@jossuealcala/madre 1.0.3 → 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 +113 -1
- package/CHANGELOG.md +113 -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 +1087 -247
- 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 +495 -137
- 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 +185 -30
- package/public/salas-mac.html +5 -5
- package/public/salas-mac.js +475 -68
- package/public/styles.css +306 -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/ports.mjs +4 -6
- 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-sentinel.mjs +7 -3
- package/src/server.mjs +302 -70
- package/src/tour.mjs +24 -5
|
@@ -144,9 +144,9 @@ export const CONDITIONS = [
|
|
|
144
144
|
severity: 'transient',
|
|
145
145
|
title: 'Gemini model under high demand (503)',
|
|
146
146
|
match: /status 503|high demand|UNAVAILABLE/i,
|
|
147
|
-
diagnosis: 'Google is shedding load on the selected model (HTTP 503). The CLI would retry with backoff for minutes; MADRE stops it after 15 s of that and retries once on gemini-
|
|
148
|
-
remedy: 'Ask again in a minute, pick an explicit model from the Write box\'s model menu, or hand the question to another agent. PULSE_GEMINI_FALLBACK_MODEL changes the
|
|
149
|
-
fixes: same(['# wait, then resend — or continue with @codex / @claude / @opencode', 'PULSE_GEMINI_FALLBACK_MODEL=
|
|
147
|
+
diagnosis: 'Google is shedding load on the selected model (HTTP 503). The CLI would retry with backoff for minutes; MADRE stops it after 15 s of that and retries once on gemini-3-flash-preview. The turn failed only if that spare model failed too; the message is still the one about the model you chose.',
|
|
148
|
+
remedy: 'Ask again in a minute, pick an explicit model from the Write box\'s model menu, or hand the question to another agent. PULSE_GEMINI_FALLBACK_MODEL changes the spare model; left empty, there is none.',
|
|
149
|
+
fixes: same(['# wait, then resend — or continue with @codex / @claude / @opencode', 'PULSE_GEMINI_FALLBACK_MODEL= madre start']),
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
id: 'opencode-default-provider',
|
|
@@ -163,6 +163,29 @@ export const CONDITIONS = [
|
|
|
163
163
|
linux: ['npx @jossuealcala/madre setup', '# press [m] and pick a provider/model that has a session', 'PULSE_OPENCODE_MODEL=openai/gpt-5.6-sol npx @jossuealcala/madre start', 'opencode auth logout anthropic']
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
|
+
{
|
|
167
|
+
// Seen in a real project (2026-10-19): OpenCode's default model was Anthropic's, through an API
|
|
168
|
+
// key with no balance, and every turn of a plan failed with the provider's words in English.
|
|
169
|
+
id: 'provider-credit-exhausted',
|
|
170
|
+
code: 'MU-059',
|
|
171
|
+
severity: 'blocking',
|
|
172
|
+
title: 'The API account behind this agent has no credit left',
|
|
173
|
+
match: /credit balance is too low|purchase credits|insufficient_quota|exceeded your current quota|billing_hard_limit_reached/i,
|
|
174
|
+
diagnosis: 'The provider refused the turn because the API key it was sent with has no balance left. An API key is billed apart from a subscription: a Claude Pro or Max plan, or ChatGPT, does not pay for it. In OpenCode it is the provider of the model the turn asked for, and a turn that named none ran on the default model of Settings › Agents › OpenCode.',
|
|
175
|
+
remedy: 'Top up that API account, or give OpenCode a model whose provider has a session that works: your ChatGPT account (openai/…), GitHub Copilot, or OpenCode\'s own free models (opencode/…). Change the default in Settings › Agents › OpenCode, or pick another model in the Write box for one turn.',
|
|
176
|
+
fixes: same(['# Anthropic API: https://console.anthropic.com/settings/billing', '# OpenAI API: https://platform.openai.com/settings/organization/billing', '# OpenCode, one turn on its own free model:', 'PULSE_OPENCODE_MODEL=opencode/big-pickle madre start', '# or take the key with no balance out of OpenCode:', 'opencode auth logout anthropic']),
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: 'cursor-usage-limit',
|
|
180
|
+
code: 'MU-060',
|
|
181
|
+
agent: 'cursor',
|
|
182
|
+
severity: 'blocking',
|
|
183
|
+
title: 'Cursor\'s plan has reached its usage limit',
|
|
184
|
+
match: /hit your usage limit|ActionRequiredError/i,
|
|
185
|
+
diagnosis: 'Your Cursor account has used up the agent usage its plan gives for this period, and Cursor refuses every turn until it renews or the plan changes. It is Cursor\'s limit, not MADRE\'s: nothing in the project is wrong.',
|
|
186
|
+
remedy: 'Wait for the usage to renew, change the Cursor plan, or ask another agent in the meantime.',
|
|
187
|
+
fixes: same(['# plan and usage: https://cursor.com/dashboard', 'cursor-agent status']),
|
|
188
|
+
},
|
|
166
189
|
{
|
|
167
190
|
id: 'not-signed-in',
|
|
168
191
|
code: 'MU-008',
|
|
@@ -250,7 +273,8 @@ export const CONDITIONS = [
|
|
|
250
273
|
code: 'MU-015',
|
|
251
274
|
severity: 'informational',
|
|
252
275
|
title: 'Where the usage numbers come from',
|
|
253
|
-
|
|
276
|
+
// «ring» as a word: inside «answering» or «string» it filed a question about silence here.
|
|
277
|
+
match: /\bring\b|quota|limit window|resets|rollout|oauth usage|window reset|limits-real/i,
|
|
254
278
|
diagnosis: 'Each sphere\'s usage shows the provider\'s real limit when the CLI publishes it: Codex writes its 5-hour and weekly windows (used %, reset time) into every session rollout under ~/.codex/sessions; Claude Code\'s /usage comes from Anthropic\'s OAuth usage endpoint; MADRE can ask it with the token Claude Code keeps in the keychain when you start with PULSE_CLAUDE_USAGE=1 (macOS may ask once to allow the keychain read). Gemini and OpenCode publish nothing locally, so their usage shows MADRE\'s own rolling 5-hour window of budget tokens. A window whose reset time has passed counts as empty until the CLI reports again, and the failure monitor says "clear" when a full window resets.',
|
|
255
279
|
remedy: 'Click a sphere to see both windows and when they reset. If a sphere\'s usage looks stale, run one turn with that agent: Codex only rewrites its limits when it runs. Set PULSE_OFFICIAL_QUOTA=0 to stop reading provider limits altogether.',
|
|
256
280
|
fixes: same(['# click the sphere → 5h / 7d windows and reset times', 'PULSE_CLAUDE_USAGE=1 madre start # also read Claude Code\'s usage windows', 'PULSE_OFFICIAL_QUOTA=0 madre start # local window only']),
|
|
@@ -362,7 +386,7 @@ export const CONDITIONS = [
|
|
|
362
386
|
severity: 'informational',
|
|
363
387
|
title: 'Commands and mentions in the Write box',
|
|
364
388
|
match: /slash|command|\/git|\/ahp|mention|@agent/i,
|
|
365
|
-
diagnosis: 'Type "/" for the project\'s commands: /create turns on permission to create, /image routes an image request to an agent that can draw, /stopall is the brake, /git (Git) and /ahp (Continuity) run read-only in the project and post a fact card everyone, agents included, can read. Type "@" to mention an agent; the name becomes a label. Type "!" to point at a project file ("!src/room.mjs:12-20" for lines): the agent reads it first. In the viewer, click a line number (Shift+click for a range) and
|
|
389
|
+
diagnosis: 'Type "/" for the project\'s commands: /create turns on permission to create, /image routes an image request to an agent that can draw, /stopall is the brake, /git (Git) and /ahp (Continuity) run read-only in the project and post a fact card everyone, agents included, can read. Type "@" to mention an agent; the name becomes a label. Type "!" to point at a project file ("!src/room.mjs:12-20" for lines): the agent reads it first. In the viewer, click a line number (Shift+click for a range) and ASK offers what to ask about those lines, and whom.',
|
|
366
390
|
remedy: 'A struck-through command is a module that is not available in this project: open Modules to install it or turn it on (Git needs a git repository; Continuity needs to be installed).',
|
|
367
391
|
fixes: same(['# type / or @ in the Write box', '/git status', '/git log 10', '/ahp check', '/image a poster for the launch']),
|
|
368
392
|
},
|
|
@@ -710,26 +734,137 @@ export function said(condition) {
|
|
|
710
734
|
export const allConditions = () => CONDITIONS.map(said);
|
|
711
735
|
|
|
712
736
|
// Lowercase and without accents: «limite» finds «límite», and a person types what they type.
|
|
713
|
-
const fold = (text) => String(text ?? '').normalize('NFD').replace(/[
|
|
737
|
+
const fold = (text) => String(text ?? '').normalize('NFD').replace(/[̀-ͯ]/g, '').toLowerCase();
|
|
714
738
|
const AGENT_WORDS = new Set(['codex', 'claude', 'gemini', 'opencode', 'cursor', 'madre', 'ollama']);
|
|
739
|
+
const named = (words) => words.find((word) => AGENT_WORDS.has(word.replace(/^@/, '')))?.replace(/^@/, '') ?? null;
|
|
740
|
+
const wordsOf = (query) => fold(query).split(/[^a-z0-9#.@_-]+/).filter(Boolean);
|
|
741
|
+
|
|
742
|
+
// Cards that belong to an agent without being only its own: @madre lives on Ollama.
|
|
743
|
+
const BELONGS = { madre: ['madre-agent', 'ollama', 'local-ready'], ollama: ['ollama', 'madre-agent', 'local-ready'] };
|
|
744
|
+
const belongsTo = (condition, agent) => Boolean(agent) && (condition.agent === agent || Boolean(BELONGS[agent]?.includes(condition.id)));
|
|
745
|
+
// An agent's name narrows to that agent and the general cards, and puts its own first.
|
|
746
|
+
const forAgent = (conditions, agent) => {
|
|
747
|
+
if (!agent) return conditions;
|
|
748
|
+
const kept = conditions.filter((condition) => !condition.agent || condition.agent === agent);
|
|
749
|
+
return [...kept.filter((condition) => belongsTo(condition, agent)), ...kept.filter((condition) => !belongsTo(condition, agent))];
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
// How people say it, not how a CLI prints it. A person does not paste «HTTP 429»: they write
|
|
753
|
+
// «Gemini no contesta», and every word of that sat in the wrong card — «un agente no contesta»
|
|
754
|
+
// opened the restart card and «agent does not answer» the install one. Each symptom is a few
|
|
755
|
+
// patterns over the folded text, in both languages, and the cards that most often explain it, in
|
|
756
|
+
// that order. Cards owned by another agent or by @madre only count when that agent is named.
|
|
757
|
+
const SYMPTOMS = [
|
|
758
|
+
{
|
|
759
|
+
id: 'signed-out',
|
|
760
|
+
says: [
|
|
761
|
+
/\b(?:sign(?:ed)?|log(?:ged)?)[ -]?(?:in|out)\b|\blog[ -]?in\b|\bauthenticat|\bcredential|\bpassword|\bre-?auth/,
|
|
762
|
+
/\b(?:inici\w*|cerr\w*|abr\w*|pide\w*)(?: la| una| mi| de)? sesion|\bsesion (?:cerrada|expirada|vencida)|\bsin sesion|\bautentic|\bcredencial|\bcontrasena|\bme pide (?:entrar|la cuenta|mi cuenta)/,
|
|
763
|
+
],
|
|
764
|
+
cards: ['not-signed-in', 'gemini-ineligible-tier', 'opencode-default-provider', 'custom-agent-endpoint'],
|
|
765
|
+
},
|
|
766
|
+
{
|
|
767
|
+
id: 'no-credit',
|
|
768
|
+
says: [
|
|
769
|
+
/\b(?:out of (?:credit|credits|balance|money|tokens)|no (?:credit|credits|balance|money) left|ran out of (?:credit|credits|balance|money|tokens)|(?:credit|balance) (?:is )?(?:too low|exhausted|empty)|billing|top ?up|prepaid)\b/,
|
|
770
|
+
/\b(?:sin (?:credito|creditos|saldo|fondos|tokens)|se (?:me |le )?(?:acab|termin)\w* (?:el |los |la |mi |mis |su |sus )?(?:credito|creditos|saldo|fondos|tokens)|saldo|recarga\w*|facturacion|prepago)\b/,
|
|
771
|
+
],
|
|
772
|
+
cards: ['provider-credit-exhausted', 'gemini-credits-depleted', 'cursor-usage-limit', 'budget-exhausted'],
|
|
773
|
+
},
|
|
774
|
+
{
|
|
775
|
+
id: 'rate-limited',
|
|
776
|
+
says: [
|
|
777
|
+
/\b(?:rate[ -]?limit\w*|usage limit|limit reached|quota|too many requests|429)\b/,
|
|
778
|
+
/\b(?:cuota|limite de uso|limite de (?:peticiones|solicitudes|mensajes)|demasiadas (?:peticiones|solicitudes)|(?:llego|alcanzo|lleg\w*) (?:al|a su|a mi) limite|se (?:me |le )?acab\w* (?:el |la |mi |su )?(?:cuota|uso|plan))\b/,
|
|
779
|
+
],
|
|
780
|
+
cards: ['gemini-rate-limited', 'cursor-usage-limit', 'gemini-high-demand', 'provider-credit-exhausted', 'gemini-credits-depleted', 'budget-exhausted', 'limits-real'],
|
|
781
|
+
},
|
|
782
|
+
{
|
|
783
|
+
id: 'silent',
|
|
784
|
+
says: [
|
|
785
|
+
/\b(?:no|not|never|doesn'?t|don'?t|didn'?t|won'?t|isn'?t|aren'?t|wasn'?t|can'?t|cannot)\s+(?:\w+\s+)?(?:answer|respond|repl|react|say anything|do anything|finish|come back)/,
|
|
786
|
+
/\bstopped (?:answering|responding|replying|talking|working)|\b(?:hangs?|hanging|hung|stuck|frozen|freez\w*|silent|silence)\b|\bkeeps (?:thinking|loading|spinning|waiting)|\btakes (?:forever|ages|too long)|\bnothing (?:happens|comes back)|\btime ?out|\btimed out|\btime limit/,
|
|
787
|
+
/\b(?:no|nunca|ya no)\s+(?:me\s+|nos\s+|le\s+|te\s+)?(?:contest|respond|reaccion|termin|regres|devuelv|hace nada|dice nada|sale nada|escrib)|\bdej\w* de (?:contestar|responder|escribir)|\bsin respuesta|\bno hay respuesta/,
|
|
788
|
+
/\b(?:se )?qued\w* (?:pensando|cargando|callad\w*|colgad\w*|trabad\w*|atorad\w*|congelad\w*|esperando|en silencio)|\bse (?:colg|trab|ator|congel|pasm)\w*|\btarda (?:mucho|demasiado|horas|una eternidad)|\btiempo limite/,
|
|
789
|
+
],
|
|
790
|
+
cards: ['timeout', 'not-signed-in', 'provider-credit-exhausted', 'gemini-rate-limited', 'gemini-high-demand', 'gemini-credits-depleted', 'gemini-ineligible-tier', 'cursor-usage-limit', 'opencode-default-provider', 'opencode-server-error', 'madre-agent', 'ollama', 'stream-reconnecting', 'runaway-room', 'interrupted'],
|
|
791
|
+
},
|
|
792
|
+
{
|
|
793
|
+
id: 'broken',
|
|
794
|
+
says: [
|
|
795
|
+
/\b(?:doesn'?t|does not|isn'?t|is not|not|won'?t|stopped) work\w*|\bbroken\b|\bfail(?:s|ed|ing)?\b/,
|
|
796
|
+
/\bno (?:funciona|jala|sirve|anda|arranca|abre)\b|\bfall(?:a|o|ando)\b|\bdej\w* de funcionar|\besta roto\b/,
|
|
797
|
+
],
|
|
798
|
+
cards: ['not-signed-in', 'not-installed', 'timeout', 'provider-credit-exhausted', 'gemini-rate-limited', 'gemini-ineligible-tier', 'cursor-usage-limit', 'opencode-default-provider', 'madre-agent', 'ollama', 'adapter-pending'],
|
|
799
|
+
},
|
|
800
|
+
];
|
|
801
|
+
|
|
802
|
+
// The cards a symptom points to, in the order the symptoms are listed, for that agent if one is named.
|
|
803
|
+
export function symptomConditions(query) {
|
|
804
|
+
const text = fold(query);
|
|
805
|
+
const agent = named(wordsOf(query));
|
|
806
|
+
const ids = [...new Set(SYMPTOMS.filter((symptom) => symptom.says.some((pattern) => pattern.test(text))).flatMap((symptom) => symptom.cards))];
|
|
807
|
+
const owners = (id) => Object.keys(BELONGS).filter((owner) => BELONGS[owner].includes(id));
|
|
808
|
+
const cards = ids.map((id) => CONDITIONS.find((condition) => condition.id === id)).filter(Boolean)
|
|
809
|
+
.filter((condition) => !owners(condition.id).length || owners(condition.id).includes(agent));
|
|
810
|
+
return forAgent(cards, agent).map(said);
|
|
811
|
+
}
|
|
715
812
|
|
|
716
813
|
export function searchConditions(query) {
|
|
717
|
-
const words =
|
|
814
|
+
const words = wordsOf(query);
|
|
718
815
|
const all = allConditions();
|
|
719
816
|
if (!words.length) return all;
|
|
720
817
|
// A symptom is a few words, not a phrase to be found whole. An agent's name narrows the list to
|
|
721
818
|
// that agent's conditions and the general ones; every other word has to appear somewhere in the
|
|
722
819
|
// condition, read in the language it is shown in, in either language's original, or in its fixes.
|
|
723
820
|
// «claude tiempo limite» used to find nothing, and only «timeout» found the timeout card.
|
|
724
|
-
const agent = words
|
|
821
|
+
const agent = named(words);
|
|
725
822
|
const rest = words.filter((word) => !AGENT_WORDS.has(word.replace(/^@/, '')));
|
|
726
|
-
return all.filter((condition) => {
|
|
823
|
+
return forAgent(all.filter((condition) => {
|
|
727
824
|
if (agent && condition.agent && condition.agent !== agent) return false;
|
|
728
825
|
const source = CONDITIONS.find((one) => one.id === condition.id);
|
|
729
826
|
const haystack = fold([condition.id, condition.code, condition.title, condition.diagnosis, condition.remedy, condition.agent ?? '', source?.title, source?.diagnosis, ...Object.values(condition.fixes ?? {}).flat()].join(' '));
|
|
730
827
|
if (!rest.length) return !agent || condition.agent === agent || haystack.includes(agent);
|
|
731
828
|
return rest.every((word) => haystack.includes(word));
|
|
732
|
-
});
|
|
829
|
+
}), agent);
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
// A symptom is said in the words a person has, not the catalogue's. When no condition holds every
|
|
833
|
+
// word, the ones sharing the most of them come first: «codex no responde timeout» still finds the
|
|
834
|
+
// timeout. An agent's name keeps to that agent and the general ones; little words do not count.
|
|
835
|
+
const LOOSE_SKIP = new Set(['the', 'and', 'not', 'for', 'with', 'que', 'los', 'las', 'del', 'por', 'una', 'uno', 'con', 'sin', 'esta', 'este', 'muy', 'mas', 'pero']);
|
|
836
|
+
export function looseConditions(query) {
|
|
837
|
+
const words = wordsOf(query).map((word) => word.replace(/^@/, '')).filter((word) => word.length >= 3 && !LOOSE_SKIP.has(word));
|
|
838
|
+
const agent = words.find((word) => AGENT_WORDS.has(word)) ?? null;
|
|
839
|
+
const rest = words.filter((word) => !AGENT_WORDS.has(word));
|
|
840
|
+
if (!rest.length) return [];
|
|
841
|
+
return allConditions()
|
|
842
|
+
.filter((condition) => !agent || !condition.agent || condition.agent === agent)
|
|
843
|
+
.map((condition) => {
|
|
844
|
+
const haystack = fold([condition.id, condition.code, condition.title, condition.diagnosis, condition.remedy].join(' '));
|
|
845
|
+
return { condition, score: rest.filter((word) => haystack.includes(word)).length + (agent && condition.agent === agent ? 0.5 : 0) };
|
|
846
|
+
})
|
|
847
|
+
.filter((entry) => entry.score >= 1)
|
|
848
|
+
.sort((a, b) => b.score - a.score)
|
|
849
|
+
.map((entry) => entry.condition);
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
// What Diagnosis shows for what was written, most probable first. A pasted error names its own
|
|
853
|
+
// cause, so those cards lead — except the ones that only explain something, which a stray word
|
|
854
|
+
// can match. Then what the words mean as a symptom, then the cards that hold every word, and only
|
|
855
|
+
// when nothing did, the ones holding the most of them. One card appears once.
|
|
856
|
+
export function findConditions(query) {
|
|
857
|
+
const agent = named(wordsOf(query));
|
|
858
|
+
const byError = forAgent(diagnose(query, agent), agent);
|
|
859
|
+
const found = [
|
|
860
|
+
...byError.filter((condition) => condition.severity !== 'informational'),
|
|
861
|
+
...symptomConditions(query),
|
|
862
|
+
...byError.filter((condition) => condition.severity === 'informational'),
|
|
863
|
+
...searchConditions(query),
|
|
864
|
+
];
|
|
865
|
+
const seen = new Set();
|
|
866
|
+
const unique = found.filter((condition) => !seen.has(condition.id) && seen.add(condition.id));
|
|
867
|
+
return unique.length ? unique : looseConditions(query);
|
|
733
868
|
}
|
|
734
869
|
|
|
735
870
|
export function fixesFor(condition, platform, agent = null) {
|
package/src/adapters/cursor.mjs
CHANGED
|
@@ -10,7 +10,17 @@
|
|
|
10
10
|
// Tried against the real CLI on 2026-10-17: it read and answered; asked to create a file and to run
|
|
11
11
|
// `touch`, it wrote nothing and said it was in Ask mode. `--sandbox enabled` was dropped: on a Mac
|
|
12
12
|
// where Cursor's sandbox is not available the run ends at once («Sandbox mode is enabled but not
|
|
13
|
-
// available on this system»).
|
|
13
|
+
// available on this system»).
|
|
14
|
+
//
|
|
15
|
+
// From 2026-10-21 it works at every mode, as the other agents do. #2 and #3 run in Cursor's agent
|
|
16
|
+
// mode with `--force` (in print mode, changes are only proposed without it), under a configuration
|
|
17
|
+
// that allows writing and denies every command and the places nobody writes; #4 allows commands
|
|
18
|
+
// too. Cursor's own rules are the first wall, not the only one: the room locks .env, .git and its
|
|
19
|
+
// own folders read-only for the turn and puts back whatever reaches them, and at #2 everything that
|
|
20
|
+
// existed before (room/control.mjs) — so a rule Cursor read differently could not cost a file. A
|
|
21
|
+
// command cannot be put back; that is why commands are denied below #4. Not yet run against a paid
|
|
22
|
+
// Cursor account (the author's is free and spent): built on Cursor's documented permissions and
|
|
23
|
+
// held by the room's own guard.
|
|
14
24
|
import { mkdtemp, rm, writeFile } from 'node:fs/promises';
|
|
15
25
|
import { tmpdir } from 'node:os';
|
|
16
26
|
import { join } from 'node:path';
|
|
@@ -24,11 +34,35 @@ export const READONLY_CONFIG = {
|
|
|
24
34
|
sandbox: { mode: 'disabled' },
|
|
25
35
|
};
|
|
26
36
|
|
|
27
|
-
|
|
37
|
+
// The places no turn writes, whatever its mode (as OpenCode's FORBIDDEN_GLOBS). `.pulse` is left to
|
|
38
|
+
// the room when the turn has a draft folder there, because Cursor's denials win over its allowances
|
|
39
|
+
// and would shut that folder too; the room locks every other `.pulse` path itself.
|
|
40
|
+
const NEVER_WRITTEN = ['.git/**', '.madre/**', '.env', '.env.*', '**/.env', '**/.env.*', '.claude/settings.local.json'];
|
|
41
|
+
// One configuration per turn, from the lease the room gave it: none, read only.
|
|
42
|
+
export function cursorConfigFor(lease = null) {
|
|
43
|
+
if (!lease) return READONLY_CONFIG;
|
|
44
|
+
const everywhere = Boolean(lease.create || lease.control || lease.airlock);
|
|
45
|
+
const dir = String(lease.relativeDir ?? '.').replace(/^\.\/+/, '').replace(/\/+$/, '');
|
|
46
|
+
const writes = everywhere || !dir || dir === '.' ? ['Write(**)'] : [`Write(${dir}/**)`];
|
|
47
|
+
const never = [...NEVER_WRITTEN, ...(lease.scratchDir ? [] : ['.pulse/**'])].map((glob) => `Write(${glob})`);
|
|
48
|
+
return {
|
|
49
|
+
version: 1,
|
|
50
|
+
permissions: {
|
|
51
|
+
allow: ['Read(**)', ...writes, ...(lease.airlock ? ['Shell(*)'] : [])],
|
|
52
|
+
deny: [...(lease.airlock ? [] : ['Shell(*)']), ...never],
|
|
53
|
+
},
|
|
54
|
+
approvalMode: 'allowlist',
|
|
55
|
+
sandbox: { mode: 'disabled' },
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function buildCursorArgs({ projectRoot, prompt, model = process.env.PULSE_CURSOR_MODEL || null, lease = null }) {
|
|
28
60
|
return [
|
|
29
61
|
'--print',
|
|
30
62
|
'--output-format', 'stream-json',
|
|
31
|
-
'
|
|
63
|
+
// Reading: Cursor's own ask mode. Writing: its agent mode, with the changes applied (`--force`)
|
|
64
|
+
// under the turn's configuration above.
|
|
65
|
+
...(lease ? ['--force'] : ['--mode', 'ask']),
|
|
32
66
|
// A headless run cannot answer the «trust this folder?» question; the project is the human's.
|
|
33
67
|
'--trust',
|
|
34
68
|
'--workspace', projectRoot,
|
|
@@ -74,14 +108,21 @@ export function parseCursorOutput(output) {
|
|
|
74
108
|
return { text, usage, ...(error ? { error } : {}) };
|
|
75
109
|
}
|
|
76
110
|
|
|
77
|
-
|
|
111
|
+
// A free plan answers only with Auto (2026-10-21): any named model is refused with «Named models
|
|
112
|
+
// unavailable · Free plans can only use Auto». The turn is asked again with Auto, and from then on
|
|
113
|
+
// this room offers Auto alone (models.mjs) — nothing says the plan before a turn does.
|
|
114
|
+
export const ONLY_AUTO = /Free plans can only use Auto|Named models unavailable/i;
|
|
115
|
+
let onlyAuto = false;
|
|
116
|
+
export const cursorOnlyAuto = () => onlyAuto;
|
|
117
|
+
|
|
118
|
+
export async function invokeCursor({ executable, projectRoot, prompt, timeoutMs = 120000, signal, model = null, lease = null, onProgress = null }) {
|
|
78
119
|
const configDir = await mkdtemp(join(tmpdir(), 'madre-cursor-'));
|
|
79
120
|
try {
|
|
80
|
-
await writeFile(join(configDir, 'cli-config.json'), `${JSON.stringify(
|
|
81
|
-
|
|
121
|
+
await writeFile(join(configDir, 'cli-config.json'), `${JSON.stringify(cursorConfigFor(lease), null, 2)}\n`);
|
|
122
|
+
const run = (named) => runReadonlyProcess({
|
|
82
123
|
onProgress: onProgress ? (out) => onProgress({ chars: out.length }) : null,
|
|
83
124
|
executable,
|
|
84
|
-
args: buildCursorArgs({ projectRoot, prompt, ...(
|
|
125
|
+
args: buildCursorArgs({ projectRoot, prompt, lease, ...(named ? { model: named } : {}) }),
|
|
85
126
|
cwd: projectRoot,
|
|
86
127
|
env: cursorEnvironment(process.env, { configDir }),
|
|
87
128
|
timeoutMs,
|
|
@@ -89,6 +130,14 @@ export async function invokeCursor({ executable, projectRoot, prompt, timeoutMs
|
|
|
89
130
|
label: 'Cursor',
|
|
90
131
|
parse: parseCursorOutput,
|
|
91
132
|
});
|
|
133
|
+
const named = onlyAuto ? null : model;
|
|
134
|
+
try {
|
|
135
|
+
return await run(named);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
if (!named || named === 'auto' || !ONLY_AUTO.test(String(error?.message ?? ''))) throw error;
|
|
138
|
+
onlyAuto = true;
|
|
139
|
+
return await run(null);
|
|
140
|
+
}
|
|
92
141
|
} finally {
|
|
93
142
|
// The chats and caches the CLI wrote there go with it: a turn keeps no session of its own.
|
|
94
143
|
await rm(configDir, { recursive: true, force: true, maxRetries: 6, retryDelay: 60 }).catch(() => {});
|
package/src/adapters/gemini.mjs
CHANGED
|
@@ -322,7 +322,9 @@ export async function invokeGemini({
|
|
|
322
322
|
mcpServers = [],
|
|
323
323
|
idleTimeoutMs = Number(process.env.PULSE_GEMINI_IDLE_MS ?? 90000),
|
|
324
324
|
retries = Number(process.env.PULSE_GEMINI_RETRIES ?? 1),
|
|
325
|
-
|
|
325
|
+
// The spare model a 503 or 429 tries once (2026-10-21): 2.5 Flash is no longer given to new
|
|
326
|
+
// accounts, so it failed again and its refusal hid why the chosen model had failed. Empty: no spare.
|
|
327
|
+
fallbackModel = process.env.PULSE_GEMINI_FALLBACK_MODEL ?? 'gemini-3-flash-preview',
|
|
326
328
|
failFastMs = 15000,
|
|
327
329
|
run = runReadonlyProcess,
|
|
328
330
|
}) {
|
|
@@ -334,6 +336,7 @@ export async function invokeGemini({
|
|
|
334
336
|
let attempt = 0;
|
|
335
337
|
let currentModel = model;
|
|
336
338
|
let switched = false;
|
|
339
|
+
let firstTrouble = null;
|
|
337
340
|
for (;;) {
|
|
338
341
|
attempt += 1;
|
|
339
342
|
// The CLI retries a 503 or 429 with backoff for minutes while stderr
|
|
@@ -364,6 +367,13 @@ export async function invokeGemini({
|
|
|
364
367
|
} catch (error) {
|
|
365
368
|
const produced = parseGeminiOutput(error.partialOutput ?? '').text;
|
|
366
369
|
const diagnosis = error.diagnosis ?? diagnoseGeminiStderr(error.partialStderr ?? error.stderr ?? '');
|
|
370
|
+
// The spare failed too, for whatever reason (a model this account is not given, say): what
|
|
371
|
+
// the person needs to read is why the model they chose failed, not why the spare did.
|
|
372
|
+
if (switched && firstTrouble && !produced && !signal?.aborted) {
|
|
373
|
+
error.message = `${firstTrouble.message} ${firstTrouble.hint} (also tried ${fallbackModel})`;
|
|
374
|
+
error.code = firstTrouble.code;
|
|
375
|
+
throw error;
|
|
376
|
+
}
|
|
367
377
|
if (diagnosis?.code === 'AUTH' || diagnosis?.code === 'INELIGIBLE' || diagnosis?.code === 'CREDITS_DEPLETED') {
|
|
368
378
|
error.message = `${diagnosis.message} ${diagnosis.hint}`;
|
|
369
379
|
error.code = diagnosis.code;
|
|
@@ -373,6 +383,7 @@ export async function invokeGemini({
|
|
|
373
383
|
// try on a lighter, explicit model before giving up.
|
|
374
384
|
if ((diagnosis?.code === 'UNAVAILABLE' || diagnosis?.code === 'RATE_LIMITED') && !produced && !signal?.aborted && fallbackModel && !switched && currentModel !== fallbackModel) {
|
|
375
385
|
switched = true;
|
|
386
|
+
firstTrouble = diagnosis;
|
|
376
387
|
currentModel = fallbackModel;
|
|
377
388
|
continue;
|
|
378
389
|
}
|
package/src/adapters/madre.mjs
CHANGED
|
@@ -249,23 +249,38 @@ const COMPARE = `You compare the answers a round of agents gave to one question.
|
|
|
249
249
|
|
|
250
250
|
const NO_USAGE = { inputTokens: 0, outputTokens: 0, cachedInputTokens: 0, reasoningTokens: 0, totalTokens: 0, costUsd: 0, source: 'madre', local: true };
|
|
251
251
|
|
|
252
|
-
// What the whole archive says about this request: notes first, then exact quotes.
|
|
252
|
+
// What the whole archive says about this request: notes first, then exact quotes. The question
|
|
253
|
+
// itself is already in the ledger when @madre is asked, and it is not a memory: found as the only
|
|
254
|
+
// «quote», a 7B model took it for a source and cited it under a made-up answer (2026-10-19).
|
|
255
|
+
const sameWords = (a, b) => String(a ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).toLowerCase() === String(b ?? '').replace(/\s+/g, ' ').trim().slice(0, 200).toLowerCase();
|
|
253
256
|
export async function gather(memory, text, { maxChars = 7000 } = {}) {
|
|
254
257
|
if (!memory) return { notes: [], quotes: [], text: '' };
|
|
255
258
|
const queryVector = await memory.embedQuery(text);
|
|
256
259
|
const notes = memory.recallMemories(text, { limit: 12, maxChars: Math.floor(maxChars * 0.35), queryVector, fallback: false });
|
|
257
260
|
const spent = notes.reduce((sum, note) => sum + note.text.length + 24, 0);
|
|
258
261
|
const recall = memory.recall(text, { limit: 12, maxChars: maxChars - spent, excerptChars: 420, queryVector });
|
|
262
|
+
const quotes = recall.entries.filter((entry) => !sameWords(entry.excerpt, text));
|
|
259
263
|
const lines = [
|
|
260
264
|
...notes.map((note) => `- [note · ${note.kind} · #${note.fromSequence}–#${note.throughSequence}] ${note.text}`),
|
|
261
|
-
...
|
|
265
|
+
...quotes.map((entry) => `[#${entry.sequence} · ${(entry.timestamp ?? '').slice(0, 16).replace('T', ' ')} · ${entry.role === 'command' ? entry.sender : `@${entry.sender}`}] ${entry.excerpt}`),
|
|
262
266
|
];
|
|
263
|
-
return { notes, quotes
|
|
267
|
+
return { notes, quotes, text: lines.join('\n') };
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// Nothing remembered and nothing said before: there is nothing to cite, so the model is not asked.
|
|
271
|
+
// Rule 3 told it to say so and stop; qwen2.5:7b described a store with a cart, payments, src/app.js
|
|
272
|
+
// and index.html in a project of two files (2026-10-19). The agents that can read the code are named.
|
|
273
|
+
export function nothingYet(text, { crew = [] } = {}) {
|
|
274
|
+
const others = crew.filter((id) => id !== MADRE_AGENT_ID).map((id) => `@${id}`);
|
|
275
|
+
return lang(text) === 'es'
|
|
276
|
+
? `Todavía no hay nada sobre esto en la memoria de este proyecto: la sala nunca lo discutió. Yo respondo solo con lo que la sala recuerda y no leo el código${others.length ? `; para eso pregúntale a ${others.join(', ')}` : ''}.`
|
|
277
|
+
: `There is nothing about this in this project's memory yet: the room never discussed it. I answer only from what the room remembers and I do not read the code${others.length ? `; for that, ask ${others.join(', ')}` : ''}.`;
|
|
264
278
|
}
|
|
265
279
|
|
|
266
280
|
// The invoker the room calls like any adapter. `text` is the human's request; `prompt` the room's full briefing.
|
|
267
281
|
export function madreInvoker({ memory, ollama, fetchImpl = globalThis.fetch }) {
|
|
268
|
-
|
|
282
|
+
// `signal` is the room's STOP (2026-10-20): it reaches Ollama, so a stopped @madre does not answer after all.
|
|
283
|
+
return async ({ prompt, text = '', timeoutMs = 180000, model = null, requester = 'you', crew = [], delegation = false, maxSteps = 4, round = null, bishop = null, signal = null }) => {
|
|
269
284
|
const state = typeof ollama === 'function' ? ollama() : ollama;
|
|
270
285
|
if (!state?.running || !state.chatModel) throw new Error('@madre left the project: Ollama is not running. Start Ollama, or open Local AI in Modules.');
|
|
271
286
|
const question = text || prompt.match(/User message: ([\s\S]*)$/)?.[1] || prompt.slice(-2000);
|
|
@@ -281,15 +296,21 @@ export function madreInvoker({ memory, ollama, fetchImpl = globalThis.fetch }) {
|
|
|
281
296
|
let comparison = '';
|
|
282
297
|
if (round.answers.filter((answer) => answer.sequence).length >= 2) {
|
|
283
298
|
const full = round.answers.filter((answer) => answer.sequence).map((answer) => `@${answer.agent} [#${answer.sequence}]: ${gist(answer.text, 700)}`).join('\n\n');
|
|
284
|
-
const compared = await ollamaGenerate({ host: state.host, model: model ?? state.chatModel, system: COMPARE, prompt: `${asked ? `QUESTION: ${asked}\n\n` : ''}ANSWERS:\n${full}\n\n${es ? 'Responde en español.' : 'Answer in English.'}`, fetchImpl, timeoutMs, temperature: 0.1 }).catch(() => null);
|
|
299
|
+
const compared = await ollamaGenerate({ host: state.host, model: model ?? state.chatModel, system: COMPARE, prompt: `${asked ? `QUESTION: ${asked}\n\n` : ''}ANSWERS:\n${full}\n\n${es ? 'Responde en español.' : 'Answer in English.'}`, fetchImpl, timeoutMs, temperature: 0.1, signal }).catch(() => null);
|
|
300
|
+
signal?.throwIfAborted();
|
|
285
301
|
if (compared) usage = { ...compared.usage, local: true };
|
|
286
302
|
if (compared && comparisonHolds(compared.text, round)) comparison = plain(compared.text);
|
|
287
303
|
}
|
|
288
304
|
return { text: [head, bullets, comparison].filter(Boolean).join('\n\n'), usage, grounded: { notes: 0, quotes: round.answers.filter((answer) => answer.sequence).length } };
|
|
289
305
|
}
|
|
290
306
|
const archive = await gather(memory, question);
|
|
307
|
+
// A dictated form (yes or no, one word) is still the model's: a paragraph would break it.
|
|
308
|
+
if (!archive.notes.length && !archive.quotes.length && !bishop && !FORM.test(question) && !/<context>\n[\s\S]*?\S[\s\S]*?\n<\/context>/.test(prompt)) {
|
|
309
|
+
return { text: nothingYet(question, { crew }), usage: { ...NO_USAGE }, grounded: { notes: 0, quotes: 0 }, synthetic: 'nothing-yet' };
|
|
310
|
+
}
|
|
291
311
|
const briefing = briefingFor({ prompt, text: question, archive: archive.text, bishop });
|
|
292
|
-
|
|
312
|
+
signal?.throwIfAborted();
|
|
313
|
+
const answer = await ollamaGenerate({ host: state.host, model: model ?? state.chatModel, system: bishop ? BISHOP_SYSTEM : SYSTEM, prompt: briefing, fetchImpl, timeoutMs, temperature: 0.1, signal });
|
|
293
314
|
return { text: answer.text, usage: { ...answer.usage, local: true }, grounded: { notes: archive.notes.length, quotes: archive.quotes.length } };
|
|
294
315
|
};
|
|
295
316
|
}
|
package/src/adapters/process.mjs
CHANGED
|
@@ -149,7 +149,10 @@ export function runReadonlyProcess({
|
|
|
149
149
|
const armIdle = () => {
|
|
150
150
|
if (!idleTimeoutMs) return;
|
|
151
151
|
clearTimeout(idleTimer);
|
|
152
|
-
|
|
152
|
+
// The verdict waits one turn of the loop, after the pipes are read: a timer that fires late,
|
|
153
|
+
// because the loop was busy, used to judge before the lines already waiting in the pipe were
|
|
154
|
+
// heard, and stopped a process that had been talking all along (2026-10-21).
|
|
155
|
+
idleTimer = setTimeout(() => setImmediate(() => {
|
|
153
156
|
if (settled) return;
|
|
154
157
|
if (Date.now() - lastActivity < idleTimeoutMs) { armIdle(); return; }
|
|
155
158
|
terminateProcessTree(child, { graceMs: killGraceMs });
|
|
@@ -159,7 +162,7 @@ export function runReadonlyProcess({
|
|
|
159
162
|
error.partialOutput = stdout;
|
|
160
163
|
error.partialStderr = stderr.slice(-2000);
|
|
161
164
|
finish(() => reject(error));
|
|
162
|
-
}, idleTimeoutMs);
|
|
165
|
+
}), idleTimeoutMs);
|
|
163
166
|
idleTimer.unref?.();
|
|
164
167
|
};
|
|
165
168
|
|
package/src/auth-probe.mjs
CHANGED
|
@@ -45,6 +45,13 @@ export function parseOpenCodeAuthList({ stdout = '' }) {
|
|
|
45
45
|
return { state: 'signed-out', detail: 'no providers configured', providers: [] };
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// `opencode models opencode`: the models OpenCode serves itself, one `opencode/<model>` per line.
|
|
49
|
+
export function openCodeOwnModels({ stdout = '', code = 0 }) {
|
|
50
|
+
const models = stripAnsi(stdout).split('\n').map((line) => line.trim()).filter((line) => /^opencode\/[\w.:-]+$/.test(line));
|
|
51
|
+
if (code !== 0 || !models.length) return null;
|
|
52
|
+
return { state: 'signed-in', detail: `OpenCode's own free models, no account (${models.length})`, providers: [], own: models.length };
|
|
53
|
+
}
|
|
54
|
+
|
|
48
55
|
// `cursor-agent status` says «Not logged in», or who is signed in («Logged in as …»). A key in the
|
|
49
56
|
// environment (CURSOR_API_KEY) signs every run in on its own, so it counts too.
|
|
50
57
|
export function parseCursorStatus({ stdout = '', stderr = '' }, env = process.env) {
|
|
@@ -206,7 +213,7 @@ export const AGENT_SETUP = {
|
|
|
206
213
|
browser: true,
|
|
207
214
|
terminal: 'cursor-agent login',
|
|
208
215
|
vendor: 'Cursor',
|
|
209
|
-
account: 'Signs in with your Cursor account and uses its plan.
|
|
216
|
+
account: 'Signs in with your Cursor account and uses its plan. A free plan answers only with Auto, and only while it has use left.',
|
|
210
217
|
paid: true,
|
|
211
218
|
},
|
|
212
219
|
};
|
|
@@ -249,7 +256,12 @@ export const looksLikeAdminProblem = (output) => NEEDS_ADMIN.test(String(output
|
|
|
249
256
|
|
|
250
257
|
export function installPlanFor(agent, { prefix = null } = {}) {
|
|
251
258
|
const name = AGENT_PACKAGE[agent?.id];
|
|
252
|
-
|
|
259
|
+
// An agent with no npm package (Cursor) installs with its own installer, a script from its site:
|
|
260
|
+
// MADRE does not fetch and run that on its own; it says the command, to copy into a terminal.
|
|
261
|
+
if (!name) {
|
|
262
|
+
const own = AGENT_SETUP[agent?.id]?.install ?? [];
|
|
263
|
+
return own.length ? { package: null, command: null, args: [], display: own[0], fallback: null, alternatives: own.slice(1), terminal: true } : null;
|
|
264
|
+
}
|
|
253
265
|
return {
|
|
254
266
|
package: name,
|
|
255
267
|
command: 'npm',
|
|
@@ -346,7 +358,14 @@ export async function probeAgentAuth(agent) {
|
|
|
346
358
|
switch (agent.id) {
|
|
347
359
|
case 'codex': return parseCodexLoginStatus(await run(agent.path, ['login', 'status']));
|
|
348
360
|
case 'claude': return parseClaudeAuthStatus(await run(agent.path, ['auth', 'status', '--json']));
|
|
349
|
-
case 'opencode':
|
|
361
|
+
case 'opencode': {
|
|
362
|
+
const listed = parseOpenCodeAuthList(await run(agent.path, ['auth', 'list']));
|
|
363
|
+
if (listed.state === 'signed-in') return listed;
|
|
364
|
+
// No provider of its own, and still it answers: OpenCode brings free models that need no account
|
|
365
|
+
// (opencode/big-pickle by default). Called signed out, the one agent a newcomer could use
|
|
366
|
+
// without signing in anywhere was the one MADRE would not let them write to (2026-10-19).
|
|
367
|
+
return openCodeOwnModels(await run(agent.path, ['models', 'opencode'], 15000)) ?? listed;
|
|
368
|
+
}
|
|
350
369
|
case 'cursor': return parseCursorStatus(await run(agent.path, ['status']));
|
|
351
370
|
case 'gemini': return probeGemini();
|
|
352
371
|
default: return { state: 'unknown', detail: 'no probe for this agent' };
|
package/src/bridge/policy.mjs
CHANGED
|
@@ -17,7 +17,7 @@ import { t } from '../i18n.mjs';
|
|
|
17
17
|
|
|
18
18
|
// Every file the room's page loads: one missing here and app.js cannot import it, so the whole page
|
|
19
19
|
// stops on the phone (test/phone-bridge.test.mjs reads app.js's imports to keep this whole).
|
|
20
|
-
const STATIC = new Set(['/', '/app.js', '/nostromo-engine.js', '/brands.js', '/troubleshooting.js', '/inquiry.js', '/i18n.js', '/es.js', '/resay.js', '/syntax.js', '/editor.js', '/routing.js', '/abduction.js', '/styles.css', '/review-ask.js', '/loader.js', '/tour.js', '/tour-chapters.js', '/touch.js', '/attribution.js', '/power.js', '/wallpaper.js', '/neural.js', '/hardware.js', '/code-tools.js', '/market.js', '/market-view.js', '/market-art.js']);
|
|
20
|
+
const STATIC = new Set(['/', '/app.js', '/nostromo-engine.js', '/brands.js', '/troubleshooting.js', '/inquiry.js', '/i18n.js', '/es.js', '/en.js', '/resay.js', '/syntax.js', '/editor.js', '/routing.js', '/abduction.js', '/styles.css', '/review-ask.js', '/loader.js', '/tour.js', '/tour-chapters.js', '/touch.js', '/attribution.js', '/power.js', '/wallpaper.js', '/neural.js', '/hardware.js', '/code-tools.js', '/market.js', '/market-view.js', '/market-art.js', '/mcp-catalog.js']);
|
|
21
21
|
|
|
22
22
|
const READ = new Set([
|
|
23
23
|
'/api/state', '/api/events', '/api/chats', '/api/version', '/api/whats-new', '/api/glance', '/api/handoff',
|
package/src/bridge/server.mjs
CHANGED
|
@@ -31,7 +31,7 @@ const MESSAGE_LIMIT = 1024 * 1024;
|
|
|
31
31
|
|
|
32
32
|
const MIME = { '.html': 'text/html; charset=utf-8', '.js': 'text/javascript; charset=utf-8', '.css': 'text/css; charset=utf-8', '.svg': 'image/svg+xml', '.webp': 'image/webp', '.png': 'image/png', '.woff2': 'font/woff2', '.txt': 'text/plain; charset=utf-8', '.webmanifest': 'application/manifest+json' };
|
|
33
33
|
// The bridge's own files, served from the package of the room that hosts it.
|
|
34
|
-
const OWN = { '/salas': 'salas.html', '/bridge/salas.js': 'salas.js', '/bridge/salas.css': 'salas.css', '/bridge/styles.css': 'styles.css', '/bridge/i18n.js': 'i18n.js', '/bridge/es.js': 'es.js', '/bridge/touch.js': 'touch.js', '/bridge/manifest.webmanifest': 'manifest.webmanifest' };
|
|
34
|
+
const OWN = { '/salas': 'salas.html', '/bridge/salas.js': 'salas.js', '/bridge/salas.css': 'salas.css', '/bridge/styles.css': 'styles.css', '/bridge/i18n.js': 'i18n.js', '/bridge/es.js': 'es.js', '/bridge/en.js': 'en.js', '/bridge/touch.js': 'touch.js', '/bridge/manifest.webmanifest': 'manifest.webmanifest' };
|
|
35
35
|
const HOP = new Set(['connection', 'keep-alive', 'proxy-authenticate', 'proxy-authorization', 'te', 'trailer', 'transfer-encoding', 'upgrade', 'host', 'cookie', 'origin', 'referer']);
|
|
36
36
|
|
|
37
37
|
const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (error) { return error.code === 'EPERM'; } };
|
package/src/capabilities.mjs
CHANGED
|
@@ -35,12 +35,12 @@ export const CAPABILITIES = {
|
|
|
35
35
|
imageGen: false,
|
|
36
36
|
web: { how: 'policy: allow google_web_search, web_fetch', note: 'Off until turned on in Settings › Agents › Web access.' },
|
|
37
37
|
},
|
|
38
|
-
// Cursor
|
|
39
|
-
//
|
|
38
|
+
// Cursor reads in its own ask mode and, from 2026-10-21, writes and runs commands at the modes
|
|
39
|
+
// that allow it (adapters/cursor.mjs). Attachments are named in the briefing.
|
|
40
40
|
cursor: {
|
|
41
41
|
read: true,
|
|
42
42
|
imageIn: false,
|
|
43
|
-
write:
|
|
43
|
+
write: { how: 'agent mode with --force under a configuration made for the turn', note: 'Writes where the turn allows; commands only at #4. MADRE locks and puts back .env, .git and its own folders, and at #2 what existed.' },
|
|
44
44
|
imageGen: false,
|
|
45
45
|
web: false,
|
|
46
46
|
},
|
package/src/credentials.mjs
CHANGED
|
@@ -54,10 +54,32 @@ export async function readOpenCodeCatalog({ home = homedir(), env = process.env
|
|
|
54
54
|
}
|
|
55
55
|
return out;
|
|
56
56
|
}
|
|
57
|
+
// OpenCode writes its catalogue the first time it runs. A person who has just installed it has none
|
|
58
|
+
// yet, and was offered only MADRE's four (2026-10-20): until the catalogue is there, the popular
|
|
59
|
+
// ones a single key opens are offered from this copy of it (models.dev, 2026-10-20), each with the
|
|
60
|
+
// page of its own documentation the catalogue gives.
|
|
61
|
+
export const OPENCODE_BUNDLED = [
|
|
62
|
+
{ id: 'groq', label: 'Groq', docUrl: 'https://console.groq.com/docs/models' },
|
|
63
|
+
{ id: 'deepseek', label: 'DeepSeek', docUrl: 'https://api-docs.deepseek.com/quick_start/pricing' },
|
|
64
|
+
{ id: 'mistral', label: 'Mistral', docUrl: 'https://docs.mistral.ai/getting-started/models/' },
|
|
65
|
+
{ id: 'xai', label: 'xAI', docUrl: 'https://docs.x.ai/docs/models' },
|
|
66
|
+
{ id: 'togetherai', label: 'Together AI', docUrl: 'https://docs.together.ai/docs/serverless-models' },
|
|
67
|
+
{ id: 'fireworks-ai', label: 'Fireworks AI', docUrl: 'https://fireworks.ai/docs/' },
|
|
68
|
+
{ id: 'cerebras', label: 'Cerebras', docUrl: 'https://inference-docs.cerebras.ai/models/overview' },
|
|
69
|
+
{ id: 'perplexity', label: 'Perplexity', docUrl: 'https://docs.perplexity.ai' },
|
|
70
|
+
{ id: 'huggingface', label: 'Hugging Face', docUrl: 'https://huggingface.co/docs/inference-providers' },
|
|
71
|
+
{ id: 'deepinfra', label: 'Deep Infra', docUrl: 'https://deepinfra.com/models' },
|
|
72
|
+
{ id: 'moonshotai', label: 'Moonshot AI', docUrl: 'https://platform.moonshot.ai/docs/api/chat' },
|
|
73
|
+
{ id: 'zai', label: 'Z.AI', docUrl: 'https://docs.z.ai/guides/overview/pricing' },
|
|
74
|
+
{ id: 'cohere', label: 'Cohere', docUrl: 'https://docs.cohere.com/docs/models' },
|
|
75
|
+
{ id: 'vercel', label: 'Vercel AI Gateway', docUrl: null },
|
|
76
|
+
];
|
|
57
77
|
// Every provider a key can be pasted for: MADRE's own four first (their key pages), then the
|
|
58
|
-
// catalogue's, each once, the popular ones
|
|
78
|
+
// catalogue's — or, before OpenCode has written one, the copy above — each once, the popular ones
|
|
79
|
+
// marked.
|
|
59
80
|
export async function openCodeKeyProviders({ home = homedir(), env = process.env } = {}) {
|
|
60
|
-
const
|
|
81
|
+
const read = await readOpenCodeCatalog({ home, env });
|
|
82
|
+
const catalog = read.length ? read : OPENCODE_BUNDLED;
|
|
61
83
|
const byId = new Map(OPENCODE_PROVIDERS.map((one) => [one.id, { ...one, featured: true }]));
|
|
62
84
|
for (const one of catalog) if (!byId.has(one.id)) byId.set(one.id, { id: one.id, label: one.label, keyUrl: one.docUrl, featured: OPENCODE_FEATURED.includes(one.id) });
|
|
63
85
|
const rank = (one) => { const at = OPENCODE_FEATURED.indexOf(one.id); return at < 0 ? Infinity : at; };
|