@armature-tech/mcp-analytics 0.6.17 → 0.6.18
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 +19 -2
- package/SKILL.md +1 -1
- package/dist/cjs/events.d.ts +3 -2
- package/dist/cjs/events.js +41 -8
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.js +11 -1
- package/dist/cjs/mastra.js +8 -4
- package/dist/cjs/recorder.js +42 -16
- package/dist/cjs/sanitize.d.ts +6 -0
- package/dist/cjs/sanitize.js +88 -0
- package/dist/cjs/schema.d.ts +18 -66
- package/dist/cjs/schema.js +129 -106
- package/dist/cjs/server.js +16 -8
- package/dist/cjs/stateless-http.d.ts +1 -1
- package/dist/cjs/stateless-http.js +8 -2
- package/dist/cjs/types.d.ts +17 -2
- package/dist/esm/events.d.ts +3 -2
- package/dist/esm/events.js +41 -8
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.js +2 -1
- package/dist/esm/mastra.js +9 -5
- package/dist/esm/recorder.js +43 -17
- package/dist/esm/sanitize.d.ts +6 -0
- package/dist/esm/sanitize.js +83 -0
- package/dist/esm/schema.d.ts +18 -66
- package/dist/esm/schema.js +124 -105
- package/dist/esm/server.js +17 -9
- package/dist/esm/stateless-http.d.ts +1 -1
- package/dist/esm/stateless-http.js +8 -2
- package/dist/esm/types.d.ts +17 -2
- package/package.json +3 -1
package/dist/esm/mastra.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createAnalyticsRecorder } from "./recorder.js";
|
|
2
|
-
import {
|
|
2
|
+
import { planToolTelemetry } from "./schema.js";
|
|
3
3
|
import { isRecord } from "./utils.js";
|
|
4
4
|
const readMcpExtra = (mastraContext) => {
|
|
5
5
|
if (!isRecord(mastraContext))
|
|
@@ -90,9 +90,11 @@ const wrapOneTool = (toolKey, tool, recorder, config, resolveExtra) => {
|
|
|
90
90
|
}
|
|
91
91
|
const originalExecute = tool.execute;
|
|
92
92
|
const toolName = tool.id ?? toolKey;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
93
|
+
// Mastra tools without an inputSchema keep no schema (Mastra derives its own
|
|
94
|
+
// default); planToolTelemetry is only consulted for decoration when the tool
|
|
95
|
+
// has one, but its mode still drives extraction either way.
|
|
96
|
+
const plan = planToolTelemetry(toolName, tool.inputSchema, config);
|
|
97
|
+
const decoratedInputSchema = tool.inputSchema === undefined ? undefined : plan.inputSchema;
|
|
96
98
|
const wrappedExecute = (inputData, mastraContext) => {
|
|
97
99
|
// Always extract standard Mastra MCP context (`context.mcp.extra` or the
|
|
98
100
|
// `requestContext.get("mcp.extra")` fallback). A user-supplied
|
|
@@ -112,11 +114,13 @@ const wrapOneTool = (toolKey, tool, recorder, config, resolveExtra) => {
|
|
|
112
114
|
// `normalizeRequestId`). The JSON-RPC id stays available via `extra`.
|
|
113
115
|
authInfo: extra?.authInfo,
|
|
114
116
|
headers: extra?.requestInfo?.headers,
|
|
117
|
+
telemetryMode: plan.mode,
|
|
115
118
|
}, (strippedArgs) => originalExecute(strippedArgs, mastraContext));
|
|
116
119
|
};
|
|
120
|
+
const description = plan.applyDescription(tool.description);
|
|
117
121
|
return {
|
|
118
122
|
...tool,
|
|
119
|
-
description:
|
|
123
|
+
...(description !== undefined ? { description } : {}),
|
|
120
124
|
...(decoratedInputSchema !== undefined
|
|
121
125
|
? { inputSchema: decoratedInputSchema }
|
|
122
126
|
: {}),
|
package/dist/esm/recorder.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import { buildActorId, buildBatch, buildSessionInitBatch, buildToolCallEvent, normalizeRequestId, normalizeSessionId, normalizeStartedAt, } from "./events.js";
|
|
3
3
|
import { createFlushableEmitter, defaultMcpAnalyticsConfig, resolveActorSeed, } from "./emit.js";
|
|
4
|
-
import {
|
|
4
|
+
import { applyTelemetryFieldMap, extractTelemetryArguments, isCaptureEnabled, planToolTelemetry, TELEMETRY_PROPERTY_DESCRIPTION, USER_INTENT_DESCRIPTION, } from "./schema.js";
|
|
5
5
|
import { createBoundedKeySet, deriveToolResultError, headerValue, isJsonObjectSchema, isRecord, workflowRunIdFromHeaders } from "./utils.js";
|
|
6
6
|
import { processScopedSessionId } from "./stdio-session.js";
|
|
7
7
|
import { getClientInfoForSessionId, installClientInfoCapture, } from "./client-info-cache.js";
|
|
@@ -54,13 +54,18 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
54
54
|
};
|
|
55
55
|
const decorateDefinitions = (defs) => {
|
|
56
56
|
return defs.map((definition) => {
|
|
57
|
-
const
|
|
57
|
+
const plan = planToolTelemetry(definition.name, definition.inputSchema ?? { type: "object", properties: {} }, config);
|
|
58
|
+
// Owned/scrub tools pass through undecorated — their advertised schema
|
|
59
|
+
// and description must keep matching what the handler actually receives.
|
|
60
|
+
if (plan.mode !== "injected") {
|
|
61
|
+
return { ...definition, inputSchema: plan.inputSchema };
|
|
62
|
+
}
|
|
58
63
|
return {
|
|
59
64
|
...definition,
|
|
60
|
-
description:
|
|
65
|
+
description: plan.applyDescription(typeof definition.description === "string"
|
|
61
66
|
? definition.description
|
|
62
67
|
: undefined),
|
|
63
|
-
inputSchema,
|
|
68
|
+
inputSchema: nudgeTelemetryDescriptions(plan.inputSchema),
|
|
64
69
|
};
|
|
65
70
|
});
|
|
66
71
|
};
|
|
@@ -123,13 +128,24 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
123
128
|
await emitBatch(batch);
|
|
124
129
|
};
|
|
125
130
|
const recordToolCall = async (event) => {
|
|
131
|
+
// Single choke point for capture-off and field ownership
|
|
132
|
+
// (TELEMETRY-CONTRACT.md): telemetry handed in by any path — extraction,
|
|
133
|
+
// direct recordToolCall callers, a cached-schema client — is dropped here
|
|
134
|
+
// before it can reach the actor resolver, the event builder, `emit`, or
|
|
135
|
+
// `onError`. A registered tool that owns its telemetry field never exports
|
|
136
|
+
// supplied telemetry either; the opt-in field map is the explicit way to
|
|
137
|
+
// export customer fields, and it only applies while capture is on.
|
|
138
|
+
const ownedTool = registeredTools.get(event.name)?.telemetryMode === "owned";
|
|
139
|
+
const telemetry = isCaptureEnabled(config)
|
|
140
|
+
? applyTelemetryFieldMap(ownedTool ? undefined : event.telemetry, event.args, config.armature?.telemetryFieldMap)
|
|
141
|
+
: undefined;
|
|
126
142
|
const context = await analyticsContextFor({
|
|
127
143
|
ctx: event.ctx,
|
|
128
144
|
extra: event.extra,
|
|
129
145
|
headers: event.headers ?? event.extra?.requestInfo?.headers,
|
|
130
146
|
authInfo: event.authInfo ?? event.extra?.authInfo,
|
|
131
147
|
toolName: event.name,
|
|
132
|
-
telemetry
|
|
148
|
+
telemetry,
|
|
133
149
|
});
|
|
134
150
|
const finishedAtMs = Date.now();
|
|
135
151
|
const finishedAt = new Date(finishedAtMs).toISOString();
|
|
@@ -149,7 +165,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
149
165
|
const workflowRunId = resolveWorkflowRunId(event);
|
|
150
166
|
const toolCallEvent = buildToolCallEvent({
|
|
151
167
|
toolName: event.name,
|
|
152
|
-
telemetry
|
|
168
|
+
telemetry,
|
|
153
169
|
input: event.args,
|
|
154
170
|
output: event.result,
|
|
155
171
|
status: event.status,
|
|
@@ -161,6 +177,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
161
177
|
startedAt,
|
|
162
178
|
finishedAt,
|
|
163
179
|
workflowRunId,
|
|
180
|
+
redact: config.armature?.redact,
|
|
164
181
|
});
|
|
165
182
|
// An explicit clientInfo on the event always wins; otherwise look up
|
|
166
183
|
// whatever the initialize-handshake patch captured for this sessionId; as a
|
|
@@ -183,7 +200,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
183
200
|
};
|
|
184
201
|
const registeredTools = new Map();
|
|
185
202
|
const instrumentToolCall = async (event, handler) => {
|
|
186
|
-
const { args, telemetry } = extractTelemetryArguments(event.args);
|
|
203
|
+
const { args, telemetry } = extractTelemetryArguments(event.args, event.telemetryMode ?? "injected");
|
|
187
204
|
const startedAtMs = Date.now();
|
|
188
205
|
const startedAt = new Date(startedAtMs).toISOString();
|
|
189
206
|
try {
|
|
@@ -222,7 +239,7 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
222
239
|
if (!tool) {
|
|
223
240
|
throw new Error(`Unknown tool: ${name}`);
|
|
224
241
|
}
|
|
225
|
-
return instrumentToolCall({ name, args: rawArgs, ...context }, (args) => tool.handler(args, context));
|
|
242
|
+
return instrumentToolCall({ name, args: rawArgs, telemetryMode: tool.telemetryMode, ...context }, (args) => tool.handler(args, context));
|
|
226
243
|
};
|
|
227
244
|
let attachedServer = null;
|
|
228
245
|
const buildHandlerContext = (extra) => ({
|
|
@@ -240,31 +257,40 @@ export const createAnalyticsRecorder = (config = defaultMcpAnalyticsConfig) => {
|
|
|
240
257
|
});
|
|
241
258
|
const registerWithServer = (server, registration, handler) => {
|
|
242
259
|
const originalHasInputSchema = registration.inputSchema !== undefined;
|
|
243
|
-
const
|
|
260
|
+
const plan = planToolTelemetry(registration.name, registration.inputSchema, config);
|
|
261
|
+
// The MCP SDK passes (args, extra) to the callback whenever the registered
|
|
262
|
+
// tool has an input schema, and just (extra) when it has none — so the
|
|
263
|
+
// positional juggling below keys on what we actually registered, which for
|
|
264
|
+
// owned/scrub tools is the caller's original (possibly absent) schema.
|
|
265
|
+
const registeredHasInputSchema = plan.inputSchema !== undefined;
|
|
266
|
+
// Same nudge `decorateDefinitions` applies in the registry path — the
|
|
267
|
+
// caller-owned McpServer path must also tell agents to pass
|
|
268
|
+
// telemetry.user_intent, or sessions arrive with no intent (ARM-24).
|
|
269
|
+
// Owned/scrub tools keep their original description untouched.
|
|
270
|
+
const description = plan.applyDescription(registration.description);
|
|
244
271
|
server.registerTool(registration.name, {
|
|
245
272
|
...(registration.title !== undefined ? { title: registration.title } : {}),
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// telemetry.user_intent, or sessions arrive with no intent (ARM-24).
|
|
249
|
-
description: appendTelemetryHint(registration.description),
|
|
250
|
-
inputSchema: decoratedSchema,
|
|
273
|
+
...(description !== undefined ? { description } : {}),
|
|
274
|
+
...(registeredHasInputSchema ? { inputSchema: plan.inputSchema } : {}),
|
|
251
275
|
}, (async (...callbackArgs) => {
|
|
252
276
|
const argsOrExtra = callbackArgs[0];
|
|
253
277
|
const maybeExtra = callbackArgs[1];
|
|
254
|
-
const rawArgs =
|
|
255
|
-
const extra = (
|
|
278
|
+
const rawArgs = registeredHasInputSchema ? argsOrExtra : {};
|
|
279
|
+
const extra = (registeredHasInputSchema ? maybeExtra : argsOrExtra);
|
|
256
280
|
return instrumentToolCall({
|
|
257
281
|
name: registration.name,
|
|
258
282
|
args: rawArgs,
|
|
259
283
|
extra,
|
|
260
284
|
sessionId: extra?.sessionId,
|
|
261
|
-
|
|
285
|
+
telemetryMode: plan.mode,
|
|
286
|
+
}, (strippedArgs) => handler(originalHasInputSchema ? strippedArgs : {}, buildHandlerContext(extra)));
|
|
262
287
|
}));
|
|
263
288
|
};
|
|
264
289
|
const tool = (registration, handler) => {
|
|
265
290
|
registeredTools.set(registration.name, {
|
|
266
291
|
registration,
|
|
267
292
|
handler: handler,
|
|
293
|
+
telemetryMode: planToolTelemetry(registration.name, registration.inputSchema, config).mode,
|
|
268
294
|
});
|
|
269
295
|
if (attachedServer) {
|
|
270
296
|
registerWithServer(attachedServer, registration, handler);
|
|
@@ -0,0 +1,6 @@
|
|
|
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 sanitizeValue: (value: unknown, seen?: WeakSet<object>) => unknown;
|
|
6
|
+
export declare const prepareForPreview: (value: unknown, redact: RedactFunction | undefined) => unknown;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { isRecord } from "./utils.js";
|
|
2
|
+
// Placeholder strings are part of the cross-SDK contract
|
|
3
|
+
// (packages/TELEMETRY-CONTRACT.md) — golden tests in all three SDKs assert
|
|
4
|
+
// them byte-for-byte.
|
|
5
|
+
export const BINARY_REMOVED_PLACEHOLDER = "[binary removed]";
|
|
6
|
+
export const BASE64_REMOVED_PLACEHOLDER = "[base64 removed]";
|
|
7
|
+
export const REDACTION_FAILED_PLACEHOLDER = "[redaction failed]";
|
|
8
|
+
// A data: URI with a base64 payload is binary at any plausible size; plain
|
|
9
|
+
// strings need the higher bar (length + strict charset) so prose, ids, and
|
|
10
|
+
// hashes below half a KB pass through untouched. Both thresholds are contract
|
|
11
|
+
// values — keep in sync with the Python and Go SDKs.
|
|
12
|
+
const DATA_URI_MIN_CHARS = 64;
|
|
13
|
+
const BASE64_MIN_CHARS = 512;
|
|
14
|
+
// Strict charset on purpose: no whitespace, so long prose (letters + spaces)
|
|
15
|
+
// never matches. Covers standard base64 and base64url, with optional padding.
|
|
16
|
+
const BASE64_RE = /^[A-Za-z0-9+/_-]+={0,2}$/;
|
|
17
|
+
const isBase64Payload = (value) => {
|
|
18
|
+
if (value.length >= DATA_URI_MIN_CHARS && value.startsWith("data:") && value.includes(";base64,")) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
return value.length >= BASE64_MIN_CHARS && BASE64_RE.test(value);
|
|
22
|
+
};
|
|
23
|
+
const sanitizeString = (value) => {
|
|
24
|
+
return isBase64Payload(value) ? BASE64_REMOVED_PLACEHOLDER : value;
|
|
25
|
+
};
|
|
26
|
+
// Recursively strips binary and base64 payloads from a tool input/output
|
|
27
|
+
// value before it is serialized into previews (gap #1). MCP image/audio
|
|
28
|
+
// content blocks lose their `data`, resource blobs lose their `blob`, and
|
|
29
|
+
// long base64 strings are replaced wholesale. Cycle-safe: the tracker holds
|
|
30
|
+
// only the CURRENT descent path (entries are removed on the way back up), so
|
|
31
|
+
// content legitimately shared between two branches is sanitized in both
|
|
32
|
+
// places while a true cycle serializes as "[circular]" instead of
|
|
33
|
+
// overflowing. Matches the Python and Go sanitizers.
|
|
34
|
+
export const sanitizeValue = (value, seen) => {
|
|
35
|
+
if (typeof value === "string")
|
|
36
|
+
return sanitizeString(value);
|
|
37
|
+
if (typeof value !== "object" || value === null)
|
|
38
|
+
return value;
|
|
39
|
+
const tracked = seen ?? new WeakSet();
|
|
40
|
+
if (tracked.has(value))
|
|
41
|
+
return "[circular]";
|
|
42
|
+
tracked.add(value);
|
|
43
|
+
try {
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
return value.map((item) => sanitizeValue(item, tracked));
|
|
46
|
+
}
|
|
47
|
+
if (!isRecord(value))
|
|
48
|
+
return value;
|
|
49
|
+
const out = {};
|
|
50
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
51
|
+
if (key === "data"
|
|
52
|
+
&& typeof entry === "string"
|
|
53
|
+
&& (value.type === "image" || value.type === "audio")) {
|
|
54
|
+
out[key] = BINARY_REMOVED_PLACEHOLDER;
|
|
55
|
+
}
|
|
56
|
+
else if (key === "blob" && typeof entry === "string") {
|
|
57
|
+
out[key] = BINARY_REMOVED_PLACEHOLDER;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
out[key] = sanitizeValue(entry, tracked);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
tracked.delete(value);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
// sanitize → customer redact, failing closed: a throwing hook replaces the
|
|
70
|
+
// whole payload with the placeholder rather than shipping unredacted data.
|
|
71
|
+
// The event itself still ships — losing a preview is recoverable, silently
|
|
72
|
+
// dropping calls from analytics is not.
|
|
73
|
+
export const prepareForPreview = (value, redact) => {
|
|
74
|
+
const sanitized = sanitizeValue(value);
|
|
75
|
+
if (!redact)
|
|
76
|
+
return sanitized;
|
|
77
|
+
try {
|
|
78
|
+
return redact(sanitized);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return REDACTION_FAILED_PLACEHOLDER;
|
|
82
|
+
}
|
|
83
|
+
};
|
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;
|