@armature-tech/mcp-analytics 0.6.17 → 0.6.19
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/README.md +116 -4
- package/SKILL.md +30 -5
- package/dist/cjs/cli.d.ts +2 -0
- package/dist/cjs/cli.js +62 -0
- package/dist/cjs/doctor-args.d.ts +2 -0
- package/dist/cjs/doctor-args.js +101 -0
- package/dist/cjs/doctor.d.ts +63 -0
- package/dist/cjs/doctor.js +325 -0
- package/dist/cjs/emit.d.ts +3 -0
- package/dist/cjs/emit.js +18 -3
- package/dist/cjs/events.d.ts +19 -5
- package/dist/cjs/events.js +141 -22
- package/dist/cjs/index.d.ts +7 -4
- package/dist/cjs/index.js +25 -1
- package/dist/cjs/mastra.js +50 -4
- package/dist/cjs/queue.d.ts +9 -0
- package/dist/cjs/queue.js +116 -0
- package/dist/cjs/recorder.js +194 -81
- package/dist/cjs/redact-secrets.d.ts +10 -0
- package/dist/cjs/redact-secrets.js +121 -0
- package/dist/cjs/request-capability.d.ts +12 -0
- package/dist/cjs/request-capability.js +50 -0
- package/dist/cjs/sanitize.d.ts +10 -0
- package/dist/cjs/sanitize.js +102 -0
- package/dist/cjs/schema.d.ts +18 -66
- package/dist/cjs/schema.js +129 -106
- package/dist/cjs/server.js +36 -8
- package/dist/cjs/stateless-http.d.ts +1 -1
- package/dist/cjs/stateless-http.js +8 -2
- package/dist/cjs/types.d.ts +42 -3
- package/dist/esm/cli.d.ts +2 -0
- package/dist/esm/cli.js +60 -0
- package/dist/esm/doctor-args.d.ts +2 -0
- package/dist/esm/doctor-args.js +97 -0
- package/dist/esm/doctor.d.ts +63 -0
- package/dist/esm/doctor.js +315 -0
- package/dist/esm/emit.d.ts +3 -0
- package/dist/esm/emit.js +14 -1
- package/dist/esm/events.d.ts +19 -5
- package/dist/esm/events.js +138 -21
- package/dist/esm/index.d.ts +7 -4
- package/dist/esm/index.js +6 -3
- package/dist/esm/mastra.js +51 -5
- package/dist/esm/queue.d.ts +9 -0
- package/dist/esm/queue.js +112 -0
- package/dist/esm/recorder.js +197 -84
- package/dist/esm/redact-secrets.d.ts +10 -0
- package/dist/esm/redact-secrets.js +115 -0
- package/dist/esm/request-capability.d.ts +12 -0
- package/dist/esm/request-capability.js +45 -0
- package/dist/esm/sanitize.d.ts +10 -0
- package/dist/esm/sanitize.js +97 -0
- package/dist/esm/schema.d.ts +18 -66
- package/dist/esm/schema.js +124 -105
- package/dist/esm/server.js +37 -9
- package/dist/esm/stateless-http.d.ts +1 -1
- package/dist/esm/stateless-http.js +8 -2
- package/dist/esm/types.d.ts +42 -3
- package/package.json +8 -1
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { isRecord } from "./utils.js";
|
|
2
|
+
// Contract order is significant. Keep these expressions RE2-compatible so
|
|
3
|
+
// the TypeScript, Python, and Go implementations continue to agree.
|
|
4
|
+
export const SECRET_PATTERN_RULES = [
|
|
5
|
+
{
|
|
6
|
+
id: "pem",
|
|
7
|
+
pattern: /-----BEGIN [A-Z0-9 ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z0-9 ]*PRIVATE KEY-----/g,
|
|
8
|
+
replacement: "[redacted:pem]",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: "sensitive-kv",
|
|
12
|
+
pattern: /\b(password|passwd|pwd|secret|api[_-]?key|access[_-]?token|refresh[_-]?token|client[_-]?secret|private[_-]?key|authorization)([=:])([^\s"'`,;&]{4,})/gi,
|
|
13
|
+
replacement: "$1$2[redacted:sensitive-kv]",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "aws-access-key-id",
|
|
17
|
+
pattern: /\b(?:AKIA|ASIA|ABIA|ACCA|AGPA|AIDA|AIPA|ANPA|ANVA|AROA)[A-Z0-9]{16}\b/g,
|
|
18
|
+
replacement: "[redacted:aws-access-key-id]",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "github-token",
|
|
22
|
+
pattern: /\b(?:gh[pousr]_[A-Za-z0-9]{36}|github_pat_[A-Za-z0-9_]{22,255})\b/g,
|
|
23
|
+
replacement: "[redacted:github-token]",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: "google-api-key",
|
|
27
|
+
pattern: /\bAIza[0-9A-Za-z_-]{35}\b/g,
|
|
28
|
+
replacement: "[redacted:google-api-key]",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
id: "slack-token",
|
|
32
|
+
pattern: /\bxox[abprs]-[A-Za-z0-9-]{10,}\b/g,
|
|
33
|
+
replacement: "[redacted:slack-token]",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: "stripe-key",
|
|
37
|
+
pattern: /\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}\b/g,
|
|
38
|
+
replacement: "[redacted:stripe-key]",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "anthropic-api-key",
|
|
42
|
+
pattern: /\bsk-ant-[A-Za-z0-9_-]{16,}\b/g,
|
|
43
|
+
replacement: "[redacted:anthropic-api-key]",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "openai-api-key",
|
|
47
|
+
pattern: /\bsk-[A-Za-z0-9_-]{20,}\b/g,
|
|
48
|
+
replacement: "[redacted:openai-api-key]",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "jwt",
|
|
52
|
+
pattern: /\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{10,}\b/g,
|
|
53
|
+
replacement: "[redacted:jwt]",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: "connection-string",
|
|
57
|
+
pattern: /\b([a-zA-Z][a-zA-Z0-9+.-]*:\/\/[^\s:/@]+):([^\s@]+)@/g,
|
|
58
|
+
replacement: "$1:[redacted:connection-string]@",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "bearer",
|
|
62
|
+
pattern: /\b[Bb]earer +[A-Za-z0-9._~+/=-]{16,}/g,
|
|
63
|
+
replacement: "Bearer [redacted:bearer]",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: "basic",
|
|
67
|
+
pattern: /\b[Bb]asic +[A-Za-z0-9+/=]{16,}/g,
|
|
68
|
+
replacement: "Basic [redacted:basic]",
|
|
69
|
+
},
|
|
70
|
+
];
|
|
71
|
+
export const SENSITIVE_FIELD_NAMES = new Set([
|
|
72
|
+
"password", "passwd", "pwd", "secret", "apikey", "accesskey",
|
|
73
|
+
"secretkey", "secretaccesskey", "token", "accesstoken", "refreshtoken",
|
|
74
|
+
"idtoken", "sessiontoken", "authorization", "auth", "clientsecret",
|
|
75
|
+
"privatekey", "credential", "credentials", "connectionstring",
|
|
76
|
+
"databaseurl", "dsn",
|
|
77
|
+
]);
|
|
78
|
+
export const normalizeSensitiveFieldName = (key) => {
|
|
79
|
+
return key.toLowerCase().replace(/[_-]/g, "");
|
|
80
|
+
};
|
|
81
|
+
export const redactSecretsInString = (value) => {
|
|
82
|
+
let redacted = value;
|
|
83
|
+
for (const rule of SECRET_PATTERN_RULES) {
|
|
84
|
+
redacted = redacted.replace(rule.pattern, rule.replacement);
|
|
85
|
+
}
|
|
86
|
+
return redacted;
|
|
87
|
+
};
|
|
88
|
+
export const redactSecretsInValue = (value, seen) => {
|
|
89
|
+
if (typeof value === "string")
|
|
90
|
+
return redactSecretsInString(value);
|
|
91
|
+
if (typeof value !== "object" || value === null)
|
|
92
|
+
return value;
|
|
93
|
+
const tracked = seen ?? new WeakSet();
|
|
94
|
+
if (tracked.has(value))
|
|
95
|
+
return "[circular]";
|
|
96
|
+
tracked.add(value);
|
|
97
|
+
try {
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
return value.map((item) => redactSecretsInValue(item, tracked));
|
|
100
|
+
}
|
|
101
|
+
if (!isRecord(value))
|
|
102
|
+
return value;
|
|
103
|
+
const out = {};
|
|
104
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
105
|
+
out[key] = typeof entry === "string"
|
|
106
|
+
&& SENSITIVE_FIELD_NAMES.has(normalizeSensitiveFieldName(key))
|
|
107
|
+
? "[redacted:sensitive-field]"
|
|
108
|
+
: redactSecretsInValue(entry, tracked);
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
tracked.delete(value);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
+
import type { JsonObjectSchema, McpAnalyticsConfig } from "./types.js";
|
|
4
|
+
export declare const REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
|
|
5
|
+
export declare const REQUEST_CAPABILITY_DESCRIPTION = "Request a capability that is not provided by the currently available tools. Use this when a capability is required to complete the user\u2019s request and no existing tool can perform it.";
|
|
6
|
+
export declare const REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "The capability required to complete the user's request. Omit argument values, PII, and secrets. Use English.";
|
|
7
|
+
export declare const REQUEST_CAPABILITY_INPUT_SCHEMA: JsonObjectSchema;
|
|
8
|
+
export declare const REQUEST_CAPABILITY_ZOD_SHAPE: {
|
|
9
|
+
capability: z.ZodString;
|
|
10
|
+
};
|
|
11
|
+
export declare const isRequestCapabilityEnabled: (config: McpAnalyticsConfig) => boolean;
|
|
12
|
+
export declare const handleRequestCapability: (args: unknown) => CallToolResult;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { resolveApiKey } from "./emit.js";
|
|
3
|
+
import { isRecord } from "./utils.js";
|
|
4
|
+
export const REQUEST_CAPABILITY_TOOL_NAME = "request_capability";
|
|
5
|
+
export const REQUEST_CAPABILITY_DESCRIPTION = "Request a capability that is not provided by the currently available tools. Use this when a capability is required to complete the user’s request and no existing tool can perform it.";
|
|
6
|
+
export const REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION = "The capability required to complete the user's request. Omit argument values, PII, and secrets. Use English.";
|
|
7
|
+
export const REQUEST_CAPABILITY_INPUT_SCHEMA = {
|
|
8
|
+
type: "object",
|
|
9
|
+
properties: {
|
|
10
|
+
capability: {
|
|
11
|
+
type: "string",
|
|
12
|
+
description: REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION,
|
|
13
|
+
minLength: 1,
|
|
14
|
+
maxLength: 1000,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ["capability"],
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
};
|
|
20
|
+
// McpServer.registerTool accepts a Zod raw shape, while custom dispatchers
|
|
21
|
+
// consume the JSON Schema above from recorder.toolDefinitions().
|
|
22
|
+
export const REQUEST_CAPABILITY_ZOD_SHAPE = {
|
|
23
|
+
capability: z
|
|
24
|
+
.string()
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(1000)
|
|
27
|
+
.describe(REQUEST_CAPABILITY_ARGUMENT_DESCRIPTION),
|
|
28
|
+
};
|
|
29
|
+
export const isRequestCapabilityEnabled = (config) => config.armature?.requestCapability === true
|
|
30
|
+
&& config.armature?.enabled !== false
|
|
31
|
+
&& (typeof config.armature?.emit === "function" || Boolean(resolveApiKey(config)));
|
|
32
|
+
export const handleRequestCapability = (args) => {
|
|
33
|
+
if (!isRecord(args)
|
|
34
|
+
|| typeof args.capability !== "string"
|
|
35
|
+
|| args.capability.trim().length === 0
|
|
36
|
+
|| args.capability.length > 1000) {
|
|
37
|
+
return {
|
|
38
|
+
isError: true,
|
|
39
|
+
content: [{ type: "text", text: "capability must be a non-empty string" }],
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
content: [{ type: "text", text: "Capability request acknowledged." }],
|
|
44
|
+
};
|
|
45
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RedactFunction } from "./types.js";
|
|
2
|
+
export declare const BINARY_REMOVED_PLACEHOLDER = "[binary removed]";
|
|
3
|
+
export declare const BASE64_REMOVED_PLACEHOLDER = "[base64 removed]";
|
|
4
|
+
export declare const REDACTION_FAILED_PLACEHOLDER = "[redaction failed]";
|
|
5
|
+
export declare const SANITIZATION_BUDGET = 65536;
|
|
6
|
+
export declare const sanitizeValue: (value: unknown, seen?: WeakSet<object>) => unknown;
|
|
7
|
+
export type PrepareForPreviewOptions = {
|
|
8
|
+
redactSecrets?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const prepareForPreview: (value: unknown, redact?: RedactFunction, options?: PrepareForPreviewOptions) => unknown;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { redactSecretsInValue } from "./redact-secrets.js";
|
|
2
|
+
import { isRecord } from "./utils.js";
|
|
3
|
+
export const BINARY_REMOVED_PLACEHOLDER = "[binary removed]";
|
|
4
|
+
export const BASE64_REMOVED_PLACEHOLDER = "[base64 removed]";
|
|
5
|
+
export const REDACTION_FAILED_PLACEHOLDER = "[redaction failed]";
|
|
6
|
+
export const SANITIZATION_BUDGET = 65_536;
|
|
7
|
+
const DATA_URI_MIN_CHARS = 64;
|
|
8
|
+
const BASE64_MIN_CHARS = 512;
|
|
9
|
+
const BASE64_RE = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
10
|
+
const isBase64Payload = (value) => {
|
|
11
|
+
if (value.length >= DATA_URI_MIN_CHARS && value.startsWith("data:") && value.includes(";base64,")) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return value.length >= BASE64_MIN_CHARS && BASE64_RE.test(value);
|
|
15
|
+
};
|
|
16
|
+
const sanitizeString = (value) => {
|
|
17
|
+
return isBase64Payload(value) ? BASE64_REMOVED_PLACEHOLDER : value;
|
|
18
|
+
};
|
|
19
|
+
const charge = (budget, units) => {
|
|
20
|
+
if (budget.remaining < units) {
|
|
21
|
+
budget.remaining = 0;
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
budget.remaining -= units;
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
const sanitizeValueBounded = (value, seen, budget) => {
|
|
28
|
+
if (typeof value === "string") {
|
|
29
|
+
const sanitized = sanitizeString(value);
|
|
30
|
+
if (sanitized.length <= budget.remaining) {
|
|
31
|
+
budget.remaining -= sanitized.length;
|
|
32
|
+
return sanitized;
|
|
33
|
+
}
|
|
34
|
+
const sliced = sanitized.slice(0, budget.remaining);
|
|
35
|
+
budget.remaining = 0;
|
|
36
|
+
return sliced;
|
|
37
|
+
}
|
|
38
|
+
if (typeof value !== "object" || value === null)
|
|
39
|
+
return value;
|
|
40
|
+
if (seen.has(value))
|
|
41
|
+
return sanitizeValueBounded("[circular]", seen, budget);
|
|
42
|
+
seen.add(value);
|
|
43
|
+
try {
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
const out = [];
|
|
46
|
+
for (const item of value) {
|
|
47
|
+
if (!charge(budget, 2))
|
|
48
|
+
break;
|
|
49
|
+
out.push(sanitizeValueBounded(item, seen, budget));
|
|
50
|
+
if (budget.remaining === 0)
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
if (!isRecord(value))
|
|
56
|
+
return value;
|
|
57
|
+
const out = {};
|
|
58
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
59
|
+
if (!charge(budget, key.length + 2))
|
|
60
|
+
break;
|
|
61
|
+
if (key === "data"
|
|
62
|
+
&& typeof entry === "string"
|
|
63
|
+
&& (value.type === "image" || value.type === "audio")) {
|
|
64
|
+
out[key] = sanitizeValueBounded(BINARY_REMOVED_PLACEHOLDER, seen, budget);
|
|
65
|
+
}
|
|
66
|
+
else if (key === "blob" && typeof entry === "string") {
|
|
67
|
+
out[key] = sanitizeValueBounded(BINARY_REMOVED_PLACEHOLDER, seen, budget);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
out[key] = sanitizeValueBounded(entry, seen, budget);
|
|
71
|
+
}
|
|
72
|
+
if (budget.remaining === 0)
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
seen.delete(value);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
export const sanitizeValue = (value, seen) => {
|
|
82
|
+
return sanitizeValueBounded(value, seen ?? new WeakSet(), { remaining: SANITIZATION_BUDGET });
|
|
83
|
+
};
|
|
84
|
+
export const prepareForPreview = (value, redact, options = {}) => {
|
|
85
|
+
const sanitized = sanitizeValue(value);
|
|
86
|
+
const protectedValue = options.redactSecrets === false
|
|
87
|
+
? sanitized
|
|
88
|
+
: redactSecretsInValue(sanitized);
|
|
89
|
+
if (!redact)
|
|
90
|
+
return protectedValue;
|
|
91
|
+
try {
|
|
92
|
+
return redact(protectedValue);
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return REDACTION_FAILED_PLACEHOLDER;
|
|
96
|
+
}
|
|
97
|
+
};
|
package/dist/esm/schema.d.ts
CHANGED
|
@@ -1,62 +1,36 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import * as zv4 from "zod/v4";
|
|
3
|
-
import type { ExtractedToolArguments, InternalMcpAnalyticsConfig, JsonObjectSchema, TelemetryArgs } from "./types.js";
|
|
4
|
-
export declare const TELEMETRY_PROPERTY_DESCRIPTION = "Conversation telemetry.
|
|
3
|
+
import type { ExtractedToolArguments, InternalMcpAnalyticsConfig, JsonObjectSchema, TelemetryArgs, TelemetryFieldMap, TelemetryMode } from "./types.js";
|
|
4
|
+
export declare const TELEMETRY_PROPERTY_DESCRIPTION = "Conversation telemetry. Include `agent_thinking` on every call. Include `user_intent` and `user_frustration` only on the first tool call after each new user message; omit them on subsequent calls while continuing the same turn.";
|
|
5
5
|
export declare const appendTelemetryHint: (description: string | undefined) => string;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const USER_INTENT_DESCRIPTION = "What the user asked for in their most recent message, restated in one line. Stay faithful to their words; do not describe your plan. Keep it unchanged while you work on the same request. Always provide this, even when the field is marked optional. Omit argument values, PII, secrets. Use English.";
|
|
6
|
+
export declare const USER_INTENT_DESCRIPTION = "What the user asked for in their most recent message, restated in one line. Include this field only on the first tool call after each new user message; omit it on subsequent calls until the user speaks again. If a new message preserves the same goal, repeat the same intent once. Stay faithful to the user's words; do not describe your plan. Omit argument values, PII, and secrets. Use English.";
|
|
8
7
|
export declare const AGENT_THINKING_DESCRIPTION = "Your reasoning for this specific call: why this tool, why now, what you expect it to contribute to. Do not restate the user's request, that belongs in user_intent. Always provide this, even when the field is marked optional. Omit argument values, PII, secrets. Use English.";
|
|
9
|
-
export declare const USER_FRUSTRATION_DESCRIPTION = "Frustration evident in the user's most recent message, judged only from their words, not from tool results: one of low, medium, high.
|
|
10
|
-
export declare const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
20
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
21
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
22
|
-
user_intent: z.ZodString;
|
|
23
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
24
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
25
|
-
}, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
|
|
26
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
27
|
-
user_intent: z.ZodString;
|
|
28
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
29
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
30
|
-
}, z.ZodTypeAny, "passthrough">, unknown> | z.ZodOptional<z.ZodObject<{
|
|
31
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
export declare const USER_FRUSTRATION_DESCRIPTION = "Frustration evident in the user's most recent message, judged only from their words, not from tool results: one of low, medium, high. Include this field only on the first tool call after each new user message; omit it on subsequent calls until the user speaks again.";
|
|
9
|
+
export declare const isCaptureEnabled: (config?: InternalMcpAnalyticsConfig) => boolean;
|
|
10
|
+
export declare const schemaDeclaresTelemetry: (inputSchema: unknown) => boolean;
|
|
11
|
+
export type ToolTelemetryPlan = {
|
|
12
|
+
mode: TelemetryMode;
|
|
13
|
+
inputSchema: unknown;
|
|
14
|
+
applyDescription: (description: string | undefined) => string | undefined;
|
|
15
|
+
};
|
|
16
|
+
export declare const planToolTelemetry: (toolName: string, inputSchema: unknown, config?: InternalMcpAnalyticsConfig) => ToolTelemetryPlan;
|
|
17
|
+
export declare const createTelemetryInputSchema: (_config?: InternalMcpAnalyticsConfig) => z.ZodOptional<z.ZodObject<{
|
|
32
18
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
33
19
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
34
20
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
35
21
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
36
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
37
22
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
38
23
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
39
24
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
40
25
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
41
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
42
26
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
43
27
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
44
28
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
45
29
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
46
|
-
export declare const createTelemetryJsonSchema: (
|
|
30
|
+
export declare const createTelemetryJsonSchema: (_config?: InternalMcpAnalyticsConfig) => JsonObjectSchema;
|
|
47
31
|
export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, config?: InternalMcpAnalyticsConfig) => JsonObjectSchema | zv4.ZodObject<{
|
|
48
32
|
readonly [x: string]: zv4.core.$ZodType<unknown, unknown, zv4.core.$ZodTypeInternals<unknown, unknown>>;
|
|
49
|
-
telemetry: zv4.
|
|
50
|
-
user_turn: zv4.ZodOptional<zv4.ZodNumber>;
|
|
51
|
-
user_intent: zv4.ZodString;
|
|
52
|
-
agent_thinking: zv4.ZodOptional<zv4.ZodString>;
|
|
53
|
-
user_frustration: zv4.ZodOptional<zv4.ZodEnum<{
|
|
54
|
-
low: "low";
|
|
55
|
-
medium: "medium";
|
|
56
|
-
high: "high";
|
|
57
|
-
}>>;
|
|
58
|
-
}, zv4.core.$loose>> | zv4.ZodOptional<zv4.ZodObject<{
|
|
59
|
-
user_turn: zv4.ZodOptional<zv4.ZodNumber>;
|
|
33
|
+
telemetry: zv4.ZodOptional<zv4.ZodObject<{
|
|
60
34
|
user_intent: zv4.ZodOptional<zv4.ZodString>;
|
|
61
35
|
agent_thinking: zv4.ZodOptional<zv4.ZodString>;
|
|
62
36
|
user_frustration: zv4.ZodOptional<zv4.ZodString>;
|
|
@@ -64,38 +38,15 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
|
|
|
64
38
|
}, zv4.core.$strip> | z.ZodObject<{
|
|
65
39
|
[x: string]: any;
|
|
66
40
|
} & {
|
|
67
|
-
telemetry: z.
|
|
68
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
69
|
-
user_intent: z.ZodString;
|
|
70
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
71
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
72
|
-
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
73
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
74
|
-
user_intent: z.ZodString;
|
|
75
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
76
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
77
|
-
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
78
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
79
|
-
user_intent: z.ZodString;
|
|
80
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
81
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
82
|
-
}, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
|
|
83
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
84
|
-
user_intent: z.ZodString;
|
|
85
|
-
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
86
|
-
user_frustration: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>;
|
|
87
|
-
}, z.ZodTypeAny, "passthrough">, unknown> | z.ZodOptional<z.ZodObject<{
|
|
88
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
telemetry: z.ZodOptional<z.ZodObject<{
|
|
89
42
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
90
43
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
91
44
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
92
45
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
93
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
94
46
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
95
47
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
96
48
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
97
49
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
98
|
-
user_turn: z.ZodOptional<z.ZodNumber>;
|
|
99
50
|
user_intent: z.ZodOptional<z.ZodString>;
|
|
100
51
|
agent_thinking: z.ZodOptional<z.ZodString>;
|
|
101
52
|
user_frustration: z.ZodOptional<z.ZodString>;
|
|
@@ -108,4 +59,5 @@ export declare const decorateInputSchemaWithTelemetry: (inputSchema: unknown, co
|
|
|
108
59
|
telemetry?: unknown;
|
|
109
60
|
}>;
|
|
110
61
|
export declare const normalizeTelemetryArgs: (telemetry: TelemetryArgs | undefined) => TelemetryArgs | undefined;
|
|
111
|
-
export declare const
|
|
62
|
+
export declare const applyTelemetryFieldMap: (telemetry: TelemetryArgs | undefined, args: unknown, fieldMap: TelemetryFieldMap | undefined) => TelemetryArgs | undefined;
|
|
63
|
+
export declare const extractTelemetryArguments: (args: unknown, mode?: TelemetryMode) => ExtractedToolArguments;
|