ceulen 0.30.0 → 0.32.0
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.md +86 -2
- package/extensions/modules/config/index.ts +37 -5
- package/extensions/modules/config/piSettings.ts +15 -6
- package/extensions/modules/config/test/panel.test.ts +63 -0
- package/extensions/modules/config/test/piSettings.test.ts +25 -0
- package/extensions/modules/munin/index.ts +32 -6
- package/extensions/modules/munin/lib/helpers.ts +10 -0
- package/extensions/modules/munin/lib/sdk/capabilities.ts +42 -0
- package/extensions/modules/munin/lib/sdk/client.ts +370 -0
- package/extensions/modules/munin/lib/sdk/errors.ts +70 -0
- package/extensions/modules/munin/lib/sdk/index.ts +38 -0
- package/extensions/modules/munin/lib/sdk/maintenance.ts +97 -0
- package/extensions/modules/munin/lib/sdk/node/fileWriteQueue.ts +296 -0
- package/extensions/modules/munin/lib/sdk/types.ts +74 -0
- package/extensions/modules/munin/lib/sdk/writeQueue.ts +220 -0
- package/extensions/modules/munin/test/extension.test.ts +19 -1
- package/extensions/modules/munin/test/helpers.test.ts +9 -0
- package/extensions/modules/munin/test/sdk.test.ts +206 -0
- package/extensions/modules/munin/test/stale-protocol.test.ts +45 -1
- package/extensions/modules/steering/lib/guidance.ts +13 -3
- package/extensions/modules/steering/test/guidance.test.ts +7 -1
- package/extensions/modules/steering/test/think.test.ts +1 -1
- package/package.json +3 -3
- package/extensions/modules/munin/lib/sdk.ts +0 -218
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
+
## 0.32.0 — 2026-11-26
|
|
2
|
+
|
|
3
|
+
**Pi 1.6.1 compatibility + the Munin server write gate.** Everything here was
|
|
4
|
+
found by running against the real packages, not by reading them.
|
|
5
|
+
|
|
6
|
+
- **Peer range** `>=0.99.1 <1.6.0` → `>=0.99.1 <1.7.0` for
|
|
7
|
+
`@earendil-works/pi-coding-agent` and `@earendil-works/pi-tui`; the lockfile
|
|
8
|
+
now resolves both to 1.6.1 (peer auto-installs, not devDependencies).
|
|
9
|
+
- **One broken pi-settings row, one broken test cast.** pi 1.6.1 deleted
|
|
10
|
+
`getShowCacheMissNotices`/`setShowCacheMissNotices` in favour of four
|
|
11
|
+
independent notice toggles, so `/config` carried a row whose getter no longer
|
|
12
|
+
existed; and pi-tui's `render()` now returns `readonly string[]`, which broke
|
|
13
|
+
one `as` cast in `steering/test/think.test.ts` (runtime unchanged).
|
|
14
|
+
- **`/config` now renders the four notice toggles** — `pi.notices.cacheMisses`,
|
|
15
|
+
`.cacheWarming`, `.compactionCosts`, `.reasoningDrops` on Model → Efficiency,
|
|
16
|
+
labels/descriptions taken verbatim from stock, each writing ONLY its own key
|
|
17
|
+
through `setNotice(key, …)`.
|
|
18
|
+
- **`/config` no longer dies with one broken section.** The build path is
|
|
19
|
+
isolated per section (`safe(name, build)` in `assemble()`): a contribution
|
|
20
|
+
whose `groups()` throws loses only its own rows and is disclosed in a trailing
|
|
21
|
+
**Failed sections** tab, while the rest of the panel — pi settings, plugins,
|
|
22
|
+
healthy modules — still renders. `rebuildOnCommit` inherits it. A contribution
|
|
23
|
+
FACTORY that throws is guarded separately where the factories are built (it
|
|
24
|
+
runs outside `assemble()`, so the per-section wrap alone would not catch it)
|
|
25
|
+
and its message is seeded into the same **Failed sections** tab. The save path
|
|
26
|
+
already isolated per module.
|
|
27
|
+
- **Munin SDK re-vendored 1.5.0 → 1.6.0 at `extensions/modules/munin/lib/sdk/`**
|
|
28
|
+
(upstream dist/*.js + *.d.ts translated one file per JS/d.ts pair, zero deps),
|
|
29
|
+
with five marked local deltas: a cache keyed `${baseUrl}|${apiKey}` (upstream
|
|
30
|
+
cached ONE un-keyed global, so switching servers read the wrong server's
|
|
31
|
+
capabilities), a `timeoutMs` on `fetchCapabilities` (upstream still has none),
|
|
32
|
+
an exported `CLIENT_VERSION`, a new pre-write version gate, and the
|
|
33
|
+
`ERR_CLIENT_OUTDATED`/`clients` type additions.
|
|
34
|
+
- **The server gates writes on the envelope client version** — measured:
|
|
35
|
+
`/api/mcp/capabilities` advertises `clients["@kalera/munin-sdk"].minimum =
|
|
36
|
+
1.6.0`, and a write whose envelope says `1.5.0` is rejected with
|
|
37
|
+
`ERR_CLIENT_OUTDATED` ("This write was NOT saved") no matter how correct the
|
|
38
|
+
rest of the request is. Reads are NOT gated, which is why only storing failed.
|
|
39
|
+
The vendored constant is now `CLIENT_VERSION = "1.6.0"`, and `test/sdk.test.ts`
|
|
40
|
+
parses the vendor header in `lib/sdk/index.ts` so the two can never drift
|
|
41
|
+
again.
|
|
42
|
+
- **`ERR_CLIENT_OUTDATED` gets its own error path**: `callMunin` replaces the
|
|
43
|
+
server's "install the npm package / update the Claude Code plugin" advice with
|
|
44
|
+
"ceulen vendors the SDK — upgrade ceulen", preserving `cause` and `code`, and
|
|
45
|
+
never routing it through `remediatedError` (a vendored SDK cannot be fixed by
|
|
46
|
+
npm). The SDK also refuses such a write BEFORE the POST when capabilities
|
|
47
|
+
advertise a higher minimum (missing/malformed minimum fails open — the server
|
|
48
|
+
stays authoritative). The gate is keyed on `isWriteAction`, not on
|
|
49
|
+
`ensureCapability`, so `delete` — a real write that skips the capability
|
|
50
|
+
check — is gated too. `munin_capabilities` prints each client's minimum/latest
|
|
51
|
+
so the gate is observable.
|
|
52
|
+
- **`writeQueue: false` is documented as a ceiling**, not an accident: a write
|
|
53
|
+
during a maintenance window fails loudly instead of being saved to `~/.munin`
|
|
54
|
+
and replayed. `maintenance.ts`/`writeQueue.ts`/`node/fileWriteQueue.ts` are
|
|
55
|
+
vendored so flipping that one boolean turns the queue on.
|
|
56
|
+
- `classifyError` now names `client_outdated` and `maintenance` (so `withRetry`
|
|
57
|
+
never retries a maintenance window, and the `tool_result` sanitizer — which
|
|
58
|
+
re-classifies from TEXT alone — names the failure class instead of
|
|
59
|
+
"Munin unknown error").
|
|
60
|
+
|
|
61
|
+
## 0.31.0 — 2026-11-23
|
|
62
|
+
|
|
63
|
+
DeepSeek V4 tool-selection guidance stops overriding a prerequisite read, and
|
|
64
|
+
the `bash`-first hint stops mis-firing on "after" clauses.
|
|
65
|
+
|
|
66
|
+
- **Selection guidance** (`steering.selectionGuidance`, DeepSeek V4 only) no
|
|
67
|
+
longer pushes one `codemode` script for every batch. It now says "use a
|
|
68
|
+
direct call for one simple step; batch independent calls in one round
|
|
69
|
+
(parallel direct calls, **or** codemode with `Promise.allSettled` to filter
|
|
70
|
+
or compute in place)". Live Herdr run on `router/combo/deepseek-v4.1-flash`:
|
|
71
|
+
the four-file sum task dropped from 2 tool rounds to 1 (four parallel
|
|
72
|
+
`read` calls, then one `bash`), which the previous codemode-first wording
|
|
73
|
+
never produced.
|
|
74
|
+
- **`runTaskFirstToolHint`** used to fire on any execution verb anywhere in the
|
|
75
|
+
prompt, so "Read `fixtures/runbook.txt`, then run its command" got a
|
|
76
|
+
"FIRST tool call MUST be bash … Do NOT call read first" hint that directly
|
|
77
|
+
contradicted the read the task requires (live-observed: Flash read the file,
|
|
78
|
+
then re-read it because the reminder demanded compliance). Suppressed when a
|
|
79
|
+
read/open/review/check precedes the first execution verb, and when an
|
|
80
|
+
`after you read` / `after reading` clause makes the read a prerequisite.
|
|
81
|
+
- **Scoped to the first execution clause**: "Run the tests, then deploy after
|
|
82
|
+
reviewing the results" keeps the `bash`-first hint — the review gates the
|
|
83
|
+
deploy, not the tests. An earlier revision scanned the whole suffix and
|
|
84
|
+
silently dropped the hint there.
|
|
85
|
+
|
|
1
86
|
## 0.30.0 — 2026-11-22
|
|
2
87
|
|
|
3
88
|
Three DeepSeek Harness enrichments in the **repair** module — all-model, all
|
|
@@ -204,7 +289,6 @@ then `serena_find_referencing_symbols`. Bridge actions 10/10 pass end-to-end
|
|
|
204
289
|
through the real `SerenaWorkerClient`; `tsc --noEmit` clean; `npm test`
|
|
205
290
|
**3020 pass / 0 fail / 3 env-gated skips**.
|
|
206
291
|
|
|
207
|
-
|
|
208
292
|
## 0.28.0 — 2026-11-18
|
|
209
293
|
|
|
210
294
|
**Rex is now a first-class subagent delegation backend.** ceulen's visible-pane
|
|
@@ -1627,4 +1711,4 @@ Wave 1: first two production modules merged into the bundle.
|
|
|
1627
1711
|
|
|
1628
1712
|
## 0.1.0 — 2026-09-21
|
|
1629
1713
|
|
|
1630
|
-
Name reservation + bundle scaffold.
|
|
1714
|
+
Name reservation + bundle scaffold.
|
|
@@ -136,6 +136,20 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
136
136
|
// so a save that re-registers a provider stays the owner's claim.
|
|
137
137
|
const factories = deps?.configContribs ?? new Map<string, () => ModuleConfig>();
|
|
138
138
|
|
|
139
|
+
// A contribution FACTORY that throws runs OUTSIDE `assemble()`, so it needs
|
|
140
|
+
// its own guard — otherwise one broken module's factory still costs the
|
|
141
|
+
// whole panel. Failures are collected once per /config open and seeded into
|
|
142
|
+
// assemble()'s `failed` list, so the "Failed sections" tab discloses them and
|
|
143
|
+
// assemble() stays rebuildable (rebuildOnCommit).
|
|
144
|
+
const factoryFailures: { name: string; message: string }[] = [];
|
|
145
|
+
const contributions: { name: string; cfg: ModuleConfig }[] = [];
|
|
146
|
+
for (const [name, factory] of factories) {
|
|
147
|
+
try {
|
|
148
|
+
contributions.push({ name, cfg: factory() });
|
|
149
|
+
} catch (e) {
|
|
150
|
+
factoryFailures.push({ name, message: e instanceof Error ? e.message : String(e) });
|
|
151
|
+
}
|
|
152
|
+
}
|
|
139
153
|
|
|
140
154
|
pi.registerCommand("config", {
|
|
141
155
|
description: "Central settings panel for all ceulen modules.",
|
|
@@ -157,15 +171,26 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
157
171
|
// The loader skips a module named in the `ceulen.disabled` settings
|
|
158
172
|
// escape hatch, so its factory (and section) never renders here — the
|
|
159
173
|
// settings.json key is the only way back, by design (no UI toggles).
|
|
160
|
-
const contributions = [...factories.entries()].map(([name, factory]) => ({ name, cfg: factory() }));
|
|
161
|
-
|
|
162
174
|
// Assemble in OMP taxonomy order: pi settings first (they own the
|
|
163
175
|
// Appearance/Model/Interaction/Context/Shell spine), then ceulen module
|
|
164
176
|
// sections (functional rows only — no Enable/tool toggles), then plugins.
|
|
165
177
|
const assemble = (): PanelGroup[] => {
|
|
166
|
-
|
|
178
|
+
// One throwing factory (a module reading settings it cannot parse, a
|
|
179
|
+
// pi 1.6.x API the module has not caught up with) must never cost the
|
|
180
|
+
// user the whole panel: each build is isolated, and failures surface
|
|
181
|
+
// as a "Failed sections" tab instead of an exception out of /config.
|
|
182
|
+
const failed: { name: string; message: string }[] = [...factoryFailures];
|
|
183
|
+
const safe = (name: string, build: () => PanelGroup[]): PanelGroup[] => {
|
|
184
|
+
try {
|
|
185
|
+
return build();
|
|
186
|
+
} catch (e) {
|
|
187
|
+
failed.push({ name, message: e instanceof Error ? e.message : String(e) });
|
|
188
|
+
return [];
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const modGroups = contributions.flatMap((c) => safe(c.name, () => c.cfg.groups()));
|
|
167
192
|
// Plugins' package sections precede the config module's own switch.
|
|
168
|
-
const piGroups = buildPiSettingsGroups(piSettings, piMenuLookup(ctx));
|
|
193
|
+
const piGroups = safe("pi settings", () => buildPiSettingsGroups(piSettings, piMenuLookup(ctx)));
|
|
169
194
|
// Built-in tools lead the Tools tab (before the extension-dirs rows).
|
|
170
195
|
const toolsAt = piGroups.findIndex((g) => g.tab === "Tools");
|
|
171
196
|
piGroups.splice(toolsAt === -1 ? piGroups.length : toolsAt, 0, {
|
|
@@ -174,7 +199,14 @@ export default function configModule(pi: ExtensionAPI, deps?: ModuleLoadDeps): v
|
|
|
174
199
|
tab: "Tools",
|
|
175
200
|
rows: builtinToolRows(workingStartup),
|
|
176
201
|
});
|
|
177
|
-
const all = [...piGroups, ...buildPluginsGroups(pluginsWorking), ...modGroups];
|
|
202
|
+
const all = [...piGroups, ...safe("plugins", () => buildPluginsGroups(pluginsWorking)), ...modGroups];
|
|
203
|
+
if (failed.length) {
|
|
204
|
+
all.push({
|
|
205
|
+
key: "config-errors",
|
|
206
|
+
label: "Failed sections",
|
|
207
|
+
rows: failed.map((f) => row(`config-error.${f.name}`, f.name, "info", f.message, () => {})),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
178
210
|
const rank = (g: PanelGroup) => {
|
|
179
211
|
const at = PI_TAB_ORDER.indexOf((g.tab ?? g.label) as (typeof PI_TAB_ORDER)[number]);
|
|
180
212
|
return at === -1 ? PI_TAB_ORDER.length : at;
|
|
@@ -96,6 +96,14 @@ const IMAGE_WIDTH_CHOICES = ["60", "80", "120"] as const;
|
|
|
96
96
|
const withCurrent = (choices: readonly string[], current: string): string[] =>
|
|
97
97
|
current && !choices.includes(current) ? [current, ...choices] : [...choices];
|
|
98
98
|
|
|
99
|
+
/** pi 1.6.1's transcript notice kinds (stock settings-selector.js:33-53 order). */
|
|
100
|
+
const NOTICE_TOGGLES = [
|
|
101
|
+
{ key: "cacheMisses", label: "Cache misses", description: "Show a notice when a response re-bills a significant part of the prompt cache" },
|
|
102
|
+
{ key: "cacheWarming", label: "Cache warming", description: "Show the cost of cache warming requests" },
|
|
103
|
+
{ key: "compactionCosts", label: "Compaction costs", description: "Show the cost of compactions and branch summaries" },
|
|
104
|
+
{ key: "reasoningDrops", label: "Reasoning drops", description: "Show a notice when a provider drops reasoning items from a request" },
|
|
105
|
+
] as const;
|
|
106
|
+
|
|
99
107
|
/** Per-model override clear sentinel (stock's stepped-submenu "(clear
|
|
100
108
|
* override)" — a menu value, removed from the map on commit). */
|
|
101
109
|
const CLEAR_OVERRIDE = "(clear override)";
|
|
@@ -426,12 +434,13 @@ function piRowSpecs(m: SettingsManager, lookup?: PiMenuLookup): PiRowSpec[] {
|
|
|
426
434
|
description: "off: never; streaming: while the agent runs; idle: also between runs while continuation stays profitable.",
|
|
427
435
|
set: (v) => m.setCacheWarmingMode(str(v) as never),
|
|
428
436
|
},
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
437
|
+
// pi 1.6.1 replaced showCacheMissNotices with one toggle per notice kind.
|
|
438
|
+
...NOTICE_TOGGLES.map((notice) => ({
|
|
439
|
+
key: `pi.notices.${notice.key}`, tab: "Model", section: "Efficiency", label: notice.label,
|
|
440
|
+
kind: "toggle" as const, value: m.getNotices()[notice.key], defaultValue: false,
|
|
441
|
+
description: notice.description,
|
|
442
|
+
set: (v: unknown) => m.setNotice(notice.key, Boolean(v)),
|
|
443
|
+
})),
|
|
435
444
|
{
|
|
436
445
|
key: "pi.warnings.anthropicExtraUsage", tab: "Model", section: "Warnings", label: "Anthropic extra usage",
|
|
437
446
|
kind: "toggle", value: Boolean(m.getWarnings().anthropicExtraUsage), defaultValue: false,
|
|
@@ -214,6 +214,69 @@ describe("config module", () => {
|
|
|
214
214
|
assert.ok(text.indexOf("[Appearance]") < text.indexOf("[Model]"), "taxonomy order");
|
|
215
215
|
assert.ok(text.indexOf("[Model]") < text.indexOf("[Interaction]"));
|
|
216
216
|
});
|
|
217
|
+
|
|
218
|
+
it("/config show survives a contribution whose groups() throws (isolated per section)", async () => {
|
|
219
|
+
let handler: ((args: string, ctx: never) => Promise<void>) | undefined;
|
|
220
|
+
const pi = {
|
|
221
|
+
registerCommand: (_name: string, opts: { handler: typeof handler }) => { handler = opts.handler; },
|
|
222
|
+
} as never;
|
|
223
|
+
const factories = new Map<string, () => never>([
|
|
224
|
+
["busted", () => ({ groups: () => { throw new Error("boom"); }, save: async () => {} }) as never],
|
|
225
|
+
[
|
|
226
|
+
"router",
|
|
227
|
+
() => ({
|
|
228
|
+
groups: () => [
|
|
229
|
+
{ key: "router", label: "Router", tab: "Providers", rows: [{ key: "router.baseUrl", label: "Base URL", kind: "string", value: "" }] },
|
|
230
|
+
],
|
|
231
|
+
save: async () => {},
|
|
232
|
+
}) as never,
|
|
233
|
+
],
|
|
234
|
+
]);
|
|
235
|
+
const { default: configModule } = await import("../index.js");
|
|
236
|
+
configModule(pi, { configContribs: factories } as never);
|
|
237
|
+
assert.ok(handler, "handler registered");
|
|
238
|
+
const { notes, ctx } = ctxStub();
|
|
239
|
+
// Must resolve — a throwing section is disclosed, never propagated.
|
|
240
|
+
await (handler as never as (a: string, c: unknown) => Promise<void>)("show", ctx);
|
|
241
|
+
const text = notes.join("\n");
|
|
242
|
+
assert.ok(text.includes("Failed sections"), "failure tab rendered");
|
|
243
|
+
assert.ok(text.includes("busted"), "throwing module named");
|
|
244
|
+
assert.ok(text.includes("boom"), "underlying message shown");
|
|
245
|
+
assert.ok(text.includes("[Appearance]"), "pi settings still present");
|
|
246
|
+
assert.ok(text.includes("[Providers]") && text.includes("Router"), "healthy module still present");
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
it("/config show survives a contribution FACTORY that throws (guarded outside assemble)", async () => {
|
|
250
|
+
let handler: ((args: string, ctx: never) => Promise<void>) | undefined;
|
|
251
|
+
const pi = {
|
|
252
|
+
registerCommand: (_name: string, opts: { handler: typeof handler }) => { handler = opts.handler; },
|
|
253
|
+
} as never;
|
|
254
|
+
const factories = new Map<string, () => never>([
|
|
255
|
+
["exploding", () => { throw new Error("factory boom"); }],
|
|
256
|
+
[
|
|
257
|
+
"router",
|
|
258
|
+
() => ({
|
|
259
|
+
groups: () => [
|
|
260
|
+
{ key: "router", label: "Router", tab: "Providers", rows: [{ key: "router.baseUrl", label: "Base URL", kind: "string", value: "" }] },
|
|
261
|
+
],
|
|
262
|
+
save: async () => {},
|
|
263
|
+
}) as never,
|
|
264
|
+
],
|
|
265
|
+
]);
|
|
266
|
+
const { default: configModule } = await import("../index.js");
|
|
267
|
+
// Registration must not throw either — the factory throws while the
|
|
268
|
+
// contributions are built, and that is inside the guarded loop.
|
|
269
|
+
configModule(pi, { configContribs: factories } as never);
|
|
270
|
+
assert.ok(handler, "handler registered");
|
|
271
|
+
const { notes, ctx } = ctxStub();
|
|
272
|
+
await (handler as never as (a: string, c: unknown) => Promise<void>)("show", ctx);
|
|
273
|
+
const text = notes.join("\n");
|
|
274
|
+
assert.ok(text.includes("Failed sections"), "factory failure lands in the failure tab");
|
|
275
|
+
assert.ok(text.includes("exploding"), "throwing factory's module named");
|
|
276
|
+
assert.ok(text.includes("factory boom"), "underlying factory message shown");
|
|
277
|
+
assert.ok(text.includes("[Appearance]"), "pi settings still present");
|
|
278
|
+
assert.ok(text.includes("[Providers]") && text.includes("Router"), "healthy module still present");
|
|
279
|
+
});
|
|
217
280
|
});
|
|
218
281
|
|
|
219
282
|
// ── router contribution ─────────────────────────────────────────────────────
|
|
@@ -34,6 +34,31 @@ describe("pi settings contribution", () => {
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
it("pi 1.6.1 notice kinds are four independent toggle rows", () => {
|
|
38
|
+
const m = SettingsManager.inMemory();
|
|
39
|
+
const keys = ["cacheMisses", "cacheWarming", "compactionCosts", "reasoningDrops"] as const;
|
|
40
|
+
for (const key of keys) {
|
|
41
|
+
const row = rowAt(m, `pi.notices.${key}`);
|
|
42
|
+
assert.ok(row, `row present: pi.notices.${key}`);
|
|
43
|
+
assert.equal(row.kind, "toggle");
|
|
44
|
+
assert.equal(row.value, false);
|
|
45
|
+
assert.equal(row.defaultValue, false);
|
|
46
|
+
assert.ok(row.description && row.description.length > 0, "stock description present");
|
|
47
|
+
}
|
|
48
|
+
// setNotice writes only that key — the other three keep following defaults.
|
|
49
|
+
rowAt(m, "pi.notices.cacheMisses").set(true);
|
|
50
|
+
assert.deepEqual(m.getNotices(), {
|
|
51
|
+
cacheMisses: true,
|
|
52
|
+
cacheWarming: false,
|
|
53
|
+
compactionCosts: false,
|
|
54
|
+
reasoningDrops: false,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("the removed pi.showCacheMissNotices row is gone (pi 1.6.1 deleted the setter)", () => {
|
|
59
|
+
assert.ok(!rowsOf(SettingsManager.inMemory()).some((r) => r.key === "pi.showCacheMissNotices"));
|
|
60
|
+
});
|
|
61
|
+
|
|
37
62
|
it("builds OMP-taxonomy tabs with unique keys and sections", () => {
|
|
38
63
|
const groups = buildPiSettingsGroups(SettingsManager.inMemory());
|
|
39
64
|
const keys = groups.flatMap((g) => g.rows.map((r) => r.key));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// munin module — Munin long-term memory tools for Pi.
|
|
2
2
|
//
|
|
3
3
|
// Ported from @bacnh85/pi-munin 0.5.12 extensions/index.ts (SDK vendored to
|
|
4
|
-
// lib/sdk
|
|
4
|
+
// lib/sdk/; dotenv dropped — ceulen's bundle env.ts ingests trusted .env).
|
|
5
5
|
// Registers the 8 munin_* tools (search/get/store direct; the other five
|
|
6
6
|
// deferred — tool_search loads them), the consecutive-call loop dampener,
|
|
7
7
|
// /munin-status, the Munin Memory Protocol injection (only when configured),
|
|
@@ -17,7 +17,7 @@ import type {
|
|
|
17
17
|
import fs from "node:fs";
|
|
18
18
|
import path from "node:path";
|
|
19
19
|
import { Type } from "typebox";
|
|
20
|
-
import { MuninClient } from "./lib/sdk.js";
|
|
20
|
+
import { MuninClient, type MuninAction } from "./lib/sdk/index.js";
|
|
21
21
|
import {
|
|
22
22
|
formatCapabilities,
|
|
23
23
|
parseTags,
|
|
@@ -140,7 +140,12 @@ function withMuninClient<T extends Record<string, unknown>>(
|
|
|
140
140
|
ctx?.cwd,
|
|
141
141
|
ctx?.isProjectTrusted?.() === true,
|
|
142
142
|
);
|
|
143
|
-
|
|
143
|
+
// ponytail: ceiling — writeQueue:false keeps every write synchronous and
|
|
144
|
+
// honest ("the write was NOT saved" during a maintenance window). Flipping
|
|
145
|
+
// this boolean to the default turns on the vendored local queue
|
|
146
|
+
// (lib/sdk/writeQueue.ts + node/fileWriteQueue.ts), which saves a refused
|
|
147
|
+
// write to ~/.munin and replays it later; it is the one-line upgrade path.
|
|
148
|
+
const client = new MuninClient({ apiKey, baseUrl, writeQueue: false });
|
|
144
149
|
return callback(client, projectId);
|
|
145
150
|
}
|
|
146
151
|
|
|
@@ -184,10 +189,31 @@ export async function callMunin(
|
|
|
184
189
|
try {
|
|
185
190
|
return await withRetry(async () => invokeMuninAction(client, projectId, directAction, payload, invokeOptions));
|
|
186
191
|
} catch (error) {
|
|
192
|
+
const caught = error instanceof Error ? error : new Error(String(error));
|
|
193
|
+
// The server's write gate: our vendored SDK is older than the advertised
|
|
194
|
+
// minimum. The server's message ends in "install the npm package / update
|
|
195
|
+
// the Claude Code plugin" advice — wrong here, ceulen SHIPS the SDK (live
|
|
196
|
+
// 2026-11-26: "…npm install -g @kalera/munin-claude@latest…"). So the
|
|
197
|
+
// diagnostic head is kept and the install advice is cut, instead of being
|
|
198
|
+
// relayed by remediatedError/formatRemediation.
|
|
199
|
+
if (classifyError(caught).type === "client_outdated") {
|
|
200
|
+
const advice = /\s*(?:Update the Munin client|Claude Code:|Other MCP configs:|npm install|npx -y)\b/i;
|
|
201
|
+
let diagnostic = caught.message.split(advice)[0]!.trim();
|
|
202
|
+
if (!/NOT saved/i.test(diagnostic)) diagnostic += " This write was NOT saved.";
|
|
203
|
+
const outdated = new Error(
|
|
204
|
+
sanitizeErrorMessage(new Error(
|
|
205
|
+
`${diagnostic} ceulen vendors the Munin SDK — this is fixed by upgrading ceulen, not by installing the npm package.`,
|
|
206
|
+
)),
|
|
207
|
+
{ cause: caught },
|
|
208
|
+
);
|
|
209
|
+
const code = (caught as Error & { code?: unknown }).code;
|
|
210
|
+
if (code !== undefined) (outdated as Error & { code?: unknown }).code = code;
|
|
211
|
+
throw outdated;
|
|
212
|
+
}
|
|
187
213
|
// Layer 1: auto-recover from ERR_STALE_PROTOCOL via the server's
|
|
188
214
|
// acknowledge_setup handshake, then retry the original call exactly once.
|
|
189
215
|
// ponytail: single retry — no loop; ack is idempotent and server-side remembered.
|
|
190
|
-
const err =
|
|
216
|
+
const err = caught;
|
|
191
217
|
const remediation = extractRemediation(err);
|
|
192
218
|
const ack = remediation?.acknowledge_after_reading;
|
|
193
219
|
const isStale =
|
|
@@ -203,7 +229,7 @@ export async function callMunin(
|
|
|
203
229
|
let ackFailed = false;
|
|
204
230
|
try {
|
|
205
231
|
// ack is a real action even when not advertised in capabilities.
|
|
206
|
-
const ackResult = await client.invoke(projectId, ackAction, { version }, { ensureCapability: false });
|
|
232
|
+
const ackResult = await client.invoke(projectId, ackAction as MuninAction, { version }, { ensureCapability: false });
|
|
207
233
|
ackFailed = !!ackResult && typeof ackResult === "object" &&
|
|
208
234
|
((ackResult as { ok?: boolean }).ok === false || (ackResult as { success?: boolean }).success === false || (ackResult as { acknowledged?: boolean }).acknowledged === false);
|
|
209
235
|
} catch {
|
|
@@ -251,7 +277,7 @@ function invokeMuninAction(
|
|
|
251
277
|
return (direct as (this: MuninClient, projectId: string, payload: Record<string, unknown>) => Promise<unknown>).call(client, projectId, payload);
|
|
252
278
|
}
|
|
253
279
|
if (typeof client.invoke === "function") {
|
|
254
|
-
return client.invoke(projectId, directAction, payload, invokeOptions);
|
|
280
|
+
return client.invoke(projectId, directAction as MuninAction, payload, invokeOptions);
|
|
255
281
|
}
|
|
256
282
|
throw new Error(`Munin SDK does not support action: ${directAction}`);
|
|
257
283
|
}
|
|
@@ -276,6 +276,11 @@ export function formatCapabilities(caps: Record<string, unknown>): string {
|
|
|
276
276
|
if (actions?.optional?.length) lines.push(`Optional Actions: ${actions.optional.join(", ")}`);
|
|
277
277
|
const features = Object.entries(caps.features as Record<string, { supported: boolean }> || {});
|
|
278
278
|
if (features.length) lines.push(`Features: ${features.map(([n, i]) => `${n} ${i?.supported ? "✓" : "✗"}`).join(", ")}`);
|
|
279
|
+
// The server's write gate: a client below a minimum cannot write at all.
|
|
280
|
+
const clients = Object.entries((caps.clients as Record<string, { minimum?: string; latest?: string }> | undefined) ?? {});
|
|
281
|
+
for (const [name, info] of clients) {
|
|
282
|
+
lines.push(`Client ${name}: minimum ${info?.minimum ?? "unset"}, latest ${info?.latest ?? "unset"}`);
|
|
283
|
+
}
|
|
279
284
|
return lines.join("\n");
|
|
280
285
|
}
|
|
281
286
|
|
|
@@ -365,6 +370,8 @@ export function classifyError(error: unknown): { type: string; message: string;
|
|
|
365
370
|
FEATURE_DISABLED: "feature_disabled",
|
|
366
371
|
RATE_LIMITED: "rate_limit",
|
|
367
372
|
ERR_STALE_PROTOCOL: "stale_protocol",
|
|
373
|
+
ERR_CLIENT_OUTDATED: "client_outdated",
|
|
374
|
+
MAINTENANCE_READ_ONLY: "maintenance",
|
|
368
375
|
NOT_FOUND: "not_found",
|
|
369
376
|
};
|
|
370
377
|
if (structuredTypes[code]) return { type: structuredTypes[code], message: err.message, remediation };
|
|
@@ -383,6 +390,9 @@ export function classifyError(error: unknown): { type: string; message: string;
|
|
|
383
390
|
if (message.includes("rate limit") || message.includes("too many requests") || /\b429\b/.test(message)) return { type: "rate_limit", message: err.message };
|
|
384
391
|
if (message.includes("e2ee") || message.includes("encryption")) return { type: "e2ee", message: err.message };
|
|
385
392
|
if (message.includes("stale protocol")) return { type: "stale_protocol", message: err.message };
|
|
393
|
+
// The tool_result sanitizer re-classifies from TEXT (no `code`), and
|
|
394
|
+
// callMunin's client_outdated branch writes "too old to write" without one.
|
|
395
|
+
if (message.includes("too old to write")) return { type: "client_outdated", message: err.message };
|
|
386
396
|
if (message.includes("not found")) return { type: "not_found", message: err.message };
|
|
387
397
|
return { type: "unknown", message: err.message };
|
|
388
398
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// ponytail: vendored from @kalera/munin-sdk 1.6.0 (dist/capabilities.js + capabilities.d.ts).
|
|
2
|
+
// Local delta 2: fetchCapabilities takes a timeoutMs (upstream has 3 params and no
|
|
3
|
+
// signal), so a dead capabilities endpoint cannot park a munin_* call forever.
|
|
4
|
+
|
|
5
|
+
import { MuninSdkError, MuninTransportError } from "./errors.js";
|
|
6
|
+
import type { MuninCapabilities, MuninResponse } from "./types.js";
|
|
7
|
+
|
|
8
|
+
const DEFAULT_TIMEOUT_MS = 15_000;
|
|
9
|
+
|
|
10
|
+
export async function fetchCapabilities(
|
|
11
|
+
baseUrl: string,
|
|
12
|
+
apiKey?: string,
|
|
13
|
+
fetchImpl: typeof fetch = fetch,
|
|
14
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
15
|
+
): Promise<MuninCapabilities> {
|
|
16
|
+
const response = await fetchImpl(`${baseUrl}/api/mcp/capabilities`, {
|
|
17
|
+
method: "GET",
|
|
18
|
+
headers: {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
...(apiKey ? { Authorization: `Bearer ${apiKey}` } : {}),
|
|
21
|
+
},
|
|
22
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
23
|
+
}).catch((error) => {
|
|
24
|
+
throw new MuninTransportError(`Failed to call capabilities endpoint: ${String(error)}`);
|
|
25
|
+
});
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new MuninTransportError(`Capabilities request failed with status ${response.status}`);
|
|
28
|
+
}
|
|
29
|
+
const body = (await response.json()) as MuninResponse<MuninCapabilities>;
|
|
30
|
+
if (!body.ok || !body.data) {
|
|
31
|
+
throw new MuninSdkError(body.error ?? {
|
|
32
|
+
code: "INTERNAL_ERROR",
|
|
33
|
+
message: "Capabilities response missing data",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return body.data;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function isActionSupported(capabilities: MuninCapabilities, action: string): boolean {
|
|
40
|
+
return capabilities.actions.core.includes(action) ||
|
|
41
|
+
capabilities.actions.optional.includes(action);
|
|
42
|
+
}
|