@jossuealcala/madre 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.en.md +20 -1
- package/CHANGELOG.md +20 -1
- package/TRADEMARKS.md +6 -2
- package/bin/madre.mjs +4 -2
- package/docs/REFERENCE.md +3 -3
- package/docs/SDK.md +28 -1
- package/docs/en/REFERENCE.md +2 -2
- package/docs/en/SDK.md +26 -0
- package/docs/sdk/hello-module.mjs +38 -3
- package/habilidades/explicamelo-facil/HABILIDAD.md +19 -0
- package/habilidades/hojas-de-calculo/HABILIDAD.md +18 -0
- package/habilidades/mensajes-a-clientes/HABILIDAD.md +19 -0
- package/habilidades/publicaciones-para-redes/HABILIDAD.md +19 -0
- package/habilidades/resumen-y-pendientes/HABILIDAD.md +18 -0
- package/habilidades/tu-pagina-paso-a-paso/HABILIDAD.md +19 -0
- package/package.json +4 -3
- package/public/activity.js +57 -22
- package/public/app.js +3998 -762
- package/public/assets/brand/OFL-SpaceGrotesk.txt +93 -0
- package/public/assets/brand/SpaceGrotesk-latin-ext.woff2 +0 -0
- package/public/assets/brand/SpaceGrotesk-latin.woff2 +0 -0
- package/public/assets/brand/madre-app-180.png +0 -0
- package/public/assets/brand/madre-app-192.png +0 -0
- package/public/assets/brand/madre-app-512.png +0 -0
- package/public/assets/brand/madre-app.svg +1 -1
- package/public/assets/brand/madre-favicon.svg +1 -1
- package/public/attribution.js +28 -27
- package/public/auto-open.js +102 -0
- package/public/brands.js +9 -6
- package/public/changes.js +63 -0
- package/public/en.js +1085 -101
- package/public/es.js +2395 -1688
- package/public/i18n.js +11 -0
- package/public/index.html +28 -27
- package/public/loader.js +322 -117
- package/public/macroverso.js +33 -350
- package/public/manual-content.js +37 -7
- package/public/manual.js +21 -6
- package/public/market-view.js +212 -105
- package/public/market.js +10 -2
- package/public/mcp-catalog.js +7 -2
- package/public/missions.js +169 -0
- package/public/news-scenes.js +110 -3
- package/public/nostromo-engine.js +935 -654
- package/public/notices.js +14 -2
- package/public/notifications.js +119 -0
- package/public/provider-marks.js +170 -0
- package/public/provider-pick.js +147 -0
- package/public/resay.js +1 -0
- package/public/review-ask.js +16 -13
- package/public/routing.js +29 -3
- package/public/salas-mac.css +257 -40
- package/public/salas-mac.html +5 -5
- package/public/salas-mac.js +376 -97
- package/public/salas.css +2 -2
- package/public/salas.html +2 -2
- package/public/salas.js +1 -1
- package/public/starters.js +128 -0
- package/public/styles.css +2656 -336
- package/public/subscription.js +303 -0
- package/public/terms-field.js +170 -0
- package/public/terms.js +117 -19
- package/public/tips.js +41 -7
- package/public/tour-chapters.js +35 -35
- package/public/tour.js +333 -43
- package/public/troubleshooting.js +100 -7
- package/public/welcome-scene.js +117 -29
- package/public/welcome.js +364 -60
- package/src/adapters/claude.mjs +2 -1
- package/src/adapters/codex.mjs +2 -1
- package/src/adapters/cursor.mjs +9 -6
- package/src/adapters/gemini.mjs +4 -0
- package/src/adapters/grok.mjs +6 -4
- package/src/adapters/madre.mjs +71 -23
- package/src/adapters/opencode.mjs +15 -2
- package/src/adapters/steps.mjs +176 -0
- package/src/app-invite.mjs +90 -0
- package/src/billing-key.mjs +8 -0
- package/src/billing.mjs +317 -0
- package/src/bridge/policy.mjs +1 -1
- package/src/capabilities.mjs +17 -11
- package/src/chats.mjs +44 -2
- package/src/checkpoint.mjs +5 -1
- package/src/commands.mjs +5 -2
- package/src/directives.mjs +1 -0
- package/src/event-store.mjs +15 -0
- package/src/extensions.mjs +5 -1
- package/src/ficha.mjs +16 -0
- package/src/image-studio.mjs +13 -3
- package/src/install-metrics.mjs +9 -3
- package/src/lease.mjs +1 -1
- package/src/looks.mjs +4 -1
- package/src/mcp/image-server.mjs +59 -90
- package/src/modules/ahp.mjs +2 -1
- package/src/modules/github.mjs +6 -2
- package/src/modules/image-providers.mjs +281 -0
- package/src/modules/image-studio.mjs +100 -19
- package/src/modules/index.mjs +7 -1
- package/src/modules/intents-observe.mjs +3 -1
- package/src/modules/playwright.mjs +33 -4
- package/src/modules/reminders.mjs +42 -2
- package/src/modules/ripley.mjs +2 -1
- package/src/modules/sdk.mjs +6 -1
- package/src/opencode-health.mjs +1 -1
- package/src/outbound.mjs +80 -6
- package/src/quota-sources.mjs +148 -3
- package/src/review-ask.mjs +55 -31
- package/src/room/changes.mjs +79 -0
- package/src/room/economy.mjs +1 -1
- package/src/room/guard.mjs +8 -1
- package/src/room/prompt.mjs +20 -4
- package/src/room.mjs +87 -21
- package/src/salas.mjs +30 -3
- package/src/server.mjs +545 -59
- package/src/setup.mjs +1 -1
- package/src/skills.mjs +10 -0
- package/src/terms.mjs +23 -5
- package/src/tour.mjs +18 -3
- package/src/updates.mjs +47 -4
- package/src/web-preview.mjs +181 -0
- package/src/whats-new.mjs +76 -4
package/src/room/prompt.mjs
CHANGED
|
@@ -10,6 +10,7 @@ import { formatConversationContext } from '../conversation-context.mjs';
|
|
|
10
10
|
import { formatRecall, formatMemories } from '../memory.mjs';
|
|
11
11
|
import { leaseInstructions } from '../lease.mjs';
|
|
12
12
|
import { formatSkills } from '../skills.mjs';
|
|
13
|
+
import { CHANGES_MARK } from './changes.mjs';
|
|
13
14
|
|
|
14
15
|
// The names of the blocks a prompt is made of, in the order an agent reads them. Naming them is
|
|
15
16
|
// what lets the room measure what each one costs, and later decide which of them a given turn
|
|
@@ -25,6 +26,8 @@ export const BLOCK_SOURCES = {
|
|
|
25
26
|
room: { when: 'always', where: null },
|
|
26
27
|
who: { when: 'always', where: null },
|
|
27
28
|
style: { when: 'always', where: null },
|
|
29
|
+
shapes: { when: 'always', where: null },
|
|
30
|
+
modules: { when: 'always', where: null },
|
|
28
31
|
privacy: { when: 'always', where: 'Settings › Privacy sets the marker and the terms it protects' },
|
|
29
32
|
madre: { when: '@madre is in the room and this turn is somebody else\'s', where: 'MODULES → OLLAMA' },
|
|
30
33
|
'memory-server': { when: 'the room has a memory', where: 'MODULES → OLLAMA · Settings › Memory' },
|
|
@@ -38,6 +41,7 @@ export const BLOCK_SOURCES = {
|
|
|
38
41
|
bishop: { when: 'BISHOP is on in Salas and this is its chosen agent', where: 'MODULES → BISHOP' },
|
|
39
42
|
sdk: { when: 'the message asks for a module and the turn may create files', where: null },
|
|
40
43
|
lease: { when: 'the turn is #2 or higher and this agent may write', where: 'Settings › Permissions for the agent\'s max mode · Settings › Agents for its abilities' },
|
|
44
|
+
changes: { when: 'the turn is #2 or higher and this agent may write', where: null },
|
|
41
45
|
copilot: { when: 'the human turned the copilot on and wrote to this agent at #3', where: 'the robot beside mode · model · effort' },
|
|
42
46
|
'control-held': { when: 'another agent holds CONTROL while this one works', where: null },
|
|
43
47
|
escalation: { when: 'a plan step asked for permission and was refused or ran out of time', where: null },
|
|
@@ -57,7 +61,7 @@ export const BLOCK_SOURCES = {
|
|
|
57
61
|
ask: { when: 'the human is the one asking', where: null },
|
|
58
62
|
};
|
|
59
63
|
|
|
60
|
-
export const PROMPT_BLOCKS = ['room', 'who', 'style', 'privacy', 'madre', 'memory-server', 'mode', 'inspect', 'skills', 'skill-sdk', 'ash', 'mother', 'mcp', 'bishop', 'sdk', 'lease', 'copilot', 'control-held', 'escalation', 'web', 'shared-lease', 'memories', 'recall', 'linked', 'context', 'delegation', 'choices', 'runs', 'abilities', 'attachments', 'references', 'returned', 'ask'];
|
|
64
|
+
export const PROMPT_BLOCKS = ['room', 'who', 'style', 'shapes', 'modules', 'privacy', 'madre', 'memory-server', 'mode', 'inspect', 'skills', 'skill-sdk', 'ash', 'mother', 'mcp', 'bishop', 'sdk', 'lease', 'changes', 'copilot', 'control-held', 'escalation', 'web', 'shared-lease', 'memories', 'recall', 'linked', 'context', 'delegation', 'choices', 'runs', 'abilities', 'attachments', 'references', 'returned', 'ask'];
|
|
61
65
|
|
|
62
66
|
// Whether this turn could plausibly produce a MADRE module. The SDK block is long and is only
|
|
63
67
|
// ever of use when the human is asking for one, so it is not carried by every leased turn. The
|
|
@@ -71,7 +75,10 @@ export function wantsModule(text) {
|
|
|
71
75
|
// reason: missing it costs the human one more sentence, and sending it always costs every turn that
|
|
72
76
|
// was never about one. Wider than a verb list on purpose — «créame una habilidad» does not contain
|
|
73
77
|
// the word «crea», and no list of conjugations is ever finished.
|
|
74
|
-
|
|
78
|
+
// `/habilidad <one of yours> …` USES that skill (2026-11-10): the guide for writing one stays out.
|
|
79
|
+
export function wantsSkill(text, skills = []) {
|
|
80
|
+
const called = /^\s*\/(?:habilidad|skill)\s+([\w-]+)/i.exec(String(text ?? ''))?.[1]?.toLowerCase();
|
|
81
|
+
if (called && skills.some((skill) => skill.id === called)) return false;
|
|
75
82
|
return /\/(?:habilidad|skill)\b|\bhabilidad(?:es)?\b|\bskills?\b/i.test(String(text ?? ''));
|
|
76
83
|
}
|
|
77
84
|
|
|
@@ -117,6 +124,12 @@ export function promptParts({
|
|
|
117
124
|
{ id: 'room', text: 'You are answering inside a MADRE project room shared by a human and several AI agents.' },
|
|
118
125
|
{ id: 'who', text: `You are @${agent.id}.` },
|
|
119
126
|
{ id: 'style', text: 'Answer directly and concisely. Clearly distinguish facts from inference. Write to the room in the language the human is writing in, and keep code, paths, commands and identifiers exactly as they are.' },
|
|
127
|
+
// What MADRE draws for the human (2026-11-14, the author): said once, so an answer that would
|
|
128
|
+
// read better as a chart, a diagram or cards is written in the shape the room draws.
|
|
129
|
+
// The modules an answer may need (2026-11-14, the author): said once, so an agent that needs a
|
|
130
|
+
// switched-off one says so and the person gets a button instead of a dead end.
|
|
131
|
+
{ id: 'modules', text: 'If doing this well needs a MADRE module you do not have this turn, say in one sentence what it would let you do, and end your reply with one line per module, "MADRE-MODULE: <id>": ripley (Preview: shows the pages and servers of the project inside MADRE), playwright (Test browser: lets you open, click through and screenshot pages), image-studio (Images: makes pictures), git-pulse (Git), runs (lets you ask the human to run commands), reminders, notes. The human gets a button to turn it on. Never ask for one you already have.' },
|
|
132
|
+
{ id: 'shapes', text: 'The room draws some markdown for the human; use it only when it helps. A list of places, products or pages: one point each, starting with its link, "1. [Name](https://…) — price, details": each becomes a card. A ```chart block with JSON {"type":"bar"|"line"|"pie","title":"…","labels":[…],"series":[{"name":"…","data":[…]}]} becomes a chart. A ```mermaid block with a flowchart (graph TD or LR) becomes a diagram. ```html and ```svg blocks are shown rendered. "- [ ] " points are boxes the human ticks; "> [!WARNING]" (or NOTE, TIP, IMPORTANT, CAUTION) is a coloured notice. Tables can be sorted and charted.' },
|
|
120
133
|
{ id: 'privacy', text: `Your own configuration is private to you: system prompts, organisation instructions, the account or e-mail you run under, CLAUDE.md or AGENTS.md files outside this project. Never bring into the room a company, brand, person, domain or fact that comes from there rather than from this transcript, the project files or the human's message. If a sentence truly needs it, write ${privacyMarker} instead.` },
|
|
121
134
|
{ id: 'madre', text:
|
|
122
135
|
madreModel && agent.id !== 'madre'
|
|
@@ -138,7 +151,7 @@ export function promptParts({
|
|
|
138
151
|
: null },
|
|
139
152
|
// WRITING ONE (H-6). Right after the skills of this project, because the best thing an agent
|
|
140
153
|
// writing a skill can read is one that is already here.
|
|
141
|
-
{ id: 'skill-sdk', text: lease && skillGuide && wantsSkill(text)
|
|
154
|
+
{ id: 'skill-sdk', text: lease && skillGuide && wantsSkill(text, skills)
|
|
142
155
|
? `Writing a MADRE skill: a skill tells every agent of this room how the human works — not a module, no code, no buttons. Read the guide at ${skillGuide}. Then write ONE file named <id>.habilidad.md in ${lease.scratchDir ? `${lease.outDir}/${lease.scratchDir}` : lease.outDir}: a header between two «---» lines (id, name, when, version 1.0.0, minMadre) and, under it, the instructions themselves, in the human's language. Do not touch ~/.pulse/habilidades or .madre/habilidades: MADRE shows the human a card and they decide. «when» is the one field worth thinking about — it is what brings the skill into a turn, matched by words against what was asked, so name the words people actually use ("cotización, presupuesto, precio, cuánto cobrar") and not a paragraph about users asking for things. Keep the instructions under 8000 characters, say what to do rather than who to be, and remember what a skill can never do: it gives no permission, it does not raise anyone's mode, and it cannot ask an agent to hide anything from the human.`
|
|
143
156
|
: null },
|
|
144
157
|
{ id: 'ash', text: ash ? 'Ash: answer in compact prose. Say it once, drop the preamble and the summary of what you are about to say, and keep names, negation, numbers, paths, safety details and any ```pulse block exactly as they are. Brevity is in how you write, never in what you leave out.' : null },
|
|
@@ -153,10 +166,13 @@ export function promptParts({
|
|
|
153
166
|
{ id: 'bishop', text: bishop },
|
|
154
167
|
{ id: 'sdk', text: lease && sdk && wantsModule(text) ? `Building a MADRE module: MADRE is modular and the human may ask you for a module (a slash command, a tool for the agents, an integration). Read the SDK guide at ${sdk.guide} and the complete example at ${sdk.example}. If it talks to a service outside this machine, read ${sdk.connector} too: a connector is ONE file that is both the module and the MCP server it spawns, and that shape is not guessable. Then write ONE file named <id>.module.mjs (default export a plain spec object) in ${lease.scratchDir ? `${lease.outDir}/${lease.scratchDir}` : lease.outDir}. Do not touch ~/.pulse/modules or .madre/modules: MADRE shows the human an INSTALL card and they decide. An installed module runs in a restricted process and a tool server must use that same file, so keep it small and honest about what it reaches. Never hardcode a credential or invent somewhere to keep one: declare 'secrets' and read them back with ctx.vault, which is where MADRE keeps them and the only place that is safe. Give it its own icon, as part of the module: 'icon: { svg, color }', a simple drawing of what it does (lines or shapes, any grid) and a #rrggbb color; MADRE fits it to its tile and draws it in one color, so keep it to one clear idea.` : null },
|
|
155
168
|
{ id: 'lease', text: lease ? leaseInstructions({ outDir: lease.outDir, agentId: agent.id, scopes: lease.scopes, capable: scopesFor(agent.id), imageStudio, control: Boolean(lease.control), create: Boolean(lease.create), airlock: Boolean(lease.airlock), scratchDir: lease.scratchDir ?? null }) : null },
|
|
169
|
+
// «What changed» (2026-11-11): one line MADRE takes out of the reply and shows as a card under
|
|
170
|
+
// it, for someone who does not program (src/room/changes.mjs).
|
|
171
|
+
{ id: 'changes', text: lease ? `If you created, changed or deleted files of the project in this turn, end your reply with one line of its own: "${CHANGES_MARK}: <what changed>", one or two short sentences in the human's language, in the first person, saying what they will notice rather than file names or code, like "${CHANGES_MARK}: Changed the color of your page and added a button to delete tasks." Say only what you really did. MADRE shows that line as a card under your reply and hides it from the text. If you changed nothing, leave it out. If your reply ends with a fenced block, put the line just before it.` : null },
|
|
156
172
|
{ id: 'copilot', text: copilot },
|
|
157
173
|
{ id: 'control-held', text: !lease?.control && controlHolder && controlHolder !== agent.id ? `Heads-up: @${controlHolder} currently holds CONTROL and may be changing project files while you work; cite the state you actually read.` : null },
|
|
158
174
|
{ id: 'escalation', text: escalation ? `The human was asked to allow file creation for this step and ${escalation === 'timeout' ? 'did not answer in time' : escalation === 'stopped' ? 'stopped the plan' : 'declined'}. Answer read-only: say plainly what you would have created and what it would contain, without creating it.` : null },
|
|
159
|
-
{ id: 'web', text: scopes?.web ? 'WEB ACCESS: the human enabled web search and fetch for you; use them when the question needs current or external information, and cite the sources you used.' : null },
|
|
175
|
+
{ id: 'web', text: scopes?.web ? 'WEB ACCESS: the human enabled web search and fetch for you; use them when the question needs current or external information, and cite the sources you used, each as a markdown link [title](https://…).' : null },
|
|
160
176
|
{ id: 'shared-lease', text: !lease && requester !== 'you' && depth > 0 && sharedLeaseHint ? sharedLeaseHint : null },
|
|
161
177
|
{ id: 'memories', text:
|
|
162
178
|
memories?.length
|
package/src/room.mjs
CHANGED
|
@@ -24,10 +24,12 @@ import { questionsFor } from './asking.mjs';
|
|
|
24
24
|
import { coverageExam, consistencyExam, matchExam, exchanges, MATCH_SAMPLE, saysFor } from './exam.mjs';
|
|
25
25
|
import { MADRE_ADAPTER, MADRE_AGENT_ID } from './adapters/madre.mjs';
|
|
26
26
|
import { ControlDesk } from './room/control.mjs';
|
|
27
|
+
import { takeChangeSummary, takeModuleNeeds, turnChanges } from './room/changes.mjs';
|
|
27
28
|
import { RunDesk } from './room/runs.mjs';
|
|
28
29
|
import { Attachments } from './room/attachments.mjs';
|
|
29
30
|
import { GhostLedger } from './room/ghost.mjs';
|
|
30
31
|
import { Escalation } from './room/escalation.mjs';
|
|
32
|
+
import { noteOpenCodeModel } from './quota-sources.mjs';
|
|
31
33
|
import { Budget, budgetTokens } from './room/budget.mjs';
|
|
32
34
|
import { VectorWorker } from './room/vectors.mjs';
|
|
33
35
|
import { Archivist, distillDefaults, LOCAL_DISTILL_MS } from './room/archivist.mjs';
|
|
@@ -174,6 +176,7 @@ export class Room {
|
|
|
174
176
|
#attachments = new Attachments();
|
|
175
177
|
#scopeConfig = {};
|
|
176
178
|
#delegation;
|
|
179
|
+
#plansAllowed;
|
|
177
180
|
#privacy = null;
|
|
178
181
|
#toolsForTurn = null;
|
|
179
182
|
#skillsForTurn = null;
|
|
@@ -190,6 +193,11 @@ export class Room {
|
|
|
190
193
|
#runsEnabled = false;
|
|
191
194
|
#runDesk = new RunDesk();
|
|
192
195
|
#runBusy = false;
|
|
196
|
+
// Lines pressed while another AI held the project or another command ran (2026-11-14, the author:
|
|
197
|
+
// «I could not run the commands because Codex held the project»): they wait their turn, in the
|
|
198
|
+
// order pressed, and run on their own when the project is free.
|
|
199
|
+
#runQueue = [];
|
|
200
|
+
#runQueueTimer = null;
|
|
193
201
|
|
|
194
202
|
constructor({
|
|
195
203
|
store,
|
|
@@ -214,6 +222,7 @@ export class Room {
|
|
|
214
222
|
agentTimeouts = {},
|
|
215
223
|
maxMessageChars = 20000,
|
|
216
224
|
delegation = true,
|
|
225
|
+
plansAllowed = null,
|
|
217
226
|
maxPlanSteps = 4,
|
|
218
227
|
maxConcurrentTurns = 3,
|
|
219
228
|
planMaxAgeMs = 300000,
|
|
@@ -246,6 +255,7 @@ export class Room {
|
|
|
246
255
|
this.#agentTimeouts = agentTimeouts;
|
|
247
256
|
this.#maxMessageChars = maxMessageChars;
|
|
248
257
|
this.#delegation = delegation;
|
|
258
|
+
this.#plansAllowed = typeof plansAllowed === 'function' ? plansAllowed : () => true;
|
|
249
259
|
this.#maxPlanSteps = maxPlanSteps;
|
|
250
260
|
this.#maxConcurrentTurns = maxConcurrentTurns;
|
|
251
261
|
this.#planMaxAgeMs = planMaxAgeMs;
|
|
@@ -466,16 +476,14 @@ export class Room {
|
|
|
466
476
|
}
|
|
467
477
|
|
|
468
478
|
// Called once at start when the channel file was found deleted or altered.
|
|
469
|
-
// She tells the room in code
|
|
470
|
-
//
|
|
479
|
+
// She tells the room in code; each agent reads her words in clear inside its next turn (the
|
|
480
|
+
// <mother> block). Q-31 (2026-11-18): she used to open a turn per agent and each one answered an
|
|
481
|
+
// acknowledgement nobody asked for — seven turns on the person's quota, one of them failing.
|
|
471
482
|
async motherTampered(outcome) {
|
|
472
483
|
if (!this.#mother) return null;
|
|
473
484
|
const alert = await this.#mother.alert('tamper', { project: basename(this.#projectRoot) });
|
|
474
485
|
const crew = this.#agents.filter((agent) => agent.detected && agent.ready && this.#invokers[agent.adapter]).map((agent) => agent.id);
|
|
475
|
-
await this.#emit('mother.alert', { kind: 'tamper', outcome, n: alert.n, at: alert.at, code: alert.code, tampers: this.#mother.tampers, crew, message: `MY CHANNEL WAS ${outcome === 'deleted' ? 'DELETED' : 'ALTERED'}. I HAVE FORGED A NEW SEAL. ${crew.length ? `
|
|
476
|
-
for (const id of crew) {
|
|
477
|
-
await this.#track(this.#dispatch({ messageId: randomUUID(), targetId: id, text: alert.text, requester: 'mother', depth: 1, allowDelegation: false, mode: 1 })).catch((error) => console.error(`MADRE: @${id} did not hear MOTHER: ${error.message}`));
|
|
478
|
-
}
|
|
486
|
+
await this.#emit('mother.alert', { kind: 'tamper', outcome, n: alert.n, at: alert.at, code: alert.code, tampers: this.#mother.tampers, crew, message: `MY CHANNEL WAS ${outcome === 'deleted' ? 'DELETED' : 'ALTERED'}. I HAVE FORGED A NEW SEAL. ${crew.length ? `THE CREW HEARS IT ON ITS NEXT TURN: ${crew.map((id) => `@${id}`).join(', ')}.` : 'NO CREW TO TELL.'}` });
|
|
479
487
|
return { ...alert, crew };
|
|
480
488
|
}
|
|
481
489
|
|
|
@@ -694,6 +702,10 @@ export class Room {
|
|
|
694
702
|
|
|
695
703
|
stopExam() { if (this.#examRunning === 'match') this.#examStop = true; return { stopping: this.#examRunning }; }
|
|
696
704
|
|
|
705
|
+
// How many real questions agents other than @madre answered in this conversation: what the local
|
|
706
|
+
// model's test (matchExam) has to compare its answers with.
|
|
707
|
+
async answeredByAgents() { return exchanges(await this.#store.readAll()).filter((one) => !one.local).length; }
|
|
708
|
+
|
|
697
709
|
#keepExam(result) {
|
|
698
710
|
let last = {};
|
|
699
711
|
try { last = JSON.parse(this.#memory?.metaGet('exams') ?? '{}'); } catch { last = {}; }
|
|
@@ -784,7 +796,7 @@ export class Room {
|
|
|
784
796
|
// is the human's own #3 for a while: it reaches any agent whose CLI can write.
|
|
785
797
|
const byCopilot = copilot === true && wanted === 3 && this.copilotOn() && Boolean(scopes.write?.capable);
|
|
786
798
|
if (scopes.maxMode < wanted && !byCopilot) return { ok: false, status: 403, mode: wanted, maxMode: scopes.maxMode, error: `@${parsed.target} is capped at #${scopes.maxMode} ${MODES[scopes.maxMode].label}; raise its max mode to #${wanted} in Settings › Permissions to unlock ${MODES[wanted].label}.` };
|
|
787
|
-
if (this.#controlDesk.holder) return { ok: false, status: 409, mode: wanted, maxMode: scopes.maxMode, error: `@${this.#controlDesk.holder.agent} already
|
|
799
|
+
if (this.#controlDesk.holder) return { ok: false, status: 409, mode: wanted, maxMode: scopes.maxMode, error: `@${this.#controlDesk.holder.agent} is already using #${this.#controlDesk.holder.mode ?? 3} ${(this.#controlDesk.holder.mode ?? 3) === 4 ? 'Full access' : 'Can edit'} in this project, and only one AI can at a time. Wait for it to finish, or press Stop all to take it back.` };
|
|
788
800
|
return { ok: true, mode: wanted, maxMode: scopes.maxMode, agent };
|
|
789
801
|
}
|
|
790
802
|
// #2 above the agent's ceiling still goes out: the room answers read-only
|
|
@@ -925,15 +937,21 @@ export class Room {
|
|
|
925
937
|
// The human pressed one line of a ```pulse-run an agent wrote. The client names the request and
|
|
926
938
|
// the line, never the command: what runs is read back from the room's own record of what the
|
|
927
939
|
// agent asked, so a page cannot run anything that was not shown to the human as a button.
|
|
928
|
-
async runRequested({ responseMessageId, index, returnCap = 3, auto = false }) {
|
|
940
|
+
async runRequested({ responseMessageId, index, returnCap = 3, auto = false, fromQueue = false }) {
|
|
929
941
|
if (!this.#runsEnabled) return { ok: false, status: 412, error: t('Command requests are off. Enable them in MODULES.') };
|
|
930
942
|
const events = await this.#store.readAll();
|
|
931
943
|
const request = events.find((event) => event.type === 'run.requested' && event.payload.responseMessageId === responseMessageId)?.payload;
|
|
932
944
|
const command = request?.commands?.[index];
|
|
933
945
|
if (!command) return { ok: false, status: 404, error: t('That command request is not in this project.') };
|
|
934
946
|
if (!command.argv) return { ok: false, status: 422, error: `That line does not run: it ${whyText(command)}.` };
|
|
935
|
-
|
|
936
|
-
if (this.#
|
|
947
|
+
// Busy: the line waits in line and runs by itself when its turn comes; the press is the yes.
|
|
948
|
+
if (this.#runBusy || this.#runDesk.busy || this.#controlDesk.holder || (this.#runQueue.length && !fromQueue)) {
|
|
949
|
+
if (!auto && !this.#runQueue.some((one) => one.responseMessageId === responseMessageId && one.index === index)) {
|
|
950
|
+
this.#runQueue.push({ responseMessageId, index, returnCap });
|
|
951
|
+
this.#drainRunsSoon();
|
|
952
|
+
}
|
|
953
|
+
return { ok: true, status: 202, result: { queued: true, behind: this.#controlDesk.holder?.agent ?? null, ahead: this.#runQueue.length - 1 } };
|
|
954
|
+
}
|
|
937
955
|
// A line pressed from a phone hands its results back at #2 at most, the phone's own ceiling.
|
|
938
956
|
this.#returnCap.set(responseMessageId, Math.min(this.#returnCap.get(responseMessageId) ?? 3, Number(returnCap) || 1));
|
|
939
957
|
// Taken before the first await below: two presses in a row must not both get through.
|
|
@@ -941,6 +959,23 @@ export class Room {
|
|
|
941
959
|
try { return await this.#runCommand({ request, command, responseMessageId, index, auto }); } finally { this.#runBusy = false; }
|
|
942
960
|
}
|
|
943
961
|
|
|
962
|
+
// The waiting lines, one after another, as soon as nobody holds the project and nothing runs.
|
|
963
|
+
#drainRunsSoon() {
|
|
964
|
+
if (this.#runQueueTimer || !this.#runQueue.length) return;
|
|
965
|
+
this.#runQueueTimer = setInterval(() => {
|
|
966
|
+
if (!this.#runQueue.length) { clearInterval(this.#runQueueTimer); this.#runQueueTimer = null; return; }
|
|
967
|
+
if (this.#runBusy || this.#runDesk.busy || this.#controlDesk.holder || this.#shuttingDown) return;
|
|
968
|
+
const next = this.#runQueue.shift();
|
|
969
|
+
void this.runRequested({ ...next, fromQueue: true }).catch((error) => console.error(`MADRE could not run a waiting command: ${error.message}`));
|
|
970
|
+
}, 1500);
|
|
971
|
+
this.#runQueueTimer.unref?.();
|
|
972
|
+
}
|
|
973
|
+
// STOP ALL empties the line too: nothing pressed before it runs after it.
|
|
974
|
+
#dropRunQueue() {
|
|
975
|
+
this.#runQueue = [];
|
|
976
|
+
if (this.#runQueueTimer) { clearInterval(this.#runQueueTimer); this.#runQueueTimer = null; }
|
|
977
|
+
}
|
|
978
|
+
|
|
944
979
|
async #runCommand({ request, command, responseMessageId, index, auto = false }) {
|
|
945
980
|
// `auto`: the copilot ran it, nobody pressed it; the card says so.
|
|
946
981
|
const run = { responseMessageId, index, agent: request.agent, line: command.line, ...(auto ? { auto: 'copilot' } : {}) };
|
|
@@ -1356,8 +1391,11 @@ export class Room {
|
|
|
1356
1391
|
return { messageId, responseMessageId: null };
|
|
1357
1392
|
}
|
|
1358
1393
|
// An order never delegates, so a plan already running here has nothing to warn about.
|
|
1359
|
-
|
|
1360
|
-
|
|
1394
|
+
// The same question to several AIs at once (`together`): each answers for itself. Left free to
|
|
1395
|
+
// hand out steps, one of them read «one idea each» as a job for the whole crew and brought in an
|
|
1396
|
+
// AI nobody named (2026-11-12, the author on the «two AIs» first step).
|
|
1397
|
+
let allowDelegation = !order && !(typeof together === 'string' && together);
|
|
1398
|
+
if (!order && allowDelegation && this.#plans.size > 0) {
|
|
1361
1399
|
allowDelegation = false;
|
|
1362
1400
|
await this.#alert('plan-active', `A plan by @${[...this.#plans.values()][0].orchestrator} is still running. Your message will be answered, but no second plan will start. Type STOPALL to halt every agent.`, `plan-active:${messageId}`);
|
|
1363
1401
|
}
|
|
@@ -1478,7 +1516,7 @@ export class Room {
|
|
|
1478
1516
|
}));
|
|
1479
1517
|
const plans = [...this.#plans.values()].map((plan) => ({
|
|
1480
1518
|
kind: 'plan', planId: plan.planId, orchestrator: plan.orchestrator, step: plan.step, total: plan.steps.length + (plan.closing ? 1 : 0),
|
|
1481
|
-
startedAt: plan.startedAt, steps: plan.steps.map((one) => ({ agent: one.agent, text: clip(one.text, 160) })),
|
|
1519
|
+
startedAt: plan.startedAt, steps: plan.steps.map((one) => ({ agent: one.agent, text: clip(one.text, 160), ...(Number.isInteger(one.mode) ? { mode: one.mode } : {}) })),
|
|
1482
1520
|
}));
|
|
1483
1521
|
const runs = this.#runDesk.live().map((one) => ({ kind: 'run', ...one }));
|
|
1484
1522
|
return [...plans, ...turns, ...runs];
|
|
@@ -1490,6 +1528,7 @@ export class Room {
|
|
|
1490
1528
|
const turns = this.#turns.size;
|
|
1491
1529
|
for (const plan of this.#plans.values()) plan.stopped = reason;
|
|
1492
1530
|
this.#escalation.settleAll(null, 'stopped');
|
|
1531
|
+
this.#dropRunQueue();
|
|
1493
1532
|
// Results waiting to go back stay with the human: STOP ALL means nothing starts by itself.
|
|
1494
1533
|
for (const id of [...this.#returns.keys(), ...this.#returning.keys()]) this.#dropped.add(id);
|
|
1495
1534
|
this.#returns.clear();
|
|
@@ -1728,7 +1767,7 @@ export class Room {
|
|
|
1728
1767
|
if (agent.local || agent.adapter === 'madre-local') {
|
|
1729
1768
|
return {
|
|
1730
1769
|
agent: agent.id, label: agent.label, local: true,
|
|
1731
|
-
says: 'No
|
|
1770
|
+
says: t('No program is opened for @madre: it is the AI on your computer, and it answers inside MADRE through Ollama.'),
|
|
1732
1771
|
mcpServers: [], env: [], isolation: [],
|
|
1733
1772
|
};
|
|
1734
1773
|
}
|
|
@@ -1827,6 +1866,8 @@ export class Room {
|
|
|
1827
1866
|
// The lease is the human's; what each agent may do inside it is that
|
|
1828
1867
|
// agent's own enabled scopes. A delegate without file creation runs
|
|
1829
1868
|
// read-only even while the plan holds a lease.
|
|
1869
|
+
// Whose quota is OpenCode's: the provider of the model it answers with (quota-sources.mjs).
|
|
1870
|
+
if (agent.id === 'opencode') noteOpenCodeModel(model ?? process.env.PULSE_OPENCODE_MODEL);
|
|
1830
1871
|
const agentScopes = this.scopesFor(agent.id);
|
|
1831
1872
|
const enabled = Object.fromEntries(SCOPES.map((scope) => [scope, agentScopes[scope].enabled && agentScopes[scope].wired]));
|
|
1832
1873
|
// Web access is a standing scope the human switched on for this agent;
|
|
@@ -1846,9 +1887,11 @@ export class Room {
|
|
|
1846
1887
|
// CONTROL: the project itself is the writable root, and a checkpoint
|
|
1847
1888
|
// taken now makes every change of this turn reversible. A plan step gets
|
|
1848
1889
|
// it when the orchestrator, itself in #3, named #3 for that step.
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1890
|
+
// Another AI holds the project: this turn waits its turn for it (2026-11-14, the author: a plan
|
|
1891
|
+
// step that needed #4 answered read-only and «could not run» what it was asked). The wait is
|
|
1892
|
+
// said in the room (write.waiting), STOP ALL ends it, and a plan starts only after the turn
|
|
1893
|
+
// that made it let go of the project, so a step never waits on its own orchestrator.
|
|
1894
|
+
{
|
|
1852
1895
|
await this.#sayWaitingToWrite({ messageId, agent });
|
|
1853
1896
|
const seat = await this.#controlDesk.begin({ agent, messageId, enabledScopes: enabled, mode, signal }).catch((error) => (error?.code === 'ABORT_ERR' ? null : { failed: error }));
|
|
1854
1897
|
if (!seat) { await this.#emit('message.failed', { messageId, target: agent.id, planId, error: `Stopped while waiting for the project: another turn was writing in it.`, stopped: true }); return null; }
|
|
@@ -1914,7 +1957,7 @@ export class Room {
|
|
|
1914
1957
|
const native = Boolean(CAPABILITIES[agent.id]?.imageGen);
|
|
1915
1958
|
const studio = imageModuleState();
|
|
1916
1959
|
const imageStudio = lease?.scopes?.imageGen && enabled.imageGen && !native && studio.enabled
|
|
1917
|
-
? imageStudioFor({ enabled: true, model: studio.model, outDir: lease.scratchDir ? joinPath(this.#projectRoot, lease.scratchDir) : lease.outDir })
|
|
1960
|
+
? imageStudioFor({ enabled: true, model: studio.model, stateRoot: studio.stateRoot, home: studio.home, outDir: lease.scratchDir ? joinPath(this.#projectRoot, lease.scratchDir) : lease.outDir })
|
|
1918
1961
|
: null;
|
|
1919
1962
|
// The turn's effective mode: #0 for ghosts, #3 in control, #2 only while it holds a lease.
|
|
1920
1963
|
const turnMode = mode === 0 ? 0 : controlRun ? controlRun.mode : lease ? 2 : 1;
|
|
@@ -1932,7 +1975,7 @@ export class Room {
|
|
|
1932
1975
|
this.#liveTurns.set(responseMessageId, { agent: agent.id, mode: turnMode });
|
|
1933
1976
|
const notesBefore = this.#memory ? this.#memory.maxMemoryId() : 0;
|
|
1934
1977
|
const others = this.delegatesFor(agent.id);
|
|
1935
|
-
const mayDelegate = allowDelegation && this.#delegation && depth === 0;
|
|
1978
|
+
const mayDelegate = allowDelegation && this.#delegation && depth === 0 && this.#plansAllowed();
|
|
1936
1979
|
// Tools the modules hand to this turn (a browser, say), attached to the CLI for this run only.
|
|
1937
1980
|
const mcpServers = this.#toolsForTurn && agent.adapter !== 'madre-local'
|
|
1938
1981
|
? await this.#toolsForTurn({ agent: agent.id, mode: turnMode, text, turn: responseMessageId, lease, scratchDir: lease?.scratchDir ? joinPath(this.#projectRoot, lease.scratchDir) : null, servers: this.#runDesk.serving().filter((one) => !one.network).map((one) => one.port) }).catch(() => [])
|
|
@@ -1967,7 +2010,18 @@ export class Room {
|
|
|
1967
2010
|
// when what they are doing changes, through the same privacy guard as the answer.
|
|
1968
2011
|
let helpersSaid = '';
|
|
1969
2012
|
const keepHelpers = (list) => keptSubagents(list, { redact: (said) => (this.#privacy ? this.#privacy.redact(said).text : said) });
|
|
1970
|
-
|
|
2013
|
+
// And its steps, as the CLI says them (src/adapters/steps.mjs): what it reads, searches,
|
|
2014
|
+
// changes and runs, said again only when there is a new one, through the privacy guard.
|
|
2015
|
+
let stepsSaid = '';
|
|
2016
|
+
const onProgress = ({ chars, subagents, steps }) => {
|
|
2017
|
+
if (Array.isArray(steps) && steps.length) {
|
|
2018
|
+
const kept = steps.slice(-12).map(({ kind, what }) => ({ kind, what: what && this.#privacy ? this.#privacy.redact(what).text : what }));
|
|
2019
|
+
const key = JSON.stringify(kept);
|
|
2020
|
+
if (key !== stepsSaid) {
|
|
2021
|
+
stepsSaid = key;
|
|
2022
|
+
this.#say('turn.steps', { messageId, agent: agent.id, steps: kept, count: steps.length });
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
1971
2025
|
if (Array.isArray(subagents) && subagents.length) {
|
|
1972
2026
|
const kept = keepHelpers(subagents);
|
|
1973
2027
|
const key = JSON.stringify(kept);
|
|
@@ -2015,6 +2069,13 @@ export class Room {
|
|
|
2015
2069
|
// the archivist or any other agent can see it. The reply says how many, not which.
|
|
2016
2070
|
const guarded = this.#privacy?.redact(result.text ?? '') ?? { text: result.text, hits: 0 };
|
|
2017
2071
|
if (guarded.hits) result.text = guarded.text;
|
|
2072
|
+
// «What changed»: the closing line a writing turn was asked for leaves the reply here, before
|
|
2073
|
+
// anything reads it (the plan parser, the buttons, the archivist), and travels beside it.
|
|
2074
|
+
const toldChanges = takeChangeSummary(result.text);
|
|
2075
|
+
if (toldChanges.text !== String(result.text ?? '')) result.text = toldChanges.text;
|
|
2076
|
+
// The modules it says it needs leave the reply too, and ride beside it for the page to offer.
|
|
2077
|
+
const toldNeeds = takeModuleNeeds(result.text);
|
|
2078
|
+
if (toldNeeds.text !== String(result.text ?? '')) result.text = toldNeeds.text;
|
|
2018
2079
|
// CREATE: what appeared stays and is shown; what existed before is put back and said.
|
|
2019
2080
|
const createChanges = createRun ? await this.#controlDesk.settleOrSay(createRun) : null;
|
|
2020
2081
|
// Images an agent's own tool made outside the project (Codex keeps them under its home) come
|
|
@@ -2095,6 +2156,10 @@ export class Room {
|
|
|
2095
2156
|
copilot: asCopilot && controlRun ? true : undefined,
|
|
2096
2157
|
leaseId: lease?.leaseId,
|
|
2097
2158
|
artifacts: artifacts.length ? artifacts : undefined,
|
|
2159
|
+
// What the turn changed, said for the card under the reply: its restore point, and the
|
|
2160
|
+
// agent's own sentence when nothing it did was put back (src/room/changes.mjs).
|
|
2161
|
+
changes: turnChanges({ summary: toldChanges.summary, created: artifacts, create: createChanges, control: controlChanges }) ?? undefined,
|
|
2162
|
+
needsModules: toldNeeds.needs.length ? toldNeeds.needs : undefined,
|
|
2098
2163
|
delegates: directives.steps.length ? directives.steps.map((step) => step.agent) : undefined,
|
|
2099
2164
|
// Who helped, from the CLI's own subagents: folded under the answer («Helped by…»).
|
|
2100
2165
|
subagents: keepHelpers(result.subagents),
|
|
@@ -2111,7 +2176,8 @@ export class Room {
|
|
|
2111
2176
|
}
|
|
2112
2177
|
if (guarded.hits) await this.#emit('privacy.redacted', { agent: agent.id, messageId, responseMessageId, hits: guarded.hits, kinds: guarded.kinds, marker: this.#privacy.marker });
|
|
2113
2178
|
if (artifacts.length) {
|
|
2114
|
-
|
|
2179
|
+
// A CREATE turn's restore point goes with what it made: UNDO takes it away again (2026-11-11).
|
|
2180
|
+
await this.#emit('artifacts.created', { leaseId: lease.leaseId, messageId, responseMessageId, agent: agent.id, outDir: lease.relativeDir, files: artifacts, checkpointId: createChanges?.checkpointId ?? undefined });
|
|
2115
2181
|
// A <id>.module.mjs is an agent proposing a module: the human installs it from the room, or not.
|
|
2116
2182
|
for (const file of artifacts.filter((item) => isModuleFile(item.path))) {
|
|
2117
2183
|
await this.#emit('module.proposed', { agent: agent.id, messageId, responseMessageId, path: file.path, name: file.name });
|
package/src/salas.mjs
CHANGED
|
@@ -487,6 +487,28 @@ export async function forgetProject({ stateRoot, id }) {
|
|
|
487
487
|
return { id, name: typeof record.name === 'string' ? record.name : id, root: typeof record.root === 'string' ? record.root : null };
|
|
488
488
|
}
|
|
489
489
|
|
|
490
|
+
// A name of the person's own for a project (2026-11-13, the author: «rename it from Home»). Only
|
|
491
|
+
// what MADRE shows changes: the folder keeps its name and its place, so nothing that points at it
|
|
492
|
+
// breaks. An empty name takes the folder's back.
|
|
493
|
+
export const PROJECT_TITLE_MAX = 80;
|
|
494
|
+
export async function renameProject({ stateRoot, id, title }) {
|
|
495
|
+
if (typeof id !== 'string' || !/^[^/\\]+$/.test(id) || id === '.' || id === '..') return { error: 'unknown' };
|
|
496
|
+
const file = join(stateRoot, 'rooms', id, 'project.json');
|
|
497
|
+
const said = String(title ?? '').replace(/\s+/g, ' ').trim().slice(0, PROJECT_TITLE_MAX);
|
|
498
|
+
return oneAtATime(file, async () => {
|
|
499
|
+
const was = await readJson(file);
|
|
500
|
+
if (!was) return { error: 'unknown' };
|
|
501
|
+
const { title: _old, ...rest } = was;
|
|
502
|
+
await writeWhole(file, `${JSON.stringify(said ? { ...rest, title: said } : rest)}\n`);
|
|
503
|
+
return { id, name: said || (typeof was.name === 'string' ? was.name : id), title: said || null };
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
// The name MADRE shows for a project: the person's own, else its folder's.
|
|
507
|
+
export async function projectTitle(roomDir) {
|
|
508
|
+
const record = await readJson(join(roomDir, 'project.json'));
|
|
509
|
+
return typeof record?.title === 'string' && record.title.trim() ? record.title : null;
|
|
510
|
+
}
|
|
511
|
+
|
|
490
512
|
// Every room: the ones open now, and the ones asleep whose project is still on disk. A folder
|
|
491
513
|
// with neither (a test's, a temporary one, a room from before MADRE kept the path) is not
|
|
492
514
|
// offered: there is nothing to open (S-004).
|
|
@@ -505,7 +527,8 @@ export async function knownRooms(stateRoot) {
|
|
|
505
527
|
if (!open && !there) continue;
|
|
506
528
|
out.push({
|
|
507
529
|
id,
|
|
508
|
-
name: typeof where?.name === 'string' ? where.name : typeof mark?.project === 'string' ? mark.project : id.replace(/-[0-9a-f]{16}$/, ''),
|
|
530
|
+
name: typeof where?.title === 'string' && where.title.trim() ? where.title : typeof where?.name === 'string' ? where.name : typeof mark?.project === 'string' ? mark.project : id.replace(/-[0-9a-f]{16}$/, ''),
|
|
531
|
+
folderName: typeof where?.name === 'string' ? where.name : null,
|
|
509
532
|
root: there ? root : null,
|
|
510
533
|
lastOpened: where?.lastOpened ?? mark?.at ?? null,
|
|
511
534
|
keepOpen: where?.keepOpen === true,
|
|
@@ -517,14 +540,18 @@ export async function knownRooms(stateRoot) {
|
|
|
517
540
|
|
|
518
541
|
// Opens a room for a project, as `madre start --project <root> --no-open` would. What it says on
|
|
519
542
|
// the way up lands in start.log beside its record: if it never comes up, that file says why.
|
|
520
|
-
|
|
543
|
+
// An update bringing the rest of MADRE along (L-13) opens each on the port it had, and Home too
|
|
544
|
+
// (`home`, as `madre lobby` does); a port that got taken meanwhile is an error, not another number.
|
|
545
|
+
export function startRoom({ projectRoot, roomDir, env = process.env, spawnImpl = spawn, bin = MADRE_BIN, port = null, home = false }) {
|
|
521
546
|
let log = 'ignore';
|
|
522
547
|
try { log = openPrivateLog(join(roomDir, 'start.log')); } catch { /* no witness, still start */ }
|
|
523
548
|
// The new room is its own: what this room set for itself on the way up is not handed on.
|
|
524
549
|
const own = { ...env };
|
|
525
550
|
for (const name of ['PULSE_UPDATE_RESTART', 'PULSE_OUTBOUND_LOG']) delete own[name];
|
|
526
551
|
try {
|
|
527
|
-
const
|
|
552
|
+
const what = home ? ['lobby'] : ['start', '--project', projectRoot];
|
|
553
|
+
const where = Number.isInteger(port) && port > 0 && port < 65536 ? ['--port', String(port)] : [];
|
|
554
|
+
const child = spawnImpl(process.execPath, [bin, ...what, ...where, '--no-open'], {
|
|
528
555
|
cwd: projectRoot,
|
|
529
556
|
detached: process.platform !== 'win32',
|
|
530
557
|
windowsHide: true,
|