@kalera/munin-runtime 1.4.4 → 1.5.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/.turbo/turbo-build.log +1 -1
- package/dist/index.js +39 -1
- package/dist/mcp-server.js +1 -1
- package/package.json +4 -3
- package/src/index.ts +39 -1
- package/src/mcp-server.ts +1 -1
- package/test/schema.test.ts +3 -1
- package/test/validation.test.ts +30 -1
package/.turbo/turbo-build.log
CHANGED
package/dist/index.js
CHANGED
|
@@ -128,13 +128,51 @@ export async function executeWithRetry(task, retries, backoffMs) {
|
|
|
128
128
|
}
|
|
129
129
|
export function safeError(error) {
|
|
130
130
|
if (error instanceof Error) {
|
|
131
|
-
|
|
131
|
+
const safe = {
|
|
132
132
|
name: error.name,
|
|
133
133
|
message: redactText(error.message),
|
|
134
134
|
};
|
|
135
|
+
// MuninSdkError carries structured `code` + `details`; preserve them so
|
|
136
|
+
// callers can branch on the code, but redact any secrets nested in details
|
|
137
|
+
// (both secret-named keys and inline `token=...` patterns in values).
|
|
138
|
+
const sdkError = error;
|
|
139
|
+
if (error.name === "MuninSdkError") {
|
|
140
|
+
if (sdkError.code !== undefined)
|
|
141
|
+
safe.code = sdkError.code;
|
|
142
|
+
if (sdkError.details !== undefined)
|
|
143
|
+
safe.details = redactValue(sdkError.details);
|
|
144
|
+
}
|
|
145
|
+
return safe;
|
|
135
146
|
}
|
|
136
147
|
return { message: redactText(String(error)) };
|
|
137
148
|
}
|
|
149
|
+
function isSecretKey(key) {
|
|
150
|
+
const lower = key.toLowerCase();
|
|
151
|
+
return REDACT_KEYS.some((redactKey) => redactKey.toLowerCase() === lower);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Recursively redact secrets from an arbitrary value. A property whose KEY is a
|
|
155
|
+
* known secret (apiKey, token, …) has its value replaced wholesale; every other
|
|
156
|
+
* string is passed through inline `redactText` so embedded `token=...` secrets
|
|
157
|
+
* are scrubbed without losing surrounding context.
|
|
158
|
+
*/
|
|
159
|
+
function redactValue(value) {
|
|
160
|
+
if (typeof value === "string")
|
|
161
|
+
return redactText(value);
|
|
162
|
+
if (Array.isArray(value))
|
|
163
|
+
return value.map((item) => redactValue(item));
|
|
164
|
+
if (value && typeof value === "object") {
|
|
165
|
+
const out = {};
|
|
166
|
+
for (const [key, val] of Object.entries(value)) {
|
|
167
|
+
out[key] =
|
|
168
|
+
isSecretKey(key) && (val === null || typeof val !== "object")
|
|
169
|
+
? "[REDACTED]"
|
|
170
|
+
: redactValue(val);
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
return value;
|
|
175
|
+
}
|
|
138
176
|
function redactText(text) {
|
|
139
177
|
return REDACT_KEYS.reduce((acc, key) => {
|
|
140
178
|
const pattern = new RegExp(`${key}\\s*[:=]\\s*[^\\s,]+`, "gi");
|
package/dist/mcp-server.js
CHANGED
package/package.json
CHANGED
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
"devDependencies": {
|
|
10
10
|
"@types/node": "^24.3.0",
|
|
11
11
|
"tsx": "^4.20.5",
|
|
12
|
-
"typescript": "^5.9.2"
|
|
12
|
+
"typescript": "^5.9.2",
|
|
13
|
+
"@kalera/munin-shared-version": "1.5.0"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
16
|
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
16
|
-
"@kalera/munin-sdk": "1.
|
|
17
|
+
"@kalera/munin-sdk": "1.5.0"
|
|
17
18
|
},
|
|
18
|
-
"version": "1.
|
|
19
|
+
"version": "1.5.0",
|
|
19
20
|
"scripts": {
|
|
20
21
|
"build": "tsc -p tsconfig.json",
|
|
21
22
|
"lint": "tsc -p tsconfig.json --noEmit",
|
package/src/index.ts
CHANGED
|
@@ -157,15 +157,53 @@ export async function executeWithRetry<T>(
|
|
|
157
157
|
|
|
158
158
|
export function safeError(error: unknown): Record<string, unknown> {
|
|
159
159
|
if (error instanceof Error) {
|
|
160
|
-
|
|
160
|
+
const safe: Record<string, unknown> = {
|
|
161
161
|
name: error.name,
|
|
162
162
|
message: redactText(error.message),
|
|
163
163
|
};
|
|
164
|
+
|
|
165
|
+
// MuninSdkError carries structured `code` + `details`; preserve them so
|
|
166
|
+
// callers can branch on the code, but redact any secrets nested in details
|
|
167
|
+
// (both secret-named keys and inline `token=...` patterns in values).
|
|
168
|
+
const sdkError = error as Error & { code?: unknown; details?: unknown };
|
|
169
|
+
if (error.name === "MuninSdkError") {
|
|
170
|
+
if (sdkError.code !== undefined) safe.code = sdkError.code;
|
|
171
|
+
if (sdkError.details !== undefined) safe.details = redactValue(sdkError.details);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
return safe;
|
|
164
175
|
}
|
|
165
176
|
|
|
166
177
|
return { message: redactText(String(error)) };
|
|
167
178
|
}
|
|
168
179
|
|
|
180
|
+
function isSecretKey(key: string): boolean {
|
|
181
|
+
const lower = key.toLowerCase();
|
|
182
|
+
return REDACT_KEYS.some((redactKey) => redactKey.toLowerCase() === lower);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Recursively redact secrets from an arbitrary value. A property whose KEY is a
|
|
187
|
+
* known secret (apiKey, token, …) has its value replaced wholesale; every other
|
|
188
|
+
* string is passed through inline `redactText` so embedded `token=...` secrets
|
|
189
|
+
* are scrubbed without losing surrounding context.
|
|
190
|
+
*/
|
|
191
|
+
function redactValue(value: unknown): unknown {
|
|
192
|
+
if (typeof value === "string") return redactText(value);
|
|
193
|
+
if (Array.isArray(value)) return value.map((item) => redactValue(item));
|
|
194
|
+
if (value && typeof value === "object") {
|
|
195
|
+
const out: Record<string, unknown> = {};
|
|
196
|
+
for (const [key, val] of Object.entries(value)) {
|
|
197
|
+
out[key] =
|
|
198
|
+
isSecretKey(key) && (val === null || typeof val !== "object")
|
|
199
|
+
? "[REDACTED]"
|
|
200
|
+
: redactValue(val);
|
|
201
|
+
}
|
|
202
|
+
return out;
|
|
203
|
+
}
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
|
|
169
207
|
function redactText(text: string): string {
|
|
170
208
|
return REDACT_KEYS.reduce((acc, key) => {
|
|
171
209
|
const pattern = new RegExp(`${key}\\s*[:=]\\s*[^\\s,]+`, "gi");
|
package/src/mcp-server.ts
CHANGED
package/test/schema.test.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
3
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
4
|
+
import { SERVER_VERSION } from "@kalera/munin-shared-version";
|
|
4
5
|
import { createMcpServerInstance } from "../src/mcp-server.js";
|
|
5
6
|
|
|
6
7
|
async function run() {
|
|
@@ -18,7 +19,7 @@ async function run() {
|
|
|
18
19
|
const client = new Client(
|
|
19
20
|
{
|
|
20
21
|
name: "runtime-schema-test-client",
|
|
21
|
-
version: "1.
|
|
22
|
+
version: "1.5.0",
|
|
22
23
|
},
|
|
23
24
|
{
|
|
24
25
|
capabilities: {},
|
|
@@ -30,6 +31,7 @@ async function run() {
|
|
|
30
31
|
server.connect(serverTransport),
|
|
31
32
|
client.connect(clientTransport),
|
|
32
33
|
]);
|
|
34
|
+
assert.equal(client.getServerVersion()?.version, SERVER_VERSION);
|
|
33
35
|
|
|
34
36
|
const response = await client.listTools();
|
|
35
37
|
|
package/test/validation.test.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
3
3
|
import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";
|
|
4
|
+
import { MuninSdkError } from "@kalera/munin-sdk";
|
|
4
5
|
import { createMcpServerInstance } from "../src/mcp-server.js";
|
|
6
|
+
import { safeError } from "../src/index.js";
|
|
5
7
|
|
|
6
8
|
interface ToolResult {
|
|
7
9
|
isError?: boolean;
|
|
@@ -23,6 +25,33 @@ function expectValidationError(result: ToolResult, toolName: string, scenario: s
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
async function run() {
|
|
28
|
+
assert.deepEqual(
|
|
29
|
+
safeError(new MuninSdkError({
|
|
30
|
+
code: "ERR_STALE_PROTOCOL",
|
|
31
|
+
message: "ERR_STALE_PROTOCOL",
|
|
32
|
+
details: {
|
|
33
|
+
remediation: {
|
|
34
|
+
version: "2026-04-17",
|
|
35
|
+
setupGuideUrl: "https://example.test/setup",
|
|
36
|
+
apiKey: "secret-value",
|
|
37
|
+
instruction: "token=secret-value",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
})),
|
|
41
|
+
{
|
|
42
|
+
name: "MuninSdkError",
|
|
43
|
+
message: "ERR_STALE_PROTOCOL",
|
|
44
|
+
code: "ERR_STALE_PROTOCOL",
|
|
45
|
+
details: {
|
|
46
|
+
remediation: {
|
|
47
|
+
version: "2026-04-17",
|
|
48
|
+
setupGuideUrl: "https://example.test/setup",
|
|
49
|
+
apiKey: "[REDACTED]",
|
|
50
|
+
instruction: "token=[REDACTED]",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
);
|
|
26
55
|
const server = createMcpServerInstance(
|
|
27
56
|
{
|
|
28
57
|
baseUrl: "https://munin.kalera.dev",
|
|
@@ -35,7 +64,7 @@ async function run() {
|
|
|
35
64
|
);
|
|
36
65
|
|
|
37
66
|
const client = new Client(
|
|
38
|
-
{ name: "runtime-validation-test-client", version: "1.
|
|
67
|
+
{ name: "runtime-validation-test-client", version: "1.5.0" },
|
|
39
68
|
{ capabilities: {} },
|
|
40
69
|
);
|
|
41
70
|
|