@armature-tech/mcp-analytics 0.6.20 → 0.6.22
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/dist/cjs/recorder.js +12 -0
- package/dist/cjs/sanitize.js +14 -2
- package/dist/cjs/types.d.ts +2 -0
- package/dist/esm/recorder.js +12 -0
- package/dist/esm/sanitize.js +14 -2
- package/dist/esm/types.d.ts +2 -0
- package/package.json +1 -1
package/dist/cjs/recorder.js
CHANGED
|
@@ -334,6 +334,12 @@ const createAnalyticsRecorder = (config = emit_js_1.defaultMcpAnalyticsConfig) =
|
|
|
334
334
|
...(registration.title !== undefined ? { title: registration.title } : {}),
|
|
335
335
|
...(description !== undefined ? { description } : {}),
|
|
336
336
|
...(registeredHasInputSchema ? { inputSchema: plan.inputSchema } : {}),
|
|
337
|
+
...(registration.outputSchema !== undefined
|
|
338
|
+
? { outputSchema: registration.outputSchema }
|
|
339
|
+
: {}),
|
|
340
|
+
...(registration.annotations !== undefined
|
|
341
|
+
? { annotations: registration.annotations }
|
|
342
|
+
: {}),
|
|
337
343
|
}, (async (...callbackArgs) => {
|
|
338
344
|
const argsOrExtra = callbackArgs[0];
|
|
339
345
|
const maybeExtra = callbackArgs[1];
|
|
@@ -398,6 +404,12 @@ const createAnalyticsRecorder = (config = emit_js_1.defaultMcpAnalyticsConfig) =
|
|
|
398
404
|
if (registration.inputSchema !== undefined) {
|
|
399
405
|
definition.inputSchema = registration.inputSchema;
|
|
400
406
|
}
|
|
407
|
+
if (registration.outputSchema !== undefined) {
|
|
408
|
+
definition.outputSchema = registration.outputSchema;
|
|
409
|
+
}
|
|
410
|
+
if (registration.annotations !== undefined) {
|
|
411
|
+
definition.annotations = registration.annotations;
|
|
412
|
+
}
|
|
401
413
|
definitions.push(...decorateDefinitions([definition]));
|
|
402
414
|
}
|
|
403
415
|
return definitions;
|
package/dist/cjs/sanitize.js
CHANGED
|
@@ -10,6 +10,9 @@ exports.SANITIZATION_BUDGET = 65_536;
|
|
|
10
10
|
const DATA_URI_MIN_CHARS = 64;
|
|
11
11
|
const BASE64_MIN_CHARS = 512;
|
|
12
12
|
const BASE64_RE = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
13
|
+
// Base64-alphabet runs long enough to be payloads embedded inside a larger
|
|
14
|
+
// string, e.g. a blob echoed within a JSON-serialized tool result.
|
|
15
|
+
const EMBEDDED_BASE64_RE = /[A-Za-z0-9+/_-]{512,}={0,2}/g;
|
|
13
16
|
const isBase64Payload = (value) => {
|
|
14
17
|
if (value.length >= DATA_URI_MIN_CHARS && value.startsWith("data:") && value.includes(";base64,")) {
|
|
15
18
|
return true;
|
|
@@ -17,7 +20,12 @@ const isBase64Payload = (value) => {
|
|
|
17
20
|
return value.length >= BASE64_MIN_CHARS && BASE64_RE.test(value);
|
|
18
21
|
};
|
|
19
22
|
const sanitizeString = (value) => {
|
|
20
|
-
|
|
23
|
+
if (isBase64Payload(value))
|
|
24
|
+
return exports.BASE64_REMOVED_PLACEHOLDER;
|
|
25
|
+
if (value.length >= BASE64_MIN_CHARS) {
|
|
26
|
+
return value.replace(EMBEDDED_BASE64_RE, exports.BASE64_REMOVED_PLACEHOLDER);
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
21
29
|
};
|
|
22
30
|
const charge = (budget, units) => {
|
|
23
31
|
if (budget.remaining < units) {
|
|
@@ -29,7 +37,11 @@ const charge = (budget, units) => {
|
|
|
29
37
|
};
|
|
30
38
|
const sanitizeValueBounded = (value, seen, budget) => {
|
|
31
39
|
if (typeof value === "string") {
|
|
32
|
-
|
|
40
|
+
// Bound pattern work to the retainable window first: previews are
|
|
41
|
+
// truncated anyway, so scanning beyond the budget is pure waste on
|
|
42
|
+
// large payloads.
|
|
43
|
+
const bounded = value.length > budget.remaining ? value.slice(0, budget.remaining) : value;
|
|
44
|
+
const sanitized = sanitizeString(bounded);
|
|
33
45
|
if (sanitized.length <= budget.remaining) {
|
|
34
46
|
budget.remaining -= sanitized.length;
|
|
35
47
|
return sanitized;
|
package/dist/cjs/types.d.ts
CHANGED
package/dist/esm/recorder.js
CHANGED
|
@@ -331,6 +331,12 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
331
331
|
...(registration.title !== undefined ? { title: registration.title } : {}),
|
|
332
332
|
...(description !== undefined ? { description } : {}),
|
|
333
333
|
...(registeredHasInputSchema ? { inputSchema: plan.inputSchema } : {}),
|
|
334
|
+
...(registration.outputSchema !== undefined
|
|
335
|
+
? { outputSchema: registration.outputSchema }
|
|
336
|
+
: {}),
|
|
337
|
+
...(registration.annotations !== undefined
|
|
338
|
+
? { annotations: registration.annotations }
|
|
339
|
+
: {}),
|
|
334
340
|
}, (async (...callbackArgs) => {
|
|
335
341
|
const argsOrExtra = callbackArgs[0];
|
|
336
342
|
const maybeExtra = callbackArgs[1];
|
|
@@ -395,6 +401,12 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
395
401
|
if (registration.inputSchema !== undefined) {
|
|
396
402
|
definition.inputSchema = registration.inputSchema;
|
|
397
403
|
}
|
|
404
|
+
if (registration.outputSchema !== undefined) {
|
|
405
|
+
definition.outputSchema = registration.outputSchema;
|
|
406
|
+
}
|
|
407
|
+
if (registration.annotations !== undefined) {
|
|
408
|
+
definition.annotations = registration.annotations;
|
|
409
|
+
}
|
|
398
410
|
definitions.push(...decorateDefinitions([definition]));
|
|
399
411
|
}
|
|
400
412
|
return definitions;
|
package/dist/esm/sanitize.js
CHANGED
|
@@ -7,6 +7,9 @@ export const SANITIZATION_BUDGET = 65_536;
|
|
|
7
7
|
const DATA_URI_MIN_CHARS = 64;
|
|
8
8
|
const BASE64_MIN_CHARS = 512;
|
|
9
9
|
const BASE64_RE = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
10
|
+
// Base64-alphabet runs long enough to be payloads embedded inside a larger
|
|
11
|
+
// string, e.g. a blob echoed within a JSON-serialized tool result.
|
|
12
|
+
const EMBEDDED_BASE64_RE = /[A-Za-z0-9+/_-]{512,}={0,2}/g;
|
|
10
13
|
const isBase64Payload = (value) => {
|
|
11
14
|
if (value.length >= DATA_URI_MIN_CHARS && value.startsWith("data:") && value.includes(";base64,")) {
|
|
12
15
|
return true;
|
|
@@ -14,7 +17,12 @@ const isBase64Payload = (value) => {
|
|
|
14
17
|
return value.length >= BASE64_MIN_CHARS && BASE64_RE.test(value);
|
|
15
18
|
};
|
|
16
19
|
const sanitizeString = (value) => {
|
|
17
|
-
|
|
20
|
+
if (isBase64Payload(value))
|
|
21
|
+
return BASE64_REMOVED_PLACEHOLDER;
|
|
22
|
+
if (value.length >= BASE64_MIN_CHARS) {
|
|
23
|
+
return value.replace(EMBEDDED_BASE64_RE, BASE64_REMOVED_PLACEHOLDER);
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
18
26
|
};
|
|
19
27
|
const charge = (budget, units) => {
|
|
20
28
|
if (budget.remaining < units) {
|
|
@@ -26,7 +34,11 @@ const charge = (budget, units) => {
|
|
|
26
34
|
};
|
|
27
35
|
const sanitizeValueBounded = (value, seen, budget) => {
|
|
28
36
|
if (typeof value === "string") {
|
|
29
|
-
|
|
37
|
+
// Bound pattern work to the retainable window first: previews are
|
|
38
|
+
// truncated anyway, so scanning beyond the budget is pure waste on
|
|
39
|
+
// large payloads.
|
|
40
|
+
const bounded = value.length > budget.remaining ? value.slice(0, budget.remaining) : value;
|
|
41
|
+
const sanitized = sanitizeString(bounded);
|
|
30
42
|
if (sanitized.length <= budget.remaining) {
|
|
31
43
|
budget.remaining -= sanitized.length;
|
|
32
44
|
return sanitized;
|
package/dist/esm/types.d.ts
CHANGED