@jossuealcala/madre 1.0.4 → 1.0.5
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 +106 -1
- package/CHANGELOG.md +106 -1
- package/NOTICE +30 -0
- package/README.en.md +59 -156
- package/README.md +60 -161
- package/TRADEMARKS.md +18 -0
- package/bin/madre.mjs +2 -2
- package/docs/REFERENCE.md +1 -1
- package/docs/SDK.md +25 -4
- package/docs/en/REFERENCE.md +1 -1
- package/docs/en/SDK.md +22 -2
- package/docs/madre-banner.png +0 -0
- package/package.json +1 -1
- package/public/app.js +1078 -239
- 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-agents.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-memory.webp +0 -0
- package/public/assets/manual/shots/en-modes.webp +0 -0
- package/public/assets/manual/shots/en-modules.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-windows.webp +0 -0
- package/public/assets/manual/shots/es-agents.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-memory.webp +0 -0
- package/public/assets/manual/shots/es-modes.webp +0 -0
- package/public/assets/manual/shots/es-modules.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-windows.webp +0 -0
- package/public/en.js +74 -0
- package/public/es.js +493 -136
- package/public/i18n.js +45 -7
- package/public/index.html +2 -3
- package/public/manual-content.js +657 -0
- package/public/manual-shots.js +43 -0
- package/public/manual.css +228 -0
- package/public/manual.html +15 -0
- package/public/manual.js +398 -0
- package/public/market-art.js +56 -0
- package/public/market-view.js +140 -22
- package/public/market.js +25 -14
- package/public/mcp-catalog.js +62 -0
- package/public/resay.js +1 -0
- package/public/salas-mac.css +178 -30
- package/public/salas-mac.html +5 -5
- package/public/salas-mac.js +432 -67
- package/public/styles.css +300 -42
- package/public/tour-chapters.js +98 -90
- package/public/tour.js +63 -21
- package/public/troubleshooting.js +145 -10
- package/src/adapters/cursor.mjs +56 -7
- package/src/adapters/gemini.mjs +12 -1
- package/src/adapters/madre.mjs +27 -6
- package/src/adapters/process.mjs +5 -2
- package/src/auth-probe.mjs +22 -3
- package/src/bridge/policy.mjs +1 -1
- package/src/bridge/server.mjs +1 -1
- package/src/capabilities.mjs +3 -3
- package/src/credentials.mjs +24 -2
- package/src/history.mjs +76 -0
- package/src/i18n.mjs +23 -1
- package/src/local-ai.mjs +10 -2
- package/src/looks.mjs +17 -5
- package/src/market-license.mjs +104 -0
- package/src/market-remote.mjs +17 -1
- package/src/mcp/notes-server.mjs +120 -0
- package/src/mcp/proxy.mjs +14 -3
- package/src/models.mjs +82 -9
- package/src/modules/index.mjs +3 -1
- package/src/modules/local-models.mjs +28 -0
- package/src/modules/notes.mjs +142 -0
- package/src/modules/ollama.mjs +39 -10
- package/src/modules/playwright.mjs +14 -3
- package/src/modules/reminders.mjs +345 -0
- package/src/modules/sdk.mjs +21 -5
- package/src/mother.mjs +11 -1
- package/src/ollama.mjs +2 -2
- package/src/opencode-health.mjs +63 -0
- package/src/outbound.mjs +25 -1
- package/src/reminder-time.mjs +127 -0
- package/src/room.mjs +19 -7
- package/src/runtime-detection.mjs +6 -2
- package/src/sentinel-errors.mjs +4 -3
- package/src/server.mjs +302 -70
- package/src/tour.mjs +24 -5
package/public/salas-mac.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
//
|
|
8
8
|
// The phone has its own SALAS (salas.js), served by the bridge; the two read the same rooms.
|
|
9
9
|
|
|
10
|
-
import { browserLanguage, setLanguage, t } from './i18n.js';
|
|
10
|
+
import { browserLanguage, sessionDetail, setLanguage, t } from './i18n.js';
|
|
11
11
|
import { brandOf, monogram } from './brands.js';
|
|
12
12
|
import { startReviewAsk } from './review-ask.js';
|
|
13
13
|
import { startTour } from './tour.js';
|
|
@@ -68,8 +68,8 @@ const revoking = new Set(); // link ids whose row asks before revoking
|
|
|
68
68
|
|
|
69
69
|
// The room's looks, from this browser: the same keys the room's own page keeps (app.js, LOOKS),
|
|
70
70
|
// so a choice made here is the room's too when the room is served at this address.
|
|
71
|
-
const ACCENTS = ['madre', 'mountain', 'caribbean', 'phantom', 'malbec', 'dijon', 'pacific', 'love', 'sierra', 'pitahaya', 'papaya', 'agave', 'dinamo', 'marina', 'pulso', 'leal', 'dulce'];
|
|
72
|
-
const ACCENT_WORDS = { madre: () => t('Madre green'), mountain: () => t('Mountain green'), caribbean: () => t('Caribbean blue'), phantom: () => t('Phantom purple'), malbec: () => t('Malbec red'), dijon: () => t('Dijon yellow'), pacific: () => t('Pacific blue'), love: () => t('Love pink'), sierra: () => t('Sierra blue'), pitahaya: () => 'Pitahaya', papaya: () => 'Papaya', agave: () => 'Agave', dinamo: () => t('Dynamo black'), marina: () => t('Marina blue'), pulso: () => t('Pulse green'), leal: () => t('Loyal orange'), dulce: () => t('Sweet yellow') };
|
|
71
|
+
const ACCENTS = ['madre', 'mountain', 'caribbean', 'phantom', 'malbec', 'dijon', 'pacific', 'love', 'sierra', 'pitahaya', 'papaya', 'agave', 'dinamo', 'marina', 'pulso', 'leal', 'dulce', 'marmol', 'durazno', 'pistache', 'petalo'];
|
|
72
|
+
const ACCENT_WORDS = { madre: () => t('Madre green'), mountain: () => t('Mountain green'), caribbean: () => t('Caribbean blue'), phantom: () => t('Phantom purple'), malbec: () => t('Malbec red'), dijon: () => t('Dijon yellow'), pacific: () => t('Pacific blue'), love: () => t('Love pink'), sierra: () => t('Sierra blue'), pitahaya: () => 'Pitahaya', papaya: () => 'Papaya', agave: () => 'Agave', dinamo: () => t('Dynamo black'), marina: () => t('Marina blue'), pulso: () => t('Pulse green'), leal: () => t('Loyal orange'), dulce: () => t('Sweet yellow'), marmol: () => t('Marble gray'), durazno: () => t('Peach orange'), pistache: () => t('Pistachio green'), petalo: () => t('Petal pink') };
|
|
73
73
|
// The wallpapers are the room's (app.js, LOOKS.wallpaper; styles.css, --wp-*): the same images, the
|
|
74
74
|
// same veil, the same «mesh» and blur the room's PERSONALIZE sets, read from the same keys.
|
|
75
75
|
const WALLPAPERS = ['default', 'jarrito', 'canela', 'paradise', 'ventura', 'magna', 'biznaga', 'oceano', 'quila', 'xico', 'tropical', 'tradicion', 'urbania', CUSTOM_WALL];
|
|
@@ -320,7 +320,7 @@ function stateOf(room) {
|
|
|
320
320
|
if (glance.delayed) return { key: 'quiet', words: t('Responding slowly · last known state') };
|
|
321
321
|
if (glance.waitingCount) return { key: 'waiting', words: t('Waiting for you · {n}', { n: glance.waitingCount }) };
|
|
322
322
|
if (glance.working?.length) return { key: 'working', words: glance.working.length === 1 ? t('@{agent} is working', { agent: glance.working[0] }) : t('{n} agents working', { n: glance.working.length }) };
|
|
323
|
-
return { key: 'calm', words: t('
|
|
323
|
+
return { key: 'calm', words: t('Active') };
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
function button(className, words, onClick) {
|
|
@@ -717,8 +717,38 @@ async function restartAll() {
|
|
|
717
717
|
// NEEDS YOU: what the person would want to know before anything else, from what the rooms, the
|
|
718
718
|
// agents and MADRE itself say: a room on an older MADRE or not answering, an agent without a
|
|
719
719
|
// session, a link about to expire, a newer MADRE. Nothing listed is a guess.
|
|
720
|
+
// REMINDERS (src/modules/reminders.mjs · an idea by Daniel Castillo): the due ones of every
|
|
721
|
+
// project, first in «Needs you», each with its project and the keys to settle it.
|
|
722
|
+
let remindersSeen = null;
|
|
723
|
+
let reminderPrefs = { hour: 9, snooze: 60 }; // Reminders' settings: how long «later» is
|
|
724
|
+
const reminderLocale = () => (document.documentElement.lang === 'en' ? 'en-US' : 'es-MX');
|
|
725
|
+
const reminderWhen = (due) => new Intl.DateTimeFormat(reminderLocale(), { weekday: 'long', hour: 'numeric', minute: '2-digit' }).format(new Date(due));
|
|
726
|
+
async function loadReminders({ opening = false } = {}) {
|
|
727
|
+
const answer = await fetch('/api/reminders', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
|
|
728
|
+
if (!answer) return;
|
|
729
|
+
remindersSeen = answer.reminders ?? [];
|
|
730
|
+
if (answer.prefs) reminderPrefs = answer.prefs;
|
|
731
|
+
const due = remindersSeen.filter((one) => Date.parse(one.due) <= Date.now());
|
|
732
|
+
// Said when MADRE opens, once: the reminders themselves stay in «Needs you» until settled.
|
|
733
|
+
if (opening && due.length) toast(due.length === 1 ? t('A reminder is due: {what}', { what: due[0].text }) : t('{n} reminders are due. They are in «Needs you».', { n: due.length }), 'done');
|
|
734
|
+
drawAttention();
|
|
735
|
+
}
|
|
736
|
+
async function settleReminder(path, payload) {
|
|
737
|
+
const answer = await post(path, payload);
|
|
738
|
+
if (!answer.ok) toast(answer.body?.error ?? t('The reminder did not change.'), 'error');
|
|
739
|
+
await loadReminders();
|
|
740
|
+
}
|
|
720
741
|
function attentionItems() {
|
|
721
742
|
const items = [];
|
|
743
|
+
for (const one of (remindersSeen ?? []).filter((item) => Date.parse(item.due) <= Date.now())) {
|
|
744
|
+
const room = data?.rooms.find((item) => item.id === one.room) ?? null;
|
|
745
|
+
items.push({
|
|
746
|
+
tone: 'ok', words: one.text,
|
|
747
|
+
hint: [room ? roomLabel(room) : one.project, t('Reminder · {when}', { when: reminderWhen(one.due) })].filter(Boolean).join(' · '),
|
|
748
|
+
act: () => void settleReminder('/api/reminders/done', { id: one.id }), go: one.repeat ? t('Done for today') : t('Done'),
|
|
749
|
+
later: { go: reminderPrefs.snooze === 60 ? t('In an hour') : reminderPrefs.snooze > 60 ? t('In {n} hours', { n: Math.round(reminderPrefs.snooze / 60) }) : t('In {n} minutes', { n: reminderPrefs.snooze }), act: () => void settleReminder('/api/reminders/snooze', { id: one.id, minutes: reminderPrefs.snooze }) },
|
|
750
|
+
});
|
|
751
|
+
}
|
|
722
752
|
for (const room of data?.rooms ?? []) {
|
|
723
753
|
if (!room.open) continue;
|
|
724
754
|
const name = roomLabel(room);
|
|
@@ -744,8 +774,10 @@ function attentionItems() {
|
|
|
744
774
|
}
|
|
745
775
|
function drawAttention() {
|
|
746
776
|
const items = attentionItems();
|
|
777
|
+
// Said like «Waiting for you» (1.0.5): one big number, calm at 0, in the accent when something needs a hand.
|
|
747
778
|
ui.attention.count.textContent = String(items.length);
|
|
748
|
-
ui.attention.count.hidden =
|
|
779
|
+
ui.attention.count.hidden = false;
|
|
780
|
+
ui.attention.count.closest('.sm-tile')?.classList.toggle('has', items.length > 0);
|
|
749
781
|
ui.attention.list.replaceChildren();
|
|
750
782
|
if (!items.length) {
|
|
751
783
|
const calm = el('li', 'sm-attention-item is-calm');
|
|
@@ -765,6 +797,11 @@ function drawAttention() {
|
|
|
765
797
|
go.href = item.href;
|
|
766
798
|
if (item.external) { go.target = '_blank'; go.rel = 'noopener'; }
|
|
767
799
|
row.append(go);
|
|
800
|
+
} else if (item.later) {
|
|
801
|
+
// Two keys in one row (a reminder: done, or in an hour).
|
|
802
|
+
const acts = el('span', 'sm-attention-acts');
|
|
803
|
+
acts.append(button('sm-btn small', item.go, item.act), button('sm-btn small quiet', item.later.go, item.later.act));
|
|
804
|
+
row.append(acts);
|
|
768
805
|
} else if (item.act) row.append(button('sm-btn small', item.go, item.act));
|
|
769
806
|
ui.attention.list.append(row);
|
|
770
807
|
}
|
|
@@ -1130,8 +1167,11 @@ function paintSide(side, picked, toList) {
|
|
|
1130
1167
|
};
|
|
1131
1168
|
list(t('Looks up'), readsFrom);
|
|
1132
1169
|
list(t('Looked up by'), readBy);
|
|
1133
|
-
|
|
1134
|
-
|
|
1170
|
+
// The keys go side by side, as everywhere else in MADRE (1.0.5): one under the other read as a list.
|
|
1171
|
+
const keys = el('div', 'sm-keys-row');
|
|
1172
|
+
if (room?.open && id !== data.salas) keys.append(button('sm-btn primary small', t('Open the project'), () => leaveTo(addressOf(room))));
|
|
1173
|
+
keys.append(listKey);
|
|
1174
|
+
side.append(keys);
|
|
1135
1175
|
return;
|
|
1136
1176
|
}
|
|
1137
1177
|
const enlace = enlaces.find((one) => one.id === picked.link);
|
|
@@ -1195,6 +1235,19 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
|
|
|
1195
1235
|
merge.append(svgNode('feMergeNode', { in: 'soft' }), svgNode('feMergeNode', { in: 'SourceGraphic' }));
|
|
1196
1236
|
glow.append(merge);
|
|
1197
1237
|
defs.append(glow);
|
|
1238
|
+
// NEURAL, 1.0.5: the connections drawn as the neural mode draws memory (public/neural.js), in a
|
|
1239
|
+
// light SVG of their own: a deep glow behind, each project a neuron (a soma that glows, short
|
|
1240
|
+
// dendrites with a bead at the end), each connection an axon that bends a little, and what
|
|
1241
|
+
// crosses it a signal of light that travels the axon. Only what travels lights up.
|
|
1242
|
+
const depthId = `sm-depth-${wide ? 'w' : 't'}`;
|
|
1243
|
+
const depthGradient = svgNode('radialGradient', { id: depthId });
|
|
1244
|
+
for (const [offset, opacity] of [['0%', 1], ['60%', 0.35], ['100%', 0]]) {
|
|
1245
|
+
const stop = svgNode('stop', { offset, 'stop-opacity': opacity, class: 'depth-stop' });
|
|
1246
|
+
depthGradient.append(stop);
|
|
1247
|
+
}
|
|
1248
|
+
defs.append(depthGradient);
|
|
1249
|
+
svg.append(svgNode('ellipse', { class: 'depth', cx, cy, rx: W * 0.55, ry: H * 0.62, fill: `url(#${depthId})` }));
|
|
1250
|
+
const seedOf = (id) => [...String(id)].reduce((sum, char) => (sum * 31 + char.charCodeAt(0)) % 9973, 7);
|
|
1198
1251
|
const halos = new Map();
|
|
1199
1252
|
const haloFor = (id, colour) => {
|
|
1200
1253
|
if (halos.has(id)) return halos.get(id);
|
|
@@ -1231,7 +1284,10 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
|
|
|
1231
1284
|
const { start, end } = edges(from, to);
|
|
1232
1285
|
// To or from the Coordinator the wire is straight; between two projects it bows away from the
|
|
1233
1286
|
// middle, so it never runs through the Coordinator.
|
|
1234
|
-
|
|
1287
|
+
// An axon to or from the Coordinator bends a little, to one side or the other by its index.
|
|
1288
|
+
const sideways = (index % 2 ? 1 : -1) * Math.min(14, Math.hypot(end.x - start.x, end.y - start.y) * 0.12);
|
|
1289
|
+
const lx = end.x - start.x, ly = end.y - start.y, ll = Math.hypot(lx, ly) || 1;
|
|
1290
|
+
let d = `M${start.x.toFixed(1)} ${start.y.toFixed(1)} Q ${((start.x + end.x) / 2 - (ly / ll) * sideways).toFixed(1)} ${((start.y + end.y) / 2 + (lx / ll) * sideways).toFixed(1)} ${end.x.toFixed(1)} ${end.y.toFixed(1)}`;
|
|
1235
1291
|
if (source !== data.salas && reader !== data.salas) {
|
|
1236
1292
|
const mx = (start.x + end.x) / 2, my = (start.y + end.y) / 2;
|
|
1237
1293
|
const ox = mx - cx, oy = my - cy, out = Math.hypot(ox, oy) || 1;
|
|
@@ -1254,15 +1310,25 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
|
|
|
1254
1310
|
// travel, from the project read to the one reading, and both ways when they read each other.
|
|
1255
1311
|
// A still line under it says the connection is there even when nothing moves.
|
|
1256
1312
|
const ways = enlace.direction === 'both' ? [['out', tone], ['back', reader === data.salas ? 'var(--text-3)' : toneOf(reader)]] : [['out', tone]];
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1313
|
+
ways.forEach(([way, colour], wayIndex) => {
|
|
1314
|
+
// A signal of light that travels the axon, the way the notes go; both ways when they read
|
|
1315
|
+
// each other. With reduced motion the axon stays lit instead.
|
|
1316
|
+
if (still) {
|
|
1317
|
+
const lit = svgNode('path', { class: `flow ${way} still`, d });
|
|
1318
|
+
lit.style.stroke = colour;
|
|
1319
|
+
lit.dataset.a = source;
|
|
1320
|
+
lit.dataset.b = reader;
|
|
1321
|
+
svg.append(lit);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
const signal = svgNode('circle', { class: `flow signal ${way}`, r: wide ? 2.6 : 2.2, filter: `url(#${glowId})` });
|
|
1325
|
+
signal.style.fill = colour;
|
|
1326
|
+
signal.dataset.a = source;
|
|
1327
|
+
signal.dataset.b = reader;
|
|
1328
|
+
const travel = svgNode('animateMotion', { dur: `${(2.8 + ((index + wayIndex) % 4) * 0.45).toFixed(2)}s`, begin: `-${((index * 0.61 + wayIndex * 1.3) % 2.4).toFixed(2)}s`, repeatCount: 'indefinite', path: d, ...(way === 'back' ? { keyPoints: '1;0', keyTimes: '0;1', calcMode: 'linear' } : {}) });
|
|
1329
|
+
signal.append(travel);
|
|
1330
|
+
svg.append(signal);
|
|
1331
|
+
});
|
|
1266
1332
|
});
|
|
1267
1333
|
for (const room of ring) {
|
|
1268
1334
|
const spot = at.get(room.id);
|
|
@@ -1276,12 +1342,28 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
|
|
|
1276
1342
|
const star = svgNode('g', { class: 'star' });
|
|
1277
1343
|
star.style.setProperty('--tw', `${(2.6 + ((room.id.length * 37) % 19) / 10).toFixed(1)}s`);
|
|
1278
1344
|
star.style.setProperty('--tw-delay', `${(((room.id.charCodeAt(0) ?? 0) * 13) % 23) / 10}s`);
|
|
1345
|
+
// 1.0.5, quieter: a small soft halo, a solid dot of its tone and a hairline ring around it.
|
|
1279
1346
|
star.append(
|
|
1280
|
-
svgNode('circle', { class: 'halo', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ?
|
|
1281
|
-
svgNode('circle', { class: '
|
|
1282
|
-
svgNode('circle', { class: '
|
|
1347
|
+
svgNode('circle', { class: 'halo', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 1.9 : 1.5)).toFixed(1), fill: haloFor(room.id, toneOf(room.id)) }),
|
|
1348
|
+
svgNode('circle', { class: 'ring', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * 0.95 + 3).toFixed(1) }),
|
|
1349
|
+
svgNode('circle', { class: 'body', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: (spot.r * (on ? 0.62 : 0.55)).toFixed(1) }),
|
|
1350
|
+
svgNode('circle', { class: 'heart', cx: spot.x.toFixed(1), cy: spot.y.toFixed(1), r: Math.max(0.8, spot.r * 0.18).toFixed(1) }),
|
|
1283
1351
|
);
|
|
1284
|
-
|
|
1352
|
+
// Its dendrites: three or four short fibres, each with a bead at the end, at angles of its own
|
|
1353
|
+
// (from its id, so a project always looks the same), never towards where its name is written.
|
|
1354
|
+
const seed = seedOf(room.id);
|
|
1355
|
+
const fibres = svgNode('g', { class: 'dendrites' });
|
|
1356
|
+
const count = on ? 4 : 3;
|
|
1357
|
+
for (let at = 0; at < count; at += 1) {
|
|
1358
|
+
const angle = Math.atan2(spot.sin, spot.cos) + Math.PI * (0.55 + (at / count) * 0.9) + ((seed % 17) - 8) * 0.03;
|
|
1359
|
+
const length = spot.r * (1.7 + ((seed >> at) % 5) * 0.18);
|
|
1360
|
+
const ax = spot.x + Math.cos(angle) * spot.r * 0.7, ay = spot.y + Math.sin(angle) * spot.r * 0.7;
|
|
1361
|
+
const bx = spot.x + Math.cos(angle) * (spot.r + length), by = spot.y + Math.sin(angle) * (spot.r + length);
|
|
1362
|
+
const bend = ((seed >> (at + 2)) % 2 ? 1 : -1) * length * 0.22;
|
|
1363
|
+
fibres.append(svgNode('path', { d: `M${ax.toFixed(1)} ${ay.toFixed(1)} Q ${((ax + bx) / 2 - Math.sin(angle) * bend).toFixed(1)} ${((ay + by) / 2 + Math.cos(angle) * bend).toFixed(1)} ${bx.toFixed(1)} ${by.toFixed(1)}` }));
|
|
1364
|
+
fibres.append(svgNode('circle', { class: 'bead', cx: bx.toFixed(1), cy: by.toFixed(1), r: 1.05 }));
|
|
1365
|
+
}
|
|
1366
|
+
group.append(fibres, star);
|
|
1285
1367
|
const title = svgNode('title');
|
|
1286
1368
|
title.textContent = `${room.name} · ${stateOf(room).words}`;
|
|
1287
1369
|
group.append(title);
|
|
@@ -1301,7 +1383,7 @@ function paintMap(host, projects, enlaces, { wide, pick = null, picked = null })
|
|
|
1301
1383
|
const hub = svgNode('g', { class: `bishop${linked.has(data.salas) ? ' linked' : ''}` });
|
|
1302
1384
|
hub.dataset.id = data.salas;
|
|
1303
1385
|
// The Coordinator is the brightest star, in its own colour, its mark at the heart.
|
|
1304
|
-
hub.append(svgNode('circle', { class: 'corona', cx, cy, r: hubR *
|
|
1386
|
+
hub.append(svgNode('circle', { class: 'corona', cx, cy, r: hubR * 1.6, fill: haloFor(data.salas, brand.solid ?? brand.color) }));
|
|
1305
1387
|
if (linked.has(data.salas)) hub.append(svgNode('circle', { class: 'halo', cx, cy, r: hubR + 6 }));
|
|
1306
1388
|
hub.append(svgNode('circle', { class: 'core', cx, cy, r: hubR, fill: brand.solid ?? brand.color }));
|
|
1307
1389
|
const size = Math.round(hubR * 1.24);
|
|
@@ -1365,7 +1447,7 @@ const WIDGETS = {
|
|
|
1365
1447
|
'w-coordinator': { kind: 'coordinator', name: () => t('Coordinator training'), about: () => t('How far the Coordinator\'s own record is from training a model of its own.'), size: 4, rows: 3 },
|
|
1366
1448
|
// Only for MADRE's author, in a copy run from source with the author's token (src/server.mjs, homeWidget):
|
|
1367
1449
|
// anywhere else the server has no such widget and Home never offers it.
|
|
1368
|
-
'w-usage': { kind: 'usage', owner: true, name: () => t('MADRE usage'), about: () => t('How many copies of MADRE are on, which versions and whether people come back. Only you see this.'), size: 8, rows:
|
|
1450
|
+
'w-usage': { kind: 'usage', owner: true, name: () => t('MADRE usage'), about: () => t('How many copies of MADRE are on, which versions and whether people come back. Only you see this.'), size: 8, rows: 5 },
|
|
1369
1451
|
'w-models': { kind: 'models', name: () => t('Local models'), about: () => t('Ollama, its models, and how close each project is to its own.'), size: 4, rows: 3 },
|
|
1370
1452
|
};
|
|
1371
1453
|
const DEFAULT_LAYOUT = { order: ['bishop', 'waiting', 'links', 'projects', 'decisions', 'attention', 'memory'], size: {}, rows: {} };
|
|
@@ -1714,7 +1796,7 @@ async function openHomeAdd() {
|
|
|
1714
1796
|
homeAddSheet.addEventListener('close', () => { homeAddSheet?.remove(); homeAddSheet = null; key?.classList.remove('filled'); });
|
|
1715
1797
|
document.body.append(homeAddSheet);
|
|
1716
1798
|
homeAddSheet.showModal();
|
|
1717
|
-
void homeTour.hint('home-add', list, { inside: true, title: t('Add to Home'), text: t('The tiles you took off
|
|
1799
|
+
void homeTour.hint('home-add', list, { inside: true, title: t('Add to Home'), text: t('The tiles you took off and the widgets you can add. A widget shows up only when this Mac has something to put in it. Right-click any tile to move it, change its size or take it off.') });
|
|
1718
1800
|
// The author's widget is asked about before the list is drawn: where it cannot be read, it is not listed at all.
|
|
1719
1801
|
const ownerOk = new Set();
|
|
1720
1802
|
for (const [id, spec] of Object.entries(WIDGETS).filter(([id, spec]) => spec.owner && !placed(id))) {
|
|
@@ -1766,32 +1848,57 @@ const OS_WORDS = { darwin: 'macOS', linux: 'Linux', win32: 'Windows', other: ()
|
|
|
1766
1848
|
const WIDGET_PAINT = {
|
|
1767
1849
|
usage(body, reading) {
|
|
1768
1850
|
if (!reading.available) { body.append(el('p', 'sm-hint', reading.status ? t('madre.run answered {status}.', { status: reading.status }) : t('madre.run could not be reached.'))); return; }
|
|
1851
|
+
const n = (value) => Number(value ?? 0).toLocaleString();
|
|
1852
|
+
const pctOf = (part, whole) => (whole ? Math.round((part / whole) * 100) : 0);
|
|
1853
|
+
// The figure that matters first: people using it this week, and whether that grew.
|
|
1854
|
+
const week = Number(reading.active.week ?? 0);
|
|
1855
|
+
const before = Number(reading.active.lastWeek ?? 0);
|
|
1856
|
+
const change = before ? Math.round(((week - before) / before) * 100) : null;
|
|
1857
|
+
const lead = el('div', 'sm-usage-lead');
|
|
1858
|
+
const trend = change === null ? (week ? t('first week with data') : '') : change === 0 ? t('same as the week before') : change > 0 ? t('{n}% more than the week before', { n: change }) : t('{n}% fewer than the week before', { n: -change });
|
|
1859
|
+
lead.append(el('b', 'sm-w-big', n(week)), el('span', null, t('copies used this week')), el('small', `sm-usage-trend${change > 0 ? ' up' : change < 0 ? ' down' : ''}`, trend));
|
|
1860
|
+
body.append(lead);
|
|
1769
1861
|
const grid = el('div', 'sm-w-grid sm-usage-figures');
|
|
1770
|
-
for (const [label,
|
|
1862
|
+
for (const [label, value, line] of [
|
|
1863
|
+
[t('Today'), reading.active.day, t('on today')],
|
|
1864
|
+
[t('30 days'), reading.active.month, t('used this month')],
|
|
1865
|
+
[t('Stayed'), reading.stayed, t('came back another day')],
|
|
1866
|
+
[t('Tried it'), reading.tried, t('seen a single day')],
|
|
1867
|
+
]) {
|
|
1771
1868
|
const cell = el('div', 'sm-w-metric');
|
|
1772
|
-
cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big',
|
|
1869
|
+
cell.append(el('span', 'sm-w-label', label), el('b', 'sm-w-big', n(value)), el('small', null, line));
|
|
1773
1870
|
grid.append(cell);
|
|
1774
1871
|
}
|
|
1775
1872
|
body.append(grid);
|
|
1776
1873
|
// The last 30 days: copies on each day, and the part of them seen for the first time.
|
|
1777
1874
|
const top = Math.max(1, ...reading.days.map((one) => one.active));
|
|
1875
|
+
const chart = el('div', 'sm-usage-chart');
|
|
1778
1876
|
const days = el('div', 'sm-usage-days');
|
|
1779
1877
|
days.setAttribute('role', 'img');
|
|
1780
1878
|
days.setAttribute('aria-label', t('Copies on each day, last 30 days'));
|
|
1879
|
+
const shortDay = (day) => new Date(`${day}T12:00:00Z`).toLocaleDateString(document.documentElement.lang === 'en' ? 'en-US' : 'es-MX', { day: 'numeric', month: 'short' });
|
|
1781
1880
|
for (const one of reading.days) {
|
|
1782
1881
|
const bar = el('i');
|
|
1783
1882
|
bar.style.setProperty('--h', String(one.active / top));
|
|
1784
1883
|
bar.style.setProperty('--new', String(one.active ? one.new / one.active : 0));
|
|
1785
|
-
bar.title = t('{day}: {n} on · {fresh} new', { day: one.day, n: one.active, fresh: one.new });
|
|
1884
|
+
bar.title = t('{day}: {n} on · {fresh} new', { day: shortDay(one.day), n: one.active, fresh: one.new });
|
|
1786
1885
|
days.append(bar);
|
|
1787
1886
|
}
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1887
|
+
const axis = el('div', 'sm-usage-axis');
|
|
1888
|
+
axis.append(el('small', null, shortDay(reading.days[0]?.day ?? reading.today)), el('small', 'sm-usage-legend', ''), el('small', null, t('today')));
|
|
1889
|
+
axis.children[1].append(el('i', 'is-on'), t('on that day'), el('i', 'is-new'), t('new'));
|
|
1890
|
+
chart.append(days, axis);
|
|
1891
|
+
body.append(chart);
|
|
1892
|
+
// Each with its share; the newest version first if it is there, so «how many updated» reads at once.
|
|
1893
|
+
const shares = (list, word = (name) => name) => {
|
|
1894
|
+
const total = list.reduce((sum, one) => sum + one.n, 0);
|
|
1895
|
+
return list.slice(0, 4).map((one) => `${word(one.name)} ${pctOf(one.n, total)}%`).join(' · ') || '—';
|
|
1896
|
+
};
|
|
1897
|
+
const back = (part) => (part.cohort ? `${pctOf(part.back, part.cohort)}%` : '—');
|
|
1791
1898
|
const lines = el('div', 'sm-usage-lines');
|
|
1792
1899
|
for (const [label, said] of [
|
|
1793
|
-
[t('Versions'),
|
|
1794
|
-
[t('Systems'),
|
|
1900
|
+
[t('Versions'), shares(reading.versions)],
|
|
1901
|
+
[t('Systems'), shares(reading.os, (name) => { const word = OS_WORDS[name] ?? name; return typeof word === 'function' ? word() : word; })],
|
|
1795
1902
|
[t('Came back'), t('after 1 day {d1} · 7 days {d7} · 30 days {d30}', { d1: back(reading.retention.d1), d7: back(reading.retention.d7), d30: back(reading.retention.d30) })],
|
|
1796
1903
|
]) {
|
|
1797
1904
|
const row = el('div', 'sm-w-line');
|
|
@@ -1799,6 +1906,30 @@ const WIDGET_PAINT = {
|
|
|
1799
1906
|
lines.append(row);
|
|
1800
1907
|
}
|
|
1801
1908
|
body.append(lines);
|
|
1909
|
+
// Yours do not count: this one never, and any other you name by its identifier.
|
|
1910
|
+
const foot = el('div', 'sm-usage-mine');
|
|
1911
|
+
foot.append(el('small', null, t('Your copies do not count: {n} left out, this one included.', { n: Math.max(1, Number(reading.excluded ?? 0)) })));
|
|
1912
|
+
const form = el('form', 'sm-usage-exclude');
|
|
1913
|
+
const field = el('input');
|
|
1914
|
+
field.type = 'text'; field.placeholder = t('Another copy of yours: its identifier'); field.spellcheck = false; field.autocomplete = 'off';
|
|
1915
|
+
field.setAttribute('aria-label', t('Another copy of yours: its identifier'));
|
|
1916
|
+
const go = button('sm-btn small', t('Leave it out'), null);
|
|
1917
|
+
go.type = 'submit';
|
|
1918
|
+
form.append(field, go);
|
|
1919
|
+
form.addEventListener('submit', async (event) => {
|
|
1920
|
+
event.preventDefault();
|
|
1921
|
+
const id = field.value.trim();
|
|
1922
|
+
if (!id) return;
|
|
1923
|
+
go.disabled = true;
|
|
1924
|
+
const answer = await post('/api/salas/usage/exclude', { id });
|
|
1925
|
+
go.disabled = false;
|
|
1926
|
+
if (!answer.ok) { toast(answer.body?.error ?? t('Home did not answer.'), 'error'); return; }
|
|
1927
|
+
field.value = '';
|
|
1928
|
+
// The tile reads itself again within 20 s; the server already forgot its old figures.
|
|
1929
|
+
toast(t('That copy no longer counts. The figures update in a moment.'), 'done');
|
|
1930
|
+
});
|
|
1931
|
+
foot.append(form);
|
|
1932
|
+
body.append(foot);
|
|
1802
1933
|
},
|
|
1803
1934
|
system(body, reading) {
|
|
1804
1935
|
const cpu = el('div', 'sm-w-metric');
|
|
@@ -1977,21 +2108,84 @@ function welcomeHome() {
|
|
|
1977
2108
|
if (welcomeAsked) return;
|
|
1978
2109
|
welcomeAsked = true;
|
|
1979
2110
|
void homeTour.loaded.then(async (answer) => {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
2111
|
+
// Someone new meets the bonjour and the chapters on this same visit: Home's cards come after
|
|
2112
|
+
// them, once Home is quiet again, not only on the next visit as they did (2026-10-20).
|
|
2113
|
+
// Someone who met MADRE just now (src/tour.mjs, `met`) is walked through Home once the bonjour
|
|
2114
|
+
// and its chapters are behind them (2026-10-21): their project, the Coordinator, connections
|
|
2115
|
+
// and where the manual is, «Next» from one card to the other. A step whose place is not on this
|
|
2116
|
+
// Home is left out of the count.
|
|
2117
|
+
const HOME_WALK = [
|
|
2118
|
+
{
|
|
2119
|
+
id: 'home-start',
|
|
2120
|
+
// The list, not a card in it: the cards are drawn again every few seconds, and a hint whose
|
|
2121
|
+
// place is gone puts itself away.
|
|
2122
|
+
anchor: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? ui.projects : ui.add),
|
|
2123
|
+
title: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? t('Your project lives here') : t('Begin with a project')),
|
|
2124
|
+
text: () => (ui.projects?.querySelector?.(':scope > :not([hidden])') ? t('Open it to start. Each project keeps its own chats and its own memory.') : t('Press «Add project» and choose the folder you work in. Nothing inside it changes.')),
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
id: 'home-coordinator',
|
|
2128
|
+
anchor: () => $('sm-bishop-go'),
|
|
2129
|
+
title: () => t('Your Coordinator'),
|
|
2130
|
+
text: () => t('An agent that sees all your projects. Ask it «which project was I on yesterday?», or to pass an instruction from one project to another.'),
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
id: 'links',
|
|
2134
|
+
anchor: () => { const tile = $('sm-links-tile'); return tile && !tile.hidden ? tile.querySelector('.sm-tile-head') ?? tile : null; },
|
|
2135
|
+
title: () => t('Connections'),
|
|
2136
|
+
text: () => t('With a connection, one project can look up what another learned. You decide what and until when; nothing is written into the other.'),
|
|
2137
|
+
},
|
|
2138
|
+
{
|
|
2139
|
+
id: 'home-manual',
|
|
2140
|
+
anchor: () => ui.gear,
|
|
2141
|
+
title: () => t('The user manual'),
|
|
2142
|
+
text: () => t('Pictures of MADRE with every step marked, for when you want to look something up. It is in Settings › System › User manual, and as a PDF.'),
|
|
2143
|
+
},
|
|
2144
|
+
];
|
|
2145
|
+
// It waits for the bonjour and its chapters, however long they take: maybeBonjour only opens
|
|
2146
|
+
// the bonjour, and the walk asked once, before it was given, never came (2026-10-21).
|
|
2147
|
+
let walkTries = 0;
|
|
2148
|
+
const walk = async () => {
|
|
2149
|
+
if (!homeTour.state()?.bonjourAt) { setTimeout(walk, 2000)?.unref?.(); return; }
|
|
2150
|
+
if (!homeTour.newcomer()) return;
|
|
2151
|
+
const seen = homeTour.state()?.hints ?? {};
|
|
2152
|
+
const here = HOME_WALK.filter((one) => one.anchor()?.getClientRects().length);
|
|
2153
|
+
const at = here.findIndex((one) => !seen[one.id]);
|
|
2154
|
+
if (at < 0) return;
|
|
2155
|
+
const one = here[at];
|
|
2156
|
+
const shown = !document.querySelector('dialog[open]') && await homeTour.hint(one.id, one.anchor(), {
|
|
2157
|
+
title: one.title(),
|
|
2158
|
+
text: one.text(),
|
|
2159
|
+
step: at + 1,
|
|
2160
|
+
of: here.length,
|
|
2161
|
+
skip: () => { for (const rest of here.slice(at + 1)) void homeTour.seen(rest.id); },
|
|
2162
|
+
then: () => setTimeout(walk, 350),
|
|
2163
|
+
});
|
|
2164
|
+
// Not yet (the chapters are open, a sheet is): asked again, for as long as a first visit lasts.
|
|
2165
|
+
if (!shown && (walkTries += 1) < 600) setTimeout(walk, 2000)?.unref?.();
|
|
2166
|
+
};
|
|
2167
|
+
setTimeout(walk, 1500)?.unref?.();
|
|
2168
|
+
if (answer?.owed) await homeTour.maybeBonjour();
|
|
2169
|
+
if (!homeTour.state()?.bonjourAt) return;
|
|
2170
|
+
let linkTries = 0;
|
|
2171
|
+
// For whoever came back: what «Connections» is now. Someone new has it in the walk above.
|
|
2172
|
+
const sayLinks = async () => {
|
|
1983
2173
|
const tile = $('sm-links-tile');
|
|
1984
|
-
if (!tile || tile.hidden ||
|
|
1985
|
-
|
|
2174
|
+
if (!tile || tile.hidden || homeTour.newcomer() || homeTour.state()?.hints?.links) return;
|
|
2175
|
+
const shown = !document.querySelector('dialog[open]') && await homeTour.hint('links', tile.querySelector('.sm-tile-head') ?? tile, {
|
|
1986
2176
|
title: t('Connections'),
|
|
1987
2177
|
text: homeTour.path() === 'back'
|
|
1988
|
-
? t('
|
|
1989
|
-
: t('
|
|
2178
|
+
? t('With a connection, one project can look up what another learned. In 0.7.2 «Connections» was where you signed your agents in; that is now Settings › Agents.')
|
|
2179
|
+
: t('With a connection, one project can look up what another learned. You decide what and until when; nothing is written into the other.'),
|
|
1990
2180
|
});
|
|
1991
|
-
|
|
2181
|
+
if (!shown && (linkTries += 1) < 40) setTimeout(sayLinks, 3000)?.unref?.();
|
|
2182
|
+
};
|
|
2183
|
+
setTimeout(sayLinks, 2200)?.unref?.();
|
|
1992
2184
|
// 1.0.2 brings one key to Home's bar: said once, after any other card, never over a sheet.
|
|
1993
2185
|
let tries = 0;
|
|
1994
2186
|
const sayAdd = async () => {
|
|
2187
|
+
// News is for whoever had the version before; to someone new every key is new (2026-10-19).
|
|
2188
|
+
if (homeTour.path() === 'new') return;
|
|
1995
2189
|
const key = document.getElementById('sm-add-widgets');
|
|
1996
2190
|
if (!key || document.querySelector('dialog[open]') || !(await homeTour.hint('new-add-widgets', key, { title: t('New: add widgets'), text: t('This button opens «Add to Home»: choose the widgets you want to see here, or bring back the ones you removed.') }))) {
|
|
1997
2191
|
if ((tries += 1) < 6) setTimeout(sayAdd, 6000)?.unref?.();
|
|
@@ -2408,7 +2602,12 @@ function openLinkSheet({ reader = null, source = null } = {}) {
|
|
|
2408
2602
|
ui.link.addEventListener('click', () => openLinkSheet());
|
|
2409
2603
|
|
|
2410
2604
|
let refreshPending = null;
|
|
2411
|
-
|
|
2605
|
+
// What the cards show now, without the clocks (`at`), and when they were drawn: the 4-second clock
|
|
2606
|
+
// redraws only when a project changed, or once a minute for the «… min. ago». A board rebuilt every
|
|
2607
|
+
// 4 s replaced the button under the pointer and the click went nowhere (2026-10-19).
|
|
2608
|
+
let drawnRooms = '';
|
|
2609
|
+
let drawnRoomsAt = 0;
|
|
2610
|
+
async function refresh({ polled = false } = {}) {
|
|
2412
2611
|
if (refreshPending) return refreshPending;
|
|
2413
2612
|
refreshPending = fetch('/api/salas', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
|
|
2414
2613
|
const answer = await refreshPending;
|
|
@@ -2430,6 +2629,10 @@ async function refresh() {
|
|
|
2430
2629
|
ui.foot.textContent = t('Every project runs on this Mac, on its own, with its own memory.');
|
|
2431
2630
|
// The room's corner (app.js, #colophon): the version this Home runs, and NOTICE's own line.
|
|
2432
2631
|
if (answer.version) { drawAttribution(ui.colophon, answer.version); void drawColophonKeys(ui.colophon); }
|
|
2632
|
+
const said = JSON.stringify(answer, (key, value) => (key === 'at' ? undefined : value));
|
|
2633
|
+
if (polled && said === drawnRooms && Date.now() - drawnRoomsAt < 60000) return;
|
|
2634
|
+
drawnRooms = said;
|
|
2635
|
+
drawnRoomsAt = Date.now();
|
|
2433
2636
|
draw();
|
|
2434
2637
|
}
|
|
2435
2638
|
|
|
@@ -2678,10 +2881,8 @@ function drawTopbar() {
|
|
|
2678
2881
|
// A newer MADRE.
|
|
2679
2882
|
b.update.hidden = !(versionSeen?.available && versionSeen.latest);
|
|
2680
2883
|
if (!b.update.hidden) { b.update.lastChild.textContent = t('{version} AVAILABLE', { version: versionSeen.latest }); b.update.title = t('MADRE {version} is out.', { version: versionSeen.latest }); }
|
|
2681
|
-
//
|
|
2682
|
-
|
|
2683
|
-
b.linksCount.hidden = !links;
|
|
2684
|
-
b.linksCount.textContent = String(links);
|
|
2884
|
+
// A key, not a counter (1.0.5): how many are in force is said on the Connections tile and in its window.
|
|
2885
|
+
b.linksCount.hidden = true;
|
|
2685
2886
|
}
|
|
2686
2887
|
// ---- THE BAR'S ROOMS, the way you want them (2026-10-10), as the room's bar is arranged (app.js,
|
|
2687
2888
|
// «The bar, the way you want it»). Until the person arranges it, the bar holds the projects that
|
|
@@ -2808,9 +3009,11 @@ function drawPins() {
|
|
|
2808
3009
|
const state = stateOf(room);
|
|
2809
3010
|
const chip = pinChip(id);
|
|
2810
3011
|
const lifted = pins.drag?.moved && pins.drag.id === id;
|
|
2811
|
-
chip.className = `sm-tb-room is-${busy.get(id) === 'starting' ? '
|
|
3012
|
+
chip.className = `sm-tb-room is-${busy.get(id) === 'starting' ? 'waking' : state.key}${lifted ? ' bar-lifted' : ''}${pins.dropping === id ? ' is-moving' : ''}`;
|
|
2812
3013
|
chip.querySelector('span').textContent = room.name;
|
|
2813
3014
|
chip.lastChild.textContent = monogram(room.name);
|
|
3015
|
+
// Its accent (src/looks.mjs): the key lit in its colour while the project is open.
|
|
3016
|
+
if ((chip.dataset.accent ?? '') !== (room.accent ?? '')) { if (room.accent) chip.dataset.accent = room.accent; else delete chip.dataset.accent; }
|
|
2814
3017
|
chip.title = `${room.name} · ${busy.get(id) === 'starting' ? t('Waking…') : state.words}`;
|
|
2815
3018
|
chip.setAttribute('aria-label', room.name);
|
|
2816
3019
|
if (room.open) { chip.href = addressOf(room); chip.removeAttribute('role'); chip.removeAttribute('tabindex'); }
|
|
@@ -3133,6 +3336,8 @@ function pinsIndexAt(x) {
|
|
|
3133
3336
|
if (pins.editing && !box.contains(event.target) && !pins.card?.contains(event.target)) pinsEdit(false);
|
|
3134
3337
|
}, true);
|
|
3135
3338
|
document.addEventListener('keydown', (event) => {
|
|
3339
|
+
// ⌘ , (Ctrl+, off a Mac) opens Settings, as in a project: Home said so and did nothing (2026-10-20).
|
|
3340
|
+
if (event.key === ',' && (event.metaKey || event.ctrlKey) && !event.altKey && !event.shiftKey) { event.preventDefault(); if (settingsSheet) settingsSheet.close(); else openSettings(); return; }
|
|
3136
3341
|
if (event.key !== 'Escape') return;
|
|
3137
3342
|
if (pins.menu) { pinsCloseMenu(); return; }
|
|
3138
3343
|
if (pins.moreCard && !pins.moreCard.hidden) { pinsCloseMore(); return; }
|
|
@@ -3729,6 +3934,9 @@ const openCodeProviders = (() => {
|
|
|
3729
3934
|
: provider.via === 'oauth' ? t('Connected with its account · {n} models', { n: provider.models.length })
|
|
3730
3935
|
: t('Connected · {n} models', { n: provider.models.length });
|
|
3731
3936
|
words.append(el('b', null, provider.label), el('small', 'sm-agent-note', status));
|
|
3937
|
+
// What went wrong with it the last time a turn used it (src/opencode-health.mjs).
|
|
3938
|
+
const trouble = provider.problem === 'no-credit' ? t('No credit left: its turns are refused') : provider.problem === 'bad-key' ? t('Its key is no longer valid') : null;
|
|
3939
|
+
if (trouble) words.append(el('small', 'oc-problem', trouble));
|
|
3732
3940
|
const controls = el('span', 'sm-oc-controls');
|
|
3733
3941
|
if (provider.via === 'api') {
|
|
3734
3942
|
const remove = button('sm-btn ghost small', t('Remove the key'), async () => {
|
|
@@ -3798,10 +4006,11 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3798
4006
|
const list = el('div', 'sm-agents');
|
|
3799
4007
|
const lastLine = new Map(); // agent → what its install or sign-in said last
|
|
3800
4008
|
const openMore = new Set(); // agents whose connection detail is unfolded
|
|
3801
|
-
const
|
|
4009
|
+
const foldedMore = new Set(); // agents the person folded, even one that would open by itself
|
|
3802
4010
|
let live = null; // the sign-in running right now, as the server tells it
|
|
3803
4011
|
let poll = 0;
|
|
3804
4012
|
let stream = null;
|
|
4013
|
+
let drawn = ''; // what the list shows now: the poll redraws only when it changed
|
|
3805
4014
|
|
|
3806
4015
|
// The second half of a browser sign-in: the address stays put, and the code that page hands
|
|
3807
4016
|
// back is typed here. Without it the sign-in could only wait until its clock killed it.
|
|
@@ -3893,7 +4102,9 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3893
4102
|
return form;
|
|
3894
4103
|
};
|
|
3895
4104
|
|
|
3896
|
-
|
|
4105
|
+
// `polled`: asked by the clock, not by the person. The clock redraws only when what the server
|
|
4106
|
+
// says changed: a list rebuilt every 2.5 s ate the click that landed on the old one (2026-10-19).
|
|
4107
|
+
const paint = async ({ polled = false } = {}) => {
|
|
3897
4108
|
const answer = await fetch('/api/settings', { cache: 'no-store' }).then((response) => response.json()).catch(() => null);
|
|
3898
4109
|
if (!answer?.agents) return;
|
|
3899
4110
|
agentsSeen = answer;
|
|
@@ -3904,15 +4115,25 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3904
4115
|
// A field being typed into is never yanked away by the poll: the panel redraws every few
|
|
3905
4116
|
// seconds, and a half-pasted key or code would go with it.
|
|
3906
4117
|
if (list.contains(document.activeElement) && ['INPUT', 'SELECT'].includes(document.activeElement.tagName)) { onPaint?.(ready, answer); return; }
|
|
4118
|
+
const said = JSON.stringify(answer);
|
|
4119
|
+
if (polled && said === drawn && list.childNodes.length) { onPaint?.(ready, answer); return; }
|
|
4120
|
+
drawn = said;
|
|
3907
4121
|
list.replaceChildren();
|
|
3908
4122
|
for (const agent of answer.agents.filter((one) => one.id !== 'madre')) {
|
|
3909
4123
|
const state = agentState(agent, answer);
|
|
3910
4124
|
// The project's AJUSTES design (2026-10-13): one card per agent, folded to a line that says
|
|
3911
4125
|
// who it is and whether it has a session. One that needs the person opens by itself.
|
|
3912
|
-
|
|
4126
|
+
// One that needs the person opens by itself, and still closes when the person folds it (1.0.5).
|
|
4127
|
+
const unfolded = !foldedMore.has(agent.id) && (openMore.has(agent.id) || !state.ok || state.busyNow || (live && live.agent === agent.id));
|
|
3913
4128
|
const item = el('section', `sm-agent${state.ok ? ' ok' : ''}${unfolded ? ' open' : ''}`);
|
|
3914
4129
|
item.dataset.agent = agent.id;
|
|
3915
|
-
|
|
4130
|
+
// What opens is brought into view: the window grows downwards and an agent low in the list
|
|
4131
|
+
// opened below the edge of the screen, as if the arrow had done nothing.
|
|
4132
|
+
const head = button('sm-agent-head', null, async () => {
|
|
4133
|
+
if (unfolded) { openMore.delete(agent.id); foldedMore.add(agent.id); } else { foldedMore.delete(agent.id); openMore.add(agent.id); }
|
|
4134
|
+
await paint();
|
|
4135
|
+
if (openMore.has(agent.id)) list.querySelector(`.sm-agent[data-agent="${agent.id}"]`)?.scrollIntoView?.({ block: 'nearest', behavior: 'smooth' });
|
|
4136
|
+
});
|
|
3916
4137
|
head.setAttribute('aria-expanded', String(unfolded));
|
|
3917
4138
|
const words = el('span', 'sm-agent-words');
|
|
3918
4139
|
words.append(el('b', null, agent.label ?? agent.id), el('small', null, VENDOR_WORDS[agent.id] ?? ''));
|
|
@@ -3924,7 +4145,8 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3924
4145
|
// Which account it is signed in with, as its own CLI reports it, and which one it asks for.
|
|
3925
4146
|
const facts = el('div', 'sm-agent-facts');
|
|
3926
4147
|
if (agent.detected && agent.version) facts.append(el('code', 'sm-agent-line', `${agent.version}${agent.path ? ` · ${agent.path}` : ''}`));
|
|
3927
|
-
|
|
4148
|
+
const said = agent.detected ? sessionDetail(answer.sessions?.[agent.id]) : null;
|
|
4149
|
+
if (said) facts.append(el('small', 'sm-agent-line', said));
|
|
3928
4150
|
if (agent.account) facts.append(el('small', 'sm-agent-note', agent.account));
|
|
3929
4151
|
if (lastLine.has(agent.id) && !state.ok) {
|
|
3930
4152
|
const said = lastLine.get(agent.id);
|
|
@@ -3962,9 +4184,11 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3962
4184
|
if (keyFirst) body.append(keyForm(agent));
|
|
3963
4185
|
const acts = el('div', 'sm-agent-acts');
|
|
3964
4186
|
if (!state.busyNow) {
|
|
3965
|
-
if (!agent.detected && agent.install) acts.append(button('sm-btn primary small', t('Install'), async (event) => { event.currentTarget.disabled = true; await post(`/api/agents/${agent.id}/install`); void paint(); }));
|
|
4187
|
+
if (!agent.detected && agent.install?.command) acts.append(button('sm-btn primary small', t('Install'), async (event) => { event.currentTarget.disabled = true; await post(`/api/agents/${agent.id}/install`); void paint(); }));
|
|
3966
4188
|
else if (agent.detected && agent.login?.headless) for (const key of doorKeys()) acts.append(key);
|
|
3967
4189
|
}
|
|
4190
|
+
// Installed by hand in a terminal (its own installer): one press looks for it again.
|
|
4191
|
+
if (!agent.detected && agent.install && !agent.install.command) acts.append(button('sm-btn small', t('Check again'), async (event) => { event.currentTarget.disabled = true; await post('/api/agents/probe'); void paint(); }));
|
|
3968
4192
|
if (acts.childNodes.length) body.append(acts);
|
|
3969
4193
|
const ask = askBlock(agent);
|
|
3970
4194
|
if (ask) body.append(ask);
|
|
@@ -3983,7 +4207,7 @@ function agentsPanel({ onPaint = null, compact = false } = {}) {
|
|
|
3983
4207
|
};
|
|
3984
4208
|
const liveOn = () => {
|
|
3985
4209
|
if (!list.isConnected || poll) return;
|
|
3986
|
-
poll = setInterval(() => { if (!document.hidden) void paint(); }, 2500);
|
|
4210
|
+
poll = setInterval(() => { if (!document.hidden) void paint({ polled: true }); }, 2500);
|
|
3987
4211
|
try {
|
|
3988
4212
|
stream = new EventSource('/api/events');
|
|
3989
4213
|
stream.onmessage = (message) => {
|
|
@@ -4168,7 +4392,7 @@ function openWizard({ then = null } = {}) {
|
|
|
4168
4392
|
const SET_SECTIONS = [
|
|
4169
4393
|
['You', 'How Home looks and what its bar holds', ['look', 'bar']],
|
|
4170
4394
|
['The agents', 'Who works on this Mac', ['agents', 'bishop', 'local']],
|
|
4171
|
-
['System', 'The projects of this Mac and the
|
|
4395
|
+
['System', 'The projects of this Mac, the version and the manual', ['projects', 'release', 'manual']],
|
|
4172
4396
|
];
|
|
4173
4397
|
// The room's own icons where the room has the category (app.js, SETTINGS_CATS); the bar, BISHOP
|
|
4174
4398
|
// and the projects drawn here in the same hand: 20×20, one round stroke.
|
|
@@ -4177,9 +4401,10 @@ const SET_CATS = {
|
|
|
4177
4401
|
bar: { name: 'Top bar', icon: '<rect x="2.6" y="5.4" width="14.8" height="9.2" rx="3" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M6.2 10h2.2M11.6 10h2.2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/>' },
|
|
4178
4402
|
agents: { name: 'Agents', icon: '<circle cx="7" cy="8" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6"/><circle cx="13.6" cy="8" r="2.6" fill="none" stroke="currentColor" stroke-width="1.6"/><path d="M2.8 16c.6-2.3 2.2-3.6 4.2-3.6s3.6 1.3 4.2 3.6M9.6 13c.9-.4 2.4-.6 4-.6 2 0 3.6 1.3 4.2 3.6" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/>' },
|
|
4179
4403
|
bishop: { name: 'Coordinator', icon: '<path d="M2.6 10c1.7-3.1 4.3-4.8 7.4-4.8s5.7 1.7 7.4 4.8c-1.7 3.1-4.3 4.8-7.4 4.8S4.3 13.1 2.6 10z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/><circle cx="10" cy="10" r="2.3" fill="currentColor"/>' },
|
|
4180
|
-
local: { name: 'Local AI', icon: '<
|
|
4404
|
+
local: { name: 'Local AI', icon: '<g class="ic-net" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round"><path stroke-width=".8" d="M6.47 5.59L9.13 4.31M6.33 7.43L8.97 9.21M5.70 8.01L9.60 14.99M9.88 5.11L5.62 12.59M11.92 4.97L14.98 9.03M11.90 10.21L14.25 10.37M10.35 11.70L10.44 14.75M6.41 14.91L8.79 15.89M14.85 11.86L11.75 15.24"/><circle cx="4.8" cy="6.4" r="1.25"/><circle cx="10.8" cy="3.5" r="1.25"/><circle cx="10.3" cy="10.1" r="1.0"/><circle cx="16.1" cy="10.5" r="1.25"/><circle cx="4.7" cy="14.2" r="1.25"/><circle cx="10.5" cy="16.6" r="1.25"/></g>' },
|
|
4181
4405
|
projects: { name: 'Projects', icon: '<path d="M3.5 6.2c0-.9.7-1.6 1.6-1.6h3l1.6 1.8h5.2c.9 0 1.6.7 1.6 1.6v6.4c0 .9-.7 1.6-1.6 1.6H5.1c-.9 0-1.6-.7-1.6-1.6z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>' },
|
|
4182
4406
|
release: { name: 'Version', icon: '<path d="M15.6 10a5.6 5.6 0 1 1-1.64-3.96" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round"/><path d="M15.7 3.6v3.2h-3.2" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>' },
|
|
4407
|
+
manual: { name: 'User manual', icon: '<path d="M4 4.5h4.5a1.5 1.5 0 0 1 1.5 1.5v10a1.5 1.5 0 0 0-1.5-1.5H4zM16 4.5h-4.5A1.5 1.5 0 0 0 10 6v10a1.5 1.5 0 0 1 1.5-1.5H16z" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linejoin="round"/>' },
|
|
4183
4408
|
};
|
|
4184
4409
|
const SET_ORDER = ['look', 'bar', 'agents', 'bishop', 'local', 'projects', 'release'];
|
|
4185
4410
|
// The words the search knows, each pointing to the category that holds it (app.js, SETTINGS_INDEX).
|
|
@@ -4240,7 +4465,10 @@ function customSeg(options, current, pick, size = '') {
|
|
|
4240
4465
|
}
|
|
4241
4466
|
|
|
4242
4467
|
// How each category stands, in a line, from what the lobby already knows; nothing is guessed.
|
|
4468
|
+
// The user manual (1.0.5): its own page in Home's language, and the same manual in PDF.
|
|
4469
|
+
function openManual() { window.open(`/manual?lang=${language}`, '_blank', 'noopener'); }
|
|
4243
4470
|
function setStatus(id) {
|
|
4471
|
+
if (id === 'manual') return { line: t('Every part of MADRE, with pictures and each step marked. Also as a PDF.') };
|
|
4244
4472
|
const looks = readLooks();
|
|
4245
4473
|
if (id === 'look') return { line: `${THEME_WORDS[looks.theme]()} · ${WALLPAPER_WORDS[looks.wallpaper]()} · ${ACCENT_WORDS[looks.accent]()}` };
|
|
4246
4474
|
if (id === 'bar') {
|
|
@@ -4276,6 +4504,13 @@ function setStatus(id) {
|
|
|
4276
4504
|
function setQuick(id) {
|
|
4277
4505
|
const rows = el('div', 'settings-quick');
|
|
4278
4506
|
const add = (label, control) => { const row = el('div', 'settings-quick-row'); row.append(el('span', null, label), control); rows.append(row); };
|
|
4507
|
+
if (id === 'manual') {
|
|
4508
|
+
const pdf = el('a', 'sx-btn settings-manual-pdf', t('PDF'));
|
|
4509
|
+
pdf.href = `/assets/manual/madre-manual-${language}.pdf`;
|
|
4510
|
+
pdf.setAttribute('download', '');
|
|
4511
|
+
pdf.addEventListener('click', (event) => event.stopPropagation());
|
|
4512
|
+
add(t('Download it to print or share'), pdf);
|
|
4513
|
+
}
|
|
4279
4514
|
if (id === 'look') {
|
|
4280
4515
|
const { theme } = readLooks();
|
|
4281
4516
|
const seg = el('div', 'settings-seg');
|
|
@@ -4321,12 +4556,12 @@ function lookPreview(looks) {
|
|
|
4321
4556
|
const coord = el('div', 'hp-tile hp-coord');
|
|
4322
4557
|
const head = el('div', 'hp-head');
|
|
4323
4558
|
head.append(el('span', 'hp-mark'), el('b', null, t('Coordinator')));
|
|
4324
|
-
coord.append(head, el('small', null, t('
|
|
4559
|
+
coord.append(head, el('small', null, t('Active')), el('span', 'hp-key', t('Talk to the Coordinator')));
|
|
4325
4560
|
grid.append(coord);
|
|
4326
4561
|
names.forEach((name, index) => {
|
|
4327
4562
|
const card = el('div', 'hp-tile hp-card');
|
|
4328
4563
|
const state = el('small', 'hp-state');
|
|
4329
|
-
state.append(el('i'), index ? t('Asleep') : t('
|
|
4564
|
+
state.append(el('i'), index ? t('Asleep') : t('Active'));
|
|
4330
4565
|
card.append(el('b', null, name), state, el('span', 'hp-chat'), el('span', 'hp-strip'), el('span', `hp-key${index ? '' : ' on'}`, t('Open')));
|
|
4331
4566
|
grid.append(card);
|
|
4332
4567
|
});
|
|
@@ -4497,19 +4732,25 @@ function fillBishop(host) {
|
|
|
4497
4732
|
}
|
|
4498
4733
|
// LOCAL AI (src/local-ai.mjs): whether every project uses Ollama, the ones picked here, or each
|
|
4499
4734
|
// one as it decides in its own Settings. The switch of each project is the same one its Settings
|
|
4500
|
-
// show
|
|
4735
|
+
// show. Since 2026-10-20 Ollama itself is governed here too, as the agents are: the server, the
|
|
4736
|
+
// switch for the whole computer and the model every project uses. What it does in one project
|
|
4737
|
+
// (its roles) stays in that project's Settings › Local AI.
|
|
4501
4738
|
const LOCAL_MODE_WORDS = { auto: () => t('Automatic'), pick: () => t('One by one'), manual: () => t('Manual') };
|
|
4502
4739
|
const LOCAL_MODE_SAYS = {
|
|
4503
4740
|
auto: () => t('Every project uses it, new ones too.'),
|
|
4504
4741
|
pick: () => t('Only the projects you switch on below. New projects start without it.'),
|
|
4505
|
-
manual: () => t('Each project decides in its own
|
|
4742
|
+
manual: () => t('Each project decides in its own Settings › Local AI. New ones start with it.'),
|
|
4506
4743
|
};
|
|
4507
4744
|
let localFailed = false; // the last read got no answer: the sheet says so instead of «Reading…» forever
|
|
4508
4745
|
let localHardware = null; // what this computer can run and train (src/modules/local-models.mjs)
|
|
4509
|
-
|
|
4746
|
+
let localOllama = null; // what /api/ollama said: the server, its models, and every model this computer may choose
|
|
4747
|
+
let localAllModels = false; // «See every model» was pressed
|
|
4748
|
+
async function loadLocal({ probe = false } = {}) {
|
|
4510
4749
|
const answer = await fetch('/api/salas/local-ai', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
|
|
4511
|
-
const ollama = await
|
|
4750
|
+
const ollama = probe ? await post('/api/ollama/probe').then((reply) => (reply.ok ? reply.body : null))
|
|
4751
|
+
: await fetch('/api/ollama', { cache: 'no-store' }).then((response) => (response.ok ? response.json() : null)).catch(() => null);
|
|
4512
4752
|
if (ollama?.recommended?.hardware) localHardware = ollama.recommended.hardware;
|
|
4753
|
+
if (ollama?.ollama) localOllama = ollama;
|
|
4513
4754
|
if (answer) localSeen = answer;
|
|
4514
4755
|
localFailed = !answer;
|
|
4515
4756
|
settingsSheet?.sync({ detail: true });
|
|
@@ -4553,11 +4794,11 @@ function fillLocal(host) {
|
|
|
4553
4794
|
}
|
|
4554
4795
|
if (!localSeen) { host.append(el('p', 'settings-reading', t('Reading…'))); return; }
|
|
4555
4796
|
host.append(el('p', 'sx-intro', t('Ollama runs local AI: it searches and sums up each project\'s memory and answers as @madre, free and private. Choose which projects use it.')));
|
|
4797
|
+
drawLocalServer(host);
|
|
4798
|
+
drawLocalModel(host);
|
|
4556
4799
|
const mode = sxBlock(host, t('Which projects'), LOCAL_MODE_SAYS[localSeen.mode]());
|
|
4557
4800
|
sxRow(mode, t('Mode'), null, localModeSeg());
|
|
4558
|
-
|
|
4559
|
-
else if (!localSeen.ollama.running) sxRow(mode, t('Ollama is not running'), t('Projects keep working with their agents meanwhile. Start it from a project, in Modules › Local AI.'));
|
|
4560
|
-
// What this computer can run and train, as a project shows it in Modules › Local AI.
|
|
4801
|
+
// What this computer can run and train, as a project shows it in Settings › Local AI.
|
|
4561
4802
|
if (localHardware) drawHardware(host, localHardware, { el, sxBlock, sxRow, sxChip: (text, tone = '') => el('span', `sx-chip${tone ? ` ${tone}` : ''}`, text) });
|
|
4562
4803
|
const list = sxBlock(host, t('Projects'), localSeen.mode === 'auto' ? t('All of them use it. Choose «One by one» or «Manual» to turn some off.') : t('A switch here is the same one the project shows in its Settings.'));
|
|
4563
4804
|
if (!localSeen.projects.length) { sxRow(list, t('No projects yet'), null); return; }
|
|
@@ -4599,6 +4840,116 @@ function fillLocal(host) {
|
|
|
4599
4840
|
list.rows.append(foot);
|
|
4600
4841
|
}
|
|
4601
4842
|
}
|
|
4843
|
+
// Ollama for the whole computer: is it there, is it running, is the local AI on at all.
|
|
4844
|
+
function drawLocalServer(host) {
|
|
4845
|
+
const info = localOllama?.ollama ?? null;
|
|
4846
|
+
const block = sxBlock(host, t('Ollama'), t('One for the whole computer: every project uses the same one.'));
|
|
4847
|
+
if (!info) { sxRow(block, t('Reading…'), null); return; }
|
|
4848
|
+
const recheck = sxButton(t('Check again'), async () => { recheck.disabled = true; await loadLocal({ probe: true }); });
|
|
4849
|
+
sxRow(block, t('Server'), info.running ? t('Running · {host}', { host: info.host }) : t('Not running'), recheck);
|
|
4850
|
+
if (!info.running) {
|
|
4851
|
+
const step = info.binary
|
|
4852
|
+
? { label: t('Start Ollama'), path: '/api/ollama/start', note: t('Wakes Ollama on this computer. Nothing leaves it.') }
|
|
4853
|
+
: info.install?.display ? { label: t('Install Ollama'), path: '/api/ollama/install', note: info.install.note ?? info.install.display } : null;
|
|
4854
|
+
if (step) {
|
|
4855
|
+
const go = sxButton(step.label, async () => {
|
|
4856
|
+
go.disabled = true;
|
|
4857
|
+
const answer = await post(step.path);
|
|
4858
|
+
if (!answer.ok) { if (answer.body?.download) window.open(answer.body.download, '_blank', 'noopener'); toast(answer.body?.error ?? t('Home did not answer.')); go.disabled = false; return; }
|
|
4859
|
+
await loadLocal({ probe: true });
|
|
4860
|
+
}, { tone: 'primary' });
|
|
4861
|
+
sxRow(block, step.label, step.note, go);
|
|
4862
|
+
} else if (info.install?.download) {
|
|
4863
|
+
sxRow(block, t('Get Ollama'), null, sxButton(t('Download ↗'), () => window.open(info.install.download, '_blank', 'noopener'), { tone: 'primary' }));
|
|
4864
|
+
}
|
|
4865
|
+
sxRow(block, t('Meanwhile'), t('Projects keep working with their agents.'));
|
|
4866
|
+
}
|
|
4867
|
+
const master = el('label', 'settings-switch');
|
|
4868
|
+
const box = el('input');
|
|
4869
|
+
box.type = 'checkbox';
|
|
4870
|
+
box.checked = Boolean(localSeen.master);
|
|
4871
|
+
box.setAttribute('aria-label', t('Local AI'));
|
|
4872
|
+
box.addEventListener('change', async () => {
|
|
4873
|
+
box.disabled = true;
|
|
4874
|
+
await post('/api/ollama/settings', { enabled: box.checked });
|
|
4875
|
+
// Said to every open project at once, as a change of mode is.
|
|
4876
|
+
await saveLocal({});
|
|
4877
|
+
await loadLocal();
|
|
4878
|
+
});
|
|
4879
|
+
master.append(box, el('i'));
|
|
4880
|
+
sxRow(block, t('Local AI on this computer'), localSeen.master ? t('On. The projects you choose below use it.') : t('Off for every project.'), master);
|
|
4881
|
+
}
|
|
4882
|
+
// The model every project uses: MADRE's pick, or the person's, among the ones installed; then the
|
|
4883
|
+
// ones this computer runs that are not here yet, the recommended one first.
|
|
4884
|
+
const EMBEDDING = /embed|minilm|bge|nomic/i;
|
|
4885
|
+
// The model that fits this computer best, said the way the room's tags say things: a small pill in
|
|
4886
|
+
// the accent beside its name, never a grey bar the width of the row (2026-10-20).
|
|
4887
|
+
const RECOMMENDED_ICON = '<svg viewBox="0 0 20 20" aria-hidden="true"><path d="M10 3.2l1.9 4.1 4.4.5-3.3 3 .9 4.4L10 13l-3.9 2.2.9-4.4-3.3-3 4.4-.5z" fill="currentColor"/></svg>';
|
|
4888
|
+
function recommendedChip() {
|
|
4889
|
+
const chip = el('span', 'sx-recommend');
|
|
4890
|
+
chip.innerHTML = RECOMMENDED_ICON; // trusted: our own SVG string
|
|
4891
|
+
chip.append(el('span', null, t('Recommended for your computer')));
|
|
4892
|
+
return chip;
|
|
4893
|
+
}
|
|
4894
|
+
function drawLocalModel(host) {
|
|
4895
|
+
const info = localOllama?.ollama;
|
|
4896
|
+
if (!info?.running || !localSeen.master) return;
|
|
4897
|
+
const catalog = localOllama.recommended?.catalog ?? [];
|
|
4898
|
+
const known = (name) => catalog.find((one) => one.ollama === String(name).replace(/:latest$/, '')) ?? null;
|
|
4899
|
+
const best = catalog.find((one) => one.recommended) ?? null;
|
|
4900
|
+
const chosen = localSeen.model ?? null;
|
|
4901
|
+
const using = localSeen.ollama?.using ?? info.chatModel ?? null;
|
|
4902
|
+
const block = sxBlock(host, t('Model'), t('The one that answers as @madre and sums up the memory, in every project that uses the local AI.'));
|
|
4903
|
+
const pick = (model) => async () => { await saveLocal({ model }); await loadLocal(); };
|
|
4904
|
+
const inUse = () => el('span', 'sx-chip on', t('In use'));
|
|
4905
|
+
const autoWords = localSeen.ollama?.auto ? t('MADRE picks the best one installed: {model}.', { model: localSeen.ollama.auto }) : t('MADRE picks the best one installed.');
|
|
4906
|
+
sxRow(block, t('Automatic'), autoWords, chosen ? sxButton(t('Use'), pick(null)) : inUse());
|
|
4907
|
+
const chats = (info.models ?? []).filter((model) => !EMBEDDING.test(model.name) && !EMBEDDING.test(model.family ?? ''));
|
|
4908
|
+
for (const model of chats) {
|
|
4909
|
+
const face = known(model.name);
|
|
4910
|
+
const hint = [face?.maker, model.size ? gb(model.size) : null, face && face.run === 'no' ? t('May not fit in this computer\'s memory') : null].filter(Boolean).join(' · ');
|
|
4911
|
+
const row = sxRow(block, face?.label ?? model.name, hint, chosen && model.name === using ? inUse() : sxButton(t('Use'), pick(model.name)));
|
|
4912
|
+
if (face?.recommended) row.querySelector('.sx-words b')?.after(recommendedChip());
|
|
4913
|
+
}
|
|
4914
|
+
if (!chats.length) sxRow(block, t('No model yet'), t('Download one below: MADRE starts using it as soon as it arrives.'));
|
|
4915
|
+
// What this computer runs and has not got yet.
|
|
4916
|
+
const have = new Set(chats.map((model) => model.name.replace(/:latest$/, '')));
|
|
4917
|
+
const runs = catalog.filter((one) => one.run !== 'no' && !have.has(one.ollama))
|
|
4918
|
+
.sort((a, b) => Number(b.recommended) - Number(a.recommended) || b.params - a.params);
|
|
4919
|
+
if (!runs.length) return;
|
|
4920
|
+
const more = sxBlock(host, t('More models for your computer'), t('Only the ones that fit in its memory. Each downloads once and stays in Ollama.'));
|
|
4921
|
+
for (const one of localAllModels ? runs : runs.slice(0, 5)) {
|
|
4922
|
+
const hint = [one.maker, t(one.note), one.run === 'slow' ? t('Slow without a graphics card') : null].filter(Boolean).join(' · ');
|
|
4923
|
+
const get = sxButton(t('Download'), async () => {
|
|
4924
|
+
get.disabled = true;
|
|
4925
|
+
const answer = await post('/api/ollama/pull', { model: one.ollama });
|
|
4926
|
+
if (!answer.ok) { toast(answer.body?.error ?? t('Home did not answer.')); get.disabled = false; return; }
|
|
4927
|
+
get.textContent = t('Downloading…');
|
|
4928
|
+
watchPull(one.ollama);
|
|
4929
|
+
}, { tone: one.recommended ? 'primary' : null });
|
|
4930
|
+
const row = sxRow(more, one.label, hint, get);
|
|
4931
|
+
if (one.recommended) row.querySelector('.sx-words b')?.after(recommendedChip());
|
|
4932
|
+
}
|
|
4933
|
+
if (runs.length > 5) {
|
|
4934
|
+
const all = sxButton(localAllModels ? t('See fewer') : t('See every model ({n})', { n: runs.length }), () => { localAllModels = !localAllModels; settingsSheet?.sync({ detail: true }); });
|
|
4935
|
+
sxRow(more, '', null, all);
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
// A download takes minutes: Home looks every few seconds until the model is there, then says so.
|
|
4939
|
+
const pulling = new Set();
|
|
4940
|
+
function watchPull(model) {
|
|
4941
|
+
if (pulling.has(model)) return;
|
|
4942
|
+
pulling.add(model);
|
|
4943
|
+
toast(t('Downloading {model}. It shows here when it arrives.', { model }));
|
|
4944
|
+
const started = Date.now();
|
|
4945
|
+
const look = async () => {
|
|
4946
|
+
await loadLocal({ probe: true });
|
|
4947
|
+
if ((localOllama?.ollama?.models ?? []).some((one) => one.name.replace(/:latest$/, '') === model)) { pulling.delete(model); toast(t('{model} is ready. Choose it in Settings › Local AI.', { model })); return; }
|
|
4948
|
+
if (Date.now() - started > 60 * 60 * 1000) { pulling.delete(model); return; }
|
|
4949
|
+
setTimeout(look, 8000);
|
|
4950
|
+
};
|
|
4951
|
+
setTimeout(look, 8000);
|
|
4952
|
+
}
|
|
4602
4953
|
function fillProjects(host) {
|
|
4603
4954
|
const block = sxBlock(host, t('Projects'), t('A project is a folder: MADRE gives it its own conversations and its own memory. Adding it does not open it; you open it from its card.'));
|
|
4604
4955
|
sxRow(block, t('Add a project'), null, sxButton(t('Add'), () => { settingsSheet?.close(); openAddSheet(); }, { tone: 'primary' }));
|
|
@@ -4618,6 +4969,14 @@ function fillRelease(host) {
|
|
|
4618
4969
|
settingsSheet?.sync({ detail: true });
|
|
4619
4970
|
}) : null;
|
|
4620
4971
|
sxRow(block, `MADRE ${info?.current ?? ''}`.trim(), info ? (info.available ? t('{version} available', { version: info.latest }) : info.enabled === false ? t('not checked') : t('up to date')) : t('Reading…'), check);
|
|
4972
|
+
// The one thing the daily usage notice says about this copy (src/heartbeat.mjs), in sight.
|
|
4973
|
+
if (info?.install) {
|
|
4974
|
+
const copy = sxButton(t('Copy'), async () => {
|
|
4975
|
+
try { await navigator.clipboard.writeText(info.install); copy.textContent = t('Copied'); setTimeout(() => { copy.textContent = t('Copy'); }, 1400); } catch { toast(t('Select it and copy it.'), 'error'); }
|
|
4976
|
+
});
|
|
4977
|
+
const row = sxRow(block, t('This copy\'s identifier'), t('Random, made by this copy. It is all the daily usage notice says about it: no name, no projects.'), copy);
|
|
4978
|
+
row.querySelector('.sx-words')?.append(el('code', 'sm-install-id', info.install));
|
|
4979
|
+
}
|
|
4621
4980
|
if (info?.available) {
|
|
4622
4981
|
const notes = el('a', 'sx-btn', t('What it brings'));
|
|
4623
4982
|
notes.href = info.release ?? 'https://madre.run';
|
|
@@ -4712,8 +5071,10 @@ function openSettings(section = null) {
|
|
|
4712
5071
|
if (status.warn) node.append(el('p', 'settings-warn', status.warn));
|
|
4713
5072
|
const quick = setQuick(id);
|
|
4714
5073
|
if (quick) node.append(quick);
|
|
4715
|
-
|
|
4716
|
-
|
|
5074
|
+
// The manual is a page of its own, not a panel.
|
|
5075
|
+
const go = () => (id === 'manual' ? openManual() : openCategory(id));
|
|
5076
|
+
node.addEventListener('click', go);
|
|
5077
|
+
node.addEventListener('keydown', (event) => { if (event.target === node && (event.key === 'Enter' || event.key === ' ')) { event.preventDefault(); go(); } });
|
|
4717
5078
|
return node;
|
|
4718
5079
|
};
|
|
4719
5080
|
const board = () => {
|
|
@@ -4780,6 +5141,7 @@ function openSettings(section = null) {
|
|
|
4780
5141
|
body.replaceChildren(board(), scrim, sheet);
|
|
4781
5142
|
};
|
|
4782
5143
|
const openCategory = (id, landOn = null) => {
|
|
5144
|
+
if (id === 'manual') { openManual(); return; }
|
|
4783
5145
|
state.open = id;
|
|
4784
5146
|
draw();
|
|
4785
5147
|
dialog.scrollTop = 0;
|
|
@@ -4918,6 +5280,7 @@ void loadAgents();
|
|
|
4918
5280
|
void loadVersion();
|
|
4919
5281
|
void loadWork();
|
|
4920
5282
|
void loadDecisions();
|
|
5283
|
+
void loadReminders({ opening: true });
|
|
4921
5284
|
// `#welcome`: the first-run wizard again, on purpose (to connect an agent or add projects in steps).
|
|
4922
5285
|
if (location.hash === '#welcome') { history.replaceState(null, '', location.pathname); welcomed = true; openWizard(); }
|
|
4923
5286
|
// Sent here for the Macroverso (the key in BISHOP's room): straight into it, on a large screen.
|
|
@@ -4927,10 +5290,12 @@ if (location.hash === '#macroverso' && data && !ui.macro.hidden) { history.repla
|
|
|
4927
5290
|
// The Market's addresses: #mercado, #mercado=<module>, #modulos.
|
|
4928
5291
|
if (/^#mercado(=|$)/.test(location.hash)) openHomeMarket('shop', decodeURIComponent(location.hash.split('=')[1] ?? '') || null);
|
|
4929
5292
|
else if (location.hash === '#modulos') openHomeMarket('mine');
|
|
4930
|
-
timer = setInterval(() => { if (!document.hidden && !busy.size && !pins.dropping && !pins.drag) void refresh(); }, 4000);
|
|
5293
|
+
timer = setInterval(() => { if (!document.hidden && !busy.size && !pins.dropping && !pins.drag) void refresh({ polled: true }); }, 4000);
|
|
4931
5294
|
document.addEventListener('visibilitychange', () => { if (!document.hidden) { void refresh(); void loadAgents(); void loadWork(); void loadDecisions(); } });
|
|
4932
5295
|
// The decisions are asked again every few minutes (the route itself asks the rooms no oftener).
|
|
4933
5296
|
setInterval(() => { if (!document.hidden) void loadDecisions(); }, 5 * 60 * 1000);
|
|
5297
|
+
// A reminder comes due while Home is open: looked at every minute.
|
|
5298
|
+
setInterval(() => { if (!document.hidden) void loadReminders(); }, 60 * 1000);
|
|
4934
5299
|
|
|
4935
5300
|
// Asking for a star or a review (review-ask.js), when Home is quiet: nothing waking or closing,
|
|
4936
5301
|
// the bar not being arranged.
|