@inferevents/mcp 0.5.3 → 1.0.2
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/api-client.d.ts +141 -59
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +59 -69
- package/dist/api-client.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +19 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +0 -0
- package/dist/remote.d.ts +1 -1
- package/dist/remote.d.ts.map +1 -1
- package/dist/remote.js +5 -0
- package/dist/remote.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +90 -186
- package/dist/server.js.map +1 -1
- package/dist/tool-result.d.ts +34 -0
- package/dist/tool-result.d.ts.map +1 -0
- package/dist/tool-result.js +30 -0
- package/dist/tool-result.js.map +1 -0
- package/dist/tools/annotate-span.d.ts +7 -0
- package/dist/tools/annotate-span.d.ts.map +1 -0
- package/dist/tools/annotate-span.js +16 -0
- package/dist/tools/annotate-span.js.map +1 -0
- package/dist/tools/annotate-trace.d.ts +7 -0
- package/dist/tools/annotate-trace.d.ts.map +1 -0
- package/dist/tools/annotate-trace.js +16 -0
- package/dist/tools/annotate-trace.js.map +1 -0
- package/dist/tools/create-project.d.ts.map +1 -1
- package/dist/tools/create-project.js +39 -7
- package/dist/tools/create-project.js.map +1 -1
- package/dist/tools/deprecated-tools.d.ts +16 -0
- package/dist/tools/deprecated-tools.d.ts.map +1 -0
- package/dist/tools/deprecated-tools.js +78 -0
- package/dist/tools/deprecated-tools.js.map +1 -0
- package/dist/tools/deprecated.d.ts +25 -0
- package/dist/tools/deprecated.d.ts.map +1 -0
- package/dist/tools/deprecated.js +42 -0
- package/dist/tools/deprecated.js.map +1 -0
- package/dist/tools/get-cost-stats.d.ts +18 -0
- package/dist/tools/get-cost-stats.d.ts.map +1 -0
- package/dist/tools/get-cost-stats.js +88 -0
- package/dist/tools/get-cost-stats.js.map +1 -0
- package/dist/tools/get-error-spans.d.ts +8 -0
- package/dist/tools/get-error-spans.d.ts.map +1 -0
- package/dist/tools/get-error-spans.js +25 -0
- package/dist/tools/get-error-spans.js.map +1 -0
- package/dist/tools/get-insights.d.ts.map +1 -1
- package/dist/tools/get-insights.js +74 -109
- package/dist/tools/get-insights.js.map +1 -1
- package/dist/tools/get-latency-stats.d.ts +7 -0
- package/dist/tools/get-latency-stats.d.ts.map +1 -0
- package/dist/tools/get-latency-stats.js +28 -0
- package/dist/tools/get-latency-stats.js.map +1 -0
- package/dist/tools/get-project-summary.d.ts +0 -39
- package/dist/tools/get-project-summary.d.ts.map +1 -1
- package/dist/tools/get-project-summary.js +101 -79
- package/dist/tools/get-project-summary.js.map +1 -1
- package/dist/tools/get-span.d.ts +6 -0
- package/dist/tools/get-span.d.ts.map +1 -0
- package/dist/tools/get-span.js +30 -0
- package/dist/tools/get-span.js.map +1 -0
- package/dist/tools/get-token-usage.d.ts +7 -0
- package/dist/tools/get-token-usage.d.ts.map +1 -0
- package/dist/tools/get-token-usage.js +25 -0
- package/dist/tools/get-token-usage.js.map +1 -0
- package/dist/tools/get-trace.d.ts +6 -0
- package/dist/tools/get-trace.d.ts.map +1 -0
- package/dist/tools/get-trace.js +28 -0
- package/dist/tools/get-trace.js.map +1 -0
- package/dist/tools/list-spans.d.ts +15 -0
- package/dist/tools/list-spans.d.ts.map +1 -0
- package/dist/tools/list-spans.js +19 -0
- package/dist/tools/list-spans.js.map +1 -0
- package/dist/tools/schemas.d.ts +45 -0
- package/dist/tools/schemas.d.ts.map +1 -0
- package/dist/tools/schemas.js +86 -0
- package/dist/tools/schemas.js.map +1 -0
- package/dist/tools/switch-project.d.ts.map +1 -1
- package/dist/tools/switch-project.js +56 -5
- package/dist/tools/switch-project.js.map +1 -1
- package/package.json +2 -2
- package/dist/tools/annotate-thread.d.ts +0 -11
- package/dist/tools/annotate-thread.d.ts.map +0 -1
- package/dist/tools/annotate-thread.js +0 -23
- package/dist/tools/annotate-thread.js.map +0 -1
- package/dist/tools/get-event-counts.d.ts +0 -23
- package/dist/tools/get-event-counts.d.ts.map +0 -1
- package/dist/tools/get-event-counts.js +0 -50
- package/dist/tools/get-event-counts.js.map +0 -1
- package/dist/tools/get-ontology.d.ts +0 -9
- package/dist/tools/get-ontology.d.ts.map +0 -1
- package/dist/tools/get-ontology.js +0 -62
- package/dist/tools/get-ontology.js.map +0 -1
- package/dist/tools/get-retention.d.ts +0 -11
- package/dist/tools/get-retention.d.ts.map +0 -1
- package/dist/tools/get-retention.js +0 -87
- package/dist/tools/get-retention.js.map +0 -1
- package/dist/tools/get-top-events.d.ts +0 -11
- package/dist/tools/get-top-events.d.ts.map +0 -1
- package/dist/tools/get-top-events.js +0 -74
- package/dist/tools/get-top-events.js.map +0 -1
- package/dist/tools/get-user-journey.d.ts +0 -10
- package/dist/tools/get-user-journey.d.ts.map +0 -1
- package/dist/tools/get-user-journey.js +0 -143
- package/dist/tools/get-user-journey.js.map +0 -1
- package/dist/tools/update-ontology.d.ts +0 -37
- package/dist/tools/update-ontology.d.ts.map +0 -1
- package/dist/tools/update-ontology.js +0 -51
- package/dist/tools/update-ontology.js.map +0 -1
|
@@ -1,43 +1,4 @@
|
|
|
1
1
|
import type { ApiClient } from "../api-client.js";
|
|
2
2
|
export declare const getProjectSummarySchema: {};
|
|
3
|
-
interface KeyMetrics {
|
|
4
|
-
total_events_30d: number;
|
|
5
|
-
unique_users_30d: number;
|
|
6
|
-
daily_active_avg: number;
|
|
7
|
-
error_rate_pct: number;
|
|
8
|
-
events_trend_pct: number;
|
|
9
|
-
users_trend_pct: number;
|
|
10
|
-
health_score: number;
|
|
11
|
-
active_issues: number;
|
|
12
|
-
}
|
|
13
|
-
interface EventEntry {
|
|
14
|
-
event_name: string;
|
|
15
|
-
category: string | null;
|
|
16
|
-
count_30d: number;
|
|
17
|
-
unique_users_30d: number;
|
|
18
|
-
trend: "up" | "down" | "stable";
|
|
19
|
-
}
|
|
20
|
-
interface FunnelStep {
|
|
21
|
-
from_event: string;
|
|
22
|
-
to_event: string;
|
|
23
|
-
conversion_pct: number;
|
|
24
|
-
trend: "up" | "down" | "stable";
|
|
25
|
-
}
|
|
26
|
-
interface ThreadEntry {
|
|
27
|
-
id: string;
|
|
28
|
-
title: string;
|
|
29
|
-
severity: string;
|
|
30
|
-
day_count: number;
|
|
31
|
-
insight_count: number;
|
|
32
|
-
latest_annotation: string | null;
|
|
33
|
-
}
|
|
34
|
-
interface ProjectSections {
|
|
35
|
-
key_metrics?: KeyMetrics;
|
|
36
|
-
event_catalog?: EventEntry[];
|
|
37
|
-
funnel_health?: FunnelStep[];
|
|
38
|
-
active_threads?: ThreadEntry[];
|
|
39
|
-
}
|
|
40
|
-
export declare function formatProjectSummary(sections: ProjectSections): string;
|
|
41
3
|
export declare function handleGetProjectSummary(client: ApiClient): Promise<string>;
|
|
42
|
-
export {};
|
|
43
4
|
//# sourceMappingURL=get-project-summary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-project-summary.d.ts","sourceRoot":"","sources":["../../src/tools/get-project-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"get-project-summary.d.ts","sourceRoot":"","sources":["../../src/tools/get-project-summary.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,eAAO,MAAM,uBAAuB,IAAK,CAAC;AAiE1C,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CA8EhF"}
|
|
@@ -1,94 +1,116 @@
|
|
|
1
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
1
2
|
export const getProjectSummarySchema = {};
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
function renderLlmObsSections(sections, lines) {
|
|
4
|
+
let rendered = false;
|
|
5
|
+
const dist = sections.model_distribution;
|
|
6
|
+
if (dist && Object.keys(dist).length > 0) {
|
|
7
|
+
lines.push("Model distribution (last 7d)");
|
|
8
|
+
const sorted = Object.entries(dist).sort((a, b) => b[1] - a[1]);
|
|
9
|
+
for (const [model, share] of sorted) {
|
|
10
|
+
lines.push(` ${(share * 100).toFixed(1).padStart(5)}% ${model}`);
|
|
11
|
+
}
|
|
12
|
+
lines.push("");
|
|
13
|
+
rendered = true;
|
|
12
14
|
}
|
|
13
|
-
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
chart.push(` Total events: ${km.total_events_30d.toLocaleString()} (${trend(km.events_trend_pct)} vs prior 30d)`);
|
|
18
|
-
chart.push(` Unique users: ${km.unique_users_30d.toLocaleString()} (${trend(km.users_trend_pct)})`);
|
|
19
|
-
chart.push(` Daily active: ~${km.daily_active_avg.toLocaleString()}`);
|
|
20
|
-
chart.push(` Error rate: ${km.error_rate_pct}%`);
|
|
21
|
-
chart.push("");
|
|
15
|
+
const spend = sections.weekly_spend_usd;
|
|
16
|
+
if (typeof spend === "number") {
|
|
17
|
+
lines.push(`Weekly spend: $${spend.toFixed(2)}`);
|
|
18
|
+
rendered = true;
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
for (const [cat, events] of Object.entries(grouped)) {
|
|
37
|
-
chart.push(` ${cat}: ${events.join(", ")}`);
|
|
20
|
+
const errorRate = sections.error_rate_7d;
|
|
21
|
+
if (typeof errorRate === "number") {
|
|
22
|
+
lines.push(`Error rate (7d): ${(errorRate * 100).toFixed(1)}%`);
|
|
23
|
+
rendered = true;
|
|
24
|
+
}
|
|
25
|
+
if (typeof spend === "number" || typeof errorRate === "number")
|
|
26
|
+
lines.push("");
|
|
27
|
+
const threads = sections.anomaly_threads;
|
|
28
|
+
if (threads && threads.length > 0) {
|
|
29
|
+
lines.push(`Active anomaly threads: ${threads.length}`);
|
|
30
|
+
for (const t of threads) {
|
|
31
|
+
lines.push(` • ${t.title} — day ${t.day_count} (trace_id=${t.thread_id})`);
|
|
38
32
|
}
|
|
39
|
-
|
|
33
|
+
lines.push("");
|
|
34
|
+
rendered = true;
|
|
40
35
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
return rendered;
|
|
37
|
+
}
|
|
38
|
+
function renderLegacySections(sections, lines) {
|
|
39
|
+
const events = sections.event_catalog;
|
|
40
|
+
if (events && events.length > 0) {
|
|
41
|
+
lines.push("Event catalog (legacy)");
|
|
42
|
+
for (const e of events.slice(0, 10)) {
|
|
43
|
+
lines.push(` ${e.count.toString().padStart(8)} ${e.name}`);
|
|
48
44
|
}
|
|
49
|
-
|
|
45
|
+
lines.push("");
|
|
50
46
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
critical: "🔴",
|
|
57
|
-
notable: "🟡",
|
|
58
|
-
informational: "🔵",
|
|
59
|
-
};
|
|
60
|
-
for (const t of threads) {
|
|
61
|
-
const dot = severityDot[t.severity] ?? "⚪";
|
|
62
|
-
const dayLabel = t.day_count > 1 ? ` (${t.day_count} days)` : "";
|
|
63
|
-
chart.push(` ${dot} ${t.title}${dayLabel}`);
|
|
64
|
-
if (t.latest_annotation) {
|
|
65
|
-
chart.push(` ↳ ${t.latest_annotation}`);
|
|
66
|
-
}
|
|
47
|
+
const funnel = sections.funnel_performance;
|
|
48
|
+
if (funnel) {
|
|
49
|
+
lines.push("Funnel performance (legacy)");
|
|
50
|
+
for (const [stage, rate] of Object.entries(funnel)) {
|
|
51
|
+
lines.push(` ${stage.padEnd(16)} ${(rate * 100).toFixed(1)}%`);
|
|
67
52
|
}
|
|
68
|
-
|
|
53
|
+
lines.push("");
|
|
69
54
|
}
|
|
70
|
-
return chart.join("\n");
|
|
71
55
|
}
|
|
72
56
|
export async function handleGetProjectSummary(client) {
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
const result = await client.getProjectSummary();
|
|
58
|
+
const warnings = [];
|
|
59
|
+
const caveats = [];
|
|
60
|
+
if (result.compiled_at === null || !result.sections || Object.keys(result.sections).length === 0) {
|
|
61
|
+
warnings.push("Project summary has not been compiled yet. The wiki-compiler cron runs hourly; wait a bit and try again.");
|
|
62
|
+
return toolResponseText(wrapResult({
|
|
63
|
+
primary: { rendered_text: "", compiled_at: null },
|
|
64
|
+
source: "project_summary",
|
|
65
|
+
warnings,
|
|
66
|
+
caveats,
|
|
67
|
+
}));
|
|
76
68
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"Present this project summary to the user exactly as-is:",
|
|
83
|
-
"",
|
|
84
|
-
"```",
|
|
85
|
-
body,
|
|
86
|
-
"```",
|
|
87
|
-
"",
|
|
88
|
-
`Last compiled: ${data.compiled_at}`,
|
|
69
|
+
const sections = result.sections;
|
|
70
|
+
const lines = [
|
|
71
|
+
`Project summary`,
|
|
72
|
+
`Compiled: ${result.compiled_at}`,
|
|
73
|
+
"─".repeat(60),
|
|
89
74
|
"",
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
75
|
+
];
|
|
76
|
+
const renderedLlmObs = renderLlmObsSections(sections, lines);
|
|
77
|
+
if (!renderedLlmObs) {
|
|
78
|
+
caveats.push("Summary is in the legacy web-analytics shape. Phase 5 wiki-compiler rewrite will populate LLM-obs sections (model_distribution, weekly_spend_usd, error_rate_7d, anomaly_threads).");
|
|
79
|
+
}
|
|
80
|
+
// Phase 5 wiki-compiler emits `spend_caveat` when any model lacks pricing.
|
|
81
|
+
// Shape: { partial, missing_pricing_models[], pricing_source_version, message }.
|
|
82
|
+
// Prefer the pre-formatted `message`; fall back to reconstructing from
|
|
83
|
+
// `missing_pricing_models[]`; defensive string-shape branch for any future
|
|
84
|
+
// renderer-to-compiler drift.
|
|
85
|
+
const spendCaveat = sections.spend_caveat;
|
|
86
|
+
if (spendCaveat !== undefined && spendCaveat !== null) {
|
|
87
|
+
if (typeof spendCaveat === "string" && spendCaveat.length > 0) {
|
|
88
|
+
caveats.push(spendCaveat);
|
|
89
|
+
}
|
|
90
|
+
else if (typeof spendCaveat === "object") {
|
|
91
|
+
const cast = spendCaveat;
|
|
92
|
+
if (typeof cast.message === "string" && cast.message.length > 0) {
|
|
93
|
+
caveats.push(cast.message);
|
|
94
|
+
}
|
|
95
|
+
else if (Array.isArray(cast.missing_pricing_models) && cast.missing_pricing_models.length > 0) {
|
|
96
|
+
const list = cast.missing_pricing_models.join(", ");
|
|
97
|
+
const suffix = cast.pricing_source_version
|
|
98
|
+
? ` (pricing table version ${cast.pricing_source_version})`
|
|
99
|
+
: "";
|
|
100
|
+
caveats.push(`Weekly spend excludes models without pricing: ${list}. Update packages/shared/src/pricing.ts.${suffix}`);
|
|
101
|
+
}
|
|
102
|
+
// Empty-array with no message → silent no-op (noise suppression).
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
renderLegacySections(sections, lines);
|
|
106
|
+
return toolResponseText(wrapResult({
|
|
107
|
+
primary: {
|
|
108
|
+
rendered_text: lines.join("\n"),
|
|
109
|
+
compiled_at: result.compiled_at,
|
|
110
|
+
},
|
|
111
|
+
source: "project_summary",
|
|
112
|
+
warnings,
|
|
113
|
+
caveats,
|
|
114
|
+
}));
|
|
93
115
|
}
|
|
94
116
|
//# sourceMappingURL=get-project-summary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-project-summary.js","sourceRoot":"","sources":["../../src/tools/get-project-summary.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-project-summary.js","sourceRoot":"","sources":["../../src/tools/get-project-summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEjE,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAI1C,SAAS,oBAAoB,CAAC,QAAkB,EAAE,KAAe;IAC/D,IAAI,QAAQ,GAAG,KAAK,CAAC;IAErB,MAAM,IAAI,GAAG,QAAQ,CAAC,kBAAwD,CAAC;IAC/E,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzC,KAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;QAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChE,KAAK,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,MAAM,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,gBAAgB,CAAC;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,KAAK,CAAC,IAAI,CAAC,kBAAkB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACjD,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M,GAAG,IAAI,CAAC,sBAAsB;oBACxC,CAAC,CAAC,2BAA2B,IAAI,CAAC,sBAAsB,GAAG;oBAC3D,CAAC,CAAC,EAAE,CAAC;gBACP,OAAO,CAAC,IAAI,CACV,iDAAiD,IAAI,2CAA2C,MAAM,EAAE,CACzG,CAAC;YACJ,CAAC;YACD,kEAAkE;QACpE,CAAC;IACH,CAAC;IAED,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAEtC,OAAO,gBAAgB,CACrB,UAAU,CAAC;QACT,OAAO,EAAE;YACP,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACD,MAAM,EAAE,iBAAiB;QACzB,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-span.d.ts","sourceRoot":"","sources":["../../src/tools/get-span.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,aAAa,CACjC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,MAAM,CAAC,CA2CjB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
2
|
+
export async function handleGetSpan(client, params) {
|
|
3
|
+
const result = await client.getSpan(params.span_id);
|
|
4
|
+
const span = result.span;
|
|
5
|
+
const attributes = span.attributes ?? {};
|
|
6
|
+
const warnings = [];
|
|
7
|
+
const caveats = [];
|
|
8
|
+
const statusCode = span.status_code;
|
|
9
|
+
if (statusCode >= 400) {
|
|
10
|
+
const errorType = span.error_type;
|
|
11
|
+
warnings.push(`Span returned HTTP status ${statusCode}${errorType ? ` (${errorType})` : ""}.`);
|
|
12
|
+
}
|
|
13
|
+
if (attributes.stream_truncated === true) {
|
|
14
|
+
warnings.push("Stream was truncated mid-response — content and token counts are incomplete.");
|
|
15
|
+
}
|
|
16
|
+
const usageEstimated = attributes["gen_ai.usage.estimated"];
|
|
17
|
+
if (usageEstimated === true) {
|
|
18
|
+
warnings.push("Token counts are estimated (upstream did not emit authoritative usage). Treat as approximate.");
|
|
19
|
+
}
|
|
20
|
+
if (span.body_stored === false) {
|
|
21
|
+
caveats.push("Messages redacted at ingest (x-infer-redact: true). Metadata and token counts are still available.");
|
|
22
|
+
}
|
|
23
|
+
return toolResponseText(wrapResult({
|
|
24
|
+
primary: result,
|
|
25
|
+
source: "spans",
|
|
26
|
+
warnings,
|
|
27
|
+
caveats,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=get-span.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-span.js","sourceRoot":"","sources":["../../src/tools/get-span.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMjE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAiB,EACjB,MAAqB;IAErB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,IAA+B,CAAC;IACpD,MAAM,UAAU,GAAI,IAAI,CAAC,UAA6C,IAAI,EAAE,CAAC;IAE7E,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,MAAM,UAAU,GAAG,IAAI,CAAC,WAAqB,CAAC;IAC9C,IAAI,UAAU,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,SAAS,GAAG,IAAI,CAAC,UAA2B,CAAC;QACnD,QAAQ,CAAC,IAAI,CACX,6BAA6B,UAAU,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAChF,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,gBAAgB,KAAK,IAAI,EAAE,CAAC;QACzC,QAAQ,CAAC,IAAI,CACX,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAI,UAAsC,CAAC,wBAAwB,CAAC,CAAC;IACzF,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;QAC5B,QAAQ,CAAC,IAAI,CACX,+FAA+F,CAChG,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;QAC/B,OAAO,CAAC,IAAI,CACV,oGAAoG,CACrG,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CACrB,UAAU,CAAC;QACT,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,OAAO;QACf,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ApiClient } from "../api-client.js";
|
|
2
|
+
export interface GetTokenUsageParams {
|
|
3
|
+
dimension: "model" | "user" | "session" | "feature";
|
|
4
|
+
time_window: "1h" | "6h" | "24h" | "7d" | "30d";
|
|
5
|
+
}
|
|
6
|
+
export declare function handleGetTokenUsage(client: ApiClient, params: GetTokenUsageParams): Promise<string>;
|
|
7
|
+
//# sourceMappingURL=get-token-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-token-usage.d.ts","sourceRoot":"","sources":["../../src/tools/get-token-usage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACpD,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;CACjD;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,MAAM,CAAC,CA8BjB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
2
|
+
export async function handleGetTokenUsage(client, params) {
|
|
3
|
+
const result = await client.getTokenUsage(params);
|
|
4
|
+
const warnings = [];
|
|
5
|
+
const caveats = [
|
|
6
|
+
"Token counts sum gen_ai_usage_input_tokens + gen_ai_usage_output_tokens per span.",
|
|
7
|
+
"Rows with NULL token counts contribute 0 to their group total.",
|
|
8
|
+
];
|
|
9
|
+
if (result.groups.length === 0) {
|
|
10
|
+
warnings.push(`No token data for dimension=${params.dimension} over the last ${params.time_window}.`);
|
|
11
|
+
}
|
|
12
|
+
for (const g of result.groups) {
|
|
13
|
+
if (g.estimated_fraction > 0) {
|
|
14
|
+
const pct = Math.round(g.estimated_fraction * 100);
|
|
15
|
+
warnings.push(`${params.dimension}="${g.key}" — ${pct}% of spans have tiktoken-estimated token counts (upstream did not emit authoritative usage). Totals are approximate.`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return toolResponseText(wrapResult({
|
|
19
|
+
primary: result,
|
|
20
|
+
source: "spans",
|
|
21
|
+
warnings,
|
|
22
|
+
caveats,
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=get-token-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-token-usage.js","sourceRoot":"","sources":["../../src/tools/get-token-usage.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAOjE,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAiB,EACjB,MAA2B;IAE3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAElD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa;QACxB,mFAAmF;QACnF,gEAAgE;KACjE,CAAC;IAEF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,+BAA+B,MAAM,CAAC,SAAS,kBAAkB,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC;IACxG,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC,CAAC,kBAAkB,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC;YACnD,QAAQ,CAAC,IAAI,CACX,GAAG,MAAM,CAAC,SAAS,KAAK,CAAC,CAAC,GAAG,OAAO,GAAG,sHAAsH,CAC9J,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CACrB,UAAU,CAAC;QACT,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,OAAO;QACf,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trace.d.ts","sourceRoot":"","sources":["../../src/tools/get-trace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CAsCjB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
2
|
+
export async function handleGetTrace(client, params) {
|
|
3
|
+
const trace = await client.getTrace(params.trace_id);
|
|
4
|
+
const warnings = [];
|
|
5
|
+
const caveats = [
|
|
6
|
+
"Token-estimated flag (gen_ai.usage.estimated) is NOT included in this projection. Call get_span(<span_id>) for full attributes.",
|
|
7
|
+
];
|
|
8
|
+
const truncatedCount = trace.spans.filter((s) => s.stream_truncated).length;
|
|
9
|
+
if (truncatedCount > 0) {
|
|
10
|
+
warnings.push(`${truncatedCount} span(s) in this trace were stream-truncated — token counts and content may be incomplete.`);
|
|
11
|
+
}
|
|
12
|
+
const errorCount = trace.spans.filter((s) => s.status_code >= 400).length;
|
|
13
|
+
if (errorCount > 0) {
|
|
14
|
+
warnings.push(`${errorCount} span(s) in this trace returned HTTP >= 400 — call get_span for error details.`);
|
|
15
|
+
}
|
|
16
|
+
const rootCount = trace.spans.filter((s) => s.depth === 0).length;
|
|
17
|
+
if (rootCount > 1) {
|
|
18
|
+
warnings.push(`This trace has ${rootCount} unconnected roots — likely orphaned spans. ` +
|
|
19
|
+
`root_span_id reports only the first; inspect spans[] for the full set.`);
|
|
20
|
+
}
|
|
21
|
+
return toolResponseText(wrapResult({
|
|
22
|
+
primary: trace,
|
|
23
|
+
source: "spans",
|
|
24
|
+
warnings,
|
|
25
|
+
caveats,
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=get-trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-trace.js","sourceRoot":"","sources":["../../src/tools/get-trace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAMjE,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,MAAsB;IAEtB,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAErD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa;QACxB,iIAAiI;KAClI,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC;IAC5E,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QACvB,QAAQ,CAAC,IAAI,CACX,GAAG,cAAc,4FAA4F,CAC9G,CAAC;IACJ,CAAC;IAED,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1E,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACnB,QAAQ,CAAC,IAAI,CACX,GAAG,UAAU,gFAAgF,CAC9F,CAAC;IACJ,CAAC;IAED,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;IAClE,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;QAClB,QAAQ,CAAC,IAAI,CACX,kBAAkB,SAAS,8CAA8C;YACvE,wEAAwE,CAC3E,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CACrB,UAAU,CAAC;QACT,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,OAAO;QACf,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ApiClient } from "../api-client.js";
|
|
2
|
+
export interface ListSpansParams {
|
|
3
|
+
model?: string;
|
|
4
|
+
user_id?: string;
|
|
5
|
+
session_id?: string;
|
|
6
|
+
time_window?: "1h" | "6h" | "24h" | "7d" | "30d";
|
|
7
|
+
tags?: string[];
|
|
8
|
+
min_duration_ms?: number;
|
|
9
|
+
status_min?: number;
|
|
10
|
+
status_max?: number;
|
|
11
|
+
cursor?: string;
|
|
12
|
+
limit?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare function handleListSpans(client: ApiClient, params: ListSpansParams): Promise<string>;
|
|
15
|
+
//# sourceMappingURL=list-spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-spans.d.ts","sourceRoot":"","sources":["../../src/tools/list-spans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IACjD,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE,eAAe,GACtB,OAAO,CAAC,MAAM,CAAC,CA0BjB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { wrapResult, toolResponseText } from "../tool-result.js";
|
|
2
|
+
export async function handleListSpans(client, params) {
|
|
3
|
+
const response = await client.listSpans(params);
|
|
4
|
+
const warnings = [];
|
|
5
|
+
const caveats = [];
|
|
6
|
+
if (response.spans.length === 0) {
|
|
7
|
+
warnings.push("No spans matched these filters. Try widening the time_window or removing filters.");
|
|
8
|
+
}
|
|
9
|
+
if (response.next_cursor !== null) {
|
|
10
|
+
caveats.push(`More results available — pass cursor="${response.next_cursor}" to continue pagination.`);
|
|
11
|
+
}
|
|
12
|
+
return toolResponseText(wrapResult({
|
|
13
|
+
primary: response,
|
|
14
|
+
source: "spans",
|
|
15
|
+
warnings,
|
|
16
|
+
caveats,
|
|
17
|
+
}));
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=list-spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-spans.js","sourceRoot":"","sources":["../../src/tools/list-spans.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAejE,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAAiB,EACjB,MAAuB;IAEvB,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAEhD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,QAAQ,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,QAAQ,CAAC,IAAI,CACX,mFAAmF,CACpF,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QAClC,OAAO,CAAC,IAAI,CACV,yCAAyC,QAAQ,CAAC,WAAW,2BAA2B,CACzF,CAAC;IACJ,CAAC;IAED,OAAO,gBAAgB,CACrB,UAAU,CAAC;QACT,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE,OAAO;QACf,QAAQ;QACR,OAAO;KACR,CAAC,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const listSpansInputSchema: {
|
|
3
|
+
model: z.ZodOptional<z.ZodString>;
|
|
4
|
+
user_id: z.ZodOptional<z.ZodString>;
|
|
5
|
+
session_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
time_window: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "7d", "30d"]>>;
|
|
7
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
8
|
+
min_duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
status_min: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
status_max: z.ZodOptional<z.ZodNumber>;
|
|
11
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
12
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
};
|
|
14
|
+
export declare const getTraceInputSchema: {
|
|
15
|
+
trace_id: z.ZodString;
|
|
16
|
+
};
|
|
17
|
+
export declare const getSpanInputSchema: {
|
|
18
|
+
span_id: z.ZodString;
|
|
19
|
+
};
|
|
20
|
+
export declare const getLatencyStatsInputSchema: {
|
|
21
|
+
dimension: z.ZodEnum<["model", "user", "session", "feature"]>;
|
|
22
|
+
time_window: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "7d", "30d"]>>;
|
|
23
|
+
};
|
|
24
|
+
export declare const getTokenUsageInputSchema: {
|
|
25
|
+
dimension: z.ZodEnum<["model", "user", "session", "feature"]>;
|
|
26
|
+
time_window: z.ZodEnum<["1h", "6h", "24h", "7d", "30d"]>;
|
|
27
|
+
};
|
|
28
|
+
export declare const getCostStatsInputSchema: {
|
|
29
|
+
dimension: z.ZodEnum<["model", "user", "session", "feature"]>;
|
|
30
|
+
time_window: z.ZodEnum<["1h", "6h", "24h", "7d", "30d"]>;
|
|
31
|
+
};
|
|
32
|
+
export declare const getErrorSpansInputSchema: {
|
|
33
|
+
time_window: z.ZodOptional<z.ZodEnum<["1h", "6h", "24h", "7d", "30d"]>>;
|
|
34
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
35
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
36
|
+
};
|
|
37
|
+
export declare const annotateSpanInputSchema: {
|
|
38
|
+
span_id: z.ZodString;
|
|
39
|
+
content: z.ZodString;
|
|
40
|
+
};
|
|
41
|
+
export declare const annotateTraceInputSchema: {
|
|
42
|
+
trace_id: z.ZodString;
|
|
43
|
+
content: z.ZodString;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkCxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;CAqBhC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAE/B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAE9B,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;CAGtC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;CAGnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;CAIpC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;CASnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;CAUpC,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Shared Zod schemas for every new Phase 4 tool. One file so:
|
|
4
|
+
* - Handlers and tests import the same shape.
|
|
5
|
+
* - Code reviewers can audit §7.4 (no project_id) in a single place.
|
|
6
|
+
* - Future tools add to this file before creating their handler.
|
|
7
|
+
*
|
|
8
|
+
* Each export is a bare-keys object (not a zod.object(...)) because the MCP
|
|
9
|
+
* SDK's `server.tool(name, description, schemaKeys, handler)` call wants the
|
|
10
|
+
* keys object directly, not a wrapped schema. Tests build `z.object(keys)`
|
|
11
|
+
* when they need to exercise parsing.
|
|
12
|
+
*/
|
|
13
|
+
const TIME_WINDOW = z
|
|
14
|
+
.enum(["1h", "6h", "24h", "7d", "30d"])
|
|
15
|
+
.describe("Time window for stat aggregation. 24h = rolling 24 hours back from now.");
|
|
16
|
+
const DIMENSION = z
|
|
17
|
+
.enum(["model", "user", "session", "feature"])
|
|
18
|
+
.describe("Dimension to group by. `model` = gen_ai_request_model; `user` = user_id; " +
|
|
19
|
+
"`session` = session_id; `feature` = metadata->>'feature'.");
|
|
20
|
+
const LIMIT = z
|
|
21
|
+
.number()
|
|
22
|
+
.int()
|
|
23
|
+
.min(1)
|
|
24
|
+
.max(200)
|
|
25
|
+
.describe("Max rows (default 50, hard cap 200).");
|
|
26
|
+
export const listSpansInputSchema = {
|
|
27
|
+
model: z.string().optional().describe("Exact match on `gen_ai_request_model`."),
|
|
28
|
+
user_id: z.string().optional().describe("Exact match on span `user_id`."),
|
|
29
|
+
session_id: z.string().optional().describe("Exact match on span `session_id`."),
|
|
30
|
+
time_window: TIME_WINDOW.optional().describe("If present, restricts to spans whose `start_time` falls inside the window."),
|
|
31
|
+
tags: z.array(z.string()).optional().describe("Must contain ALL given tags."),
|
|
32
|
+
min_duration_ms: z
|
|
33
|
+
.number()
|
|
34
|
+
.int()
|
|
35
|
+
.min(0)
|
|
36
|
+
.optional()
|
|
37
|
+
.describe("Filter spans whose `duration_ms` is at least this many ms."),
|
|
38
|
+
status_min: z.number().int().optional().describe("Minimum HTTP status_code (inclusive)."),
|
|
39
|
+
status_max: z.number().int().optional().describe("Maximum HTTP status_code (inclusive)."),
|
|
40
|
+
cursor: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Opaque pagination cursor from a previous `list_spans` call."),
|
|
44
|
+
limit: LIMIT.optional(),
|
|
45
|
+
};
|
|
46
|
+
export const getTraceInputSchema = {
|
|
47
|
+
trace_id: z.string().min(1).describe("Trace ID returned by any gateway call (from the `x-infer-trace-id` response header)."),
|
|
48
|
+
};
|
|
49
|
+
export const getSpanInputSchema = {
|
|
50
|
+
span_id: z.string().min(1).describe("Span ID (from `x-infer-span-id`)."),
|
|
51
|
+
};
|
|
52
|
+
export const getLatencyStatsInputSchema = {
|
|
53
|
+
dimension: DIMENSION,
|
|
54
|
+
time_window: TIME_WINDOW.optional().describe("Default: `24h`."),
|
|
55
|
+
};
|
|
56
|
+
export const getTokenUsageInputSchema = {
|
|
57
|
+
dimension: DIMENSION,
|
|
58
|
+
time_window: TIME_WINDOW,
|
|
59
|
+
};
|
|
60
|
+
export const getCostStatsInputSchema = {
|
|
61
|
+
dimension: DIMENSION,
|
|
62
|
+
time_window: TIME_WINDOW,
|
|
63
|
+
};
|
|
64
|
+
export const getErrorSpansInputSchema = {
|
|
65
|
+
time_window: TIME_WINDOW.optional().describe("Default: `24h`."),
|
|
66
|
+
limit: LIMIT.optional(),
|
|
67
|
+
cursor: z.string().optional(),
|
|
68
|
+
};
|
|
69
|
+
export const annotateSpanInputSchema = {
|
|
70
|
+
span_id: z.string().min(1).describe("The span_id to attach the annotation to."),
|
|
71
|
+
content: z
|
|
72
|
+
.string()
|
|
73
|
+
.min(1)
|
|
74
|
+
.max(2000)
|
|
75
|
+
.describe("Your finding — what this span shows, root cause, context. Surfaces in `get_span` output going forward."),
|
|
76
|
+
};
|
|
77
|
+
export const annotateTraceInputSchema = {
|
|
78
|
+
trace_id: z.string().min(1).describe("The trace_id to annotate (applies to the whole trace, not a single span)."),
|
|
79
|
+
content: z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.max(2000)
|
|
83
|
+
.describe("Trace-level finding — conclusion about the multi-span agent turn. " +
|
|
84
|
+
"Use for root-cause writeups that don't belong to any single span."),
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/tools/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;;;;GAUG;AAEH,MAAM,WAAW,GAAG,CAAC;KAClB,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,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AAC,0CAA0C,CAAC;IAC/E,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,IAAI,CAAC;SACT,QAAQ,CACP,wGAAwG,CACzG;CACJ,CAAC;AAEF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,2EAA2E,CAAC;IACjH,OAAO,EAAE,CAAC;SACP,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,IAAI,CAAC;SACT,QAAQ,CACP,oEAAoE;QAClE,mEAAmE,CACtE;CACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch-project.d.ts","sourceRoot":"","sources":["../../src/tools/switch-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"switch-project.d.ts","sourceRoot":"","sources":["../../src/tools/switch-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,mBAAmB;;CAK/B,CAAC;AAEF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,MAAM,CAAC,CAkFjB"}
|