@m4trix/trace-viewer 0.19.0 → 0.20.1
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/cli.js +54 -19
- package/dist/cli.js.map +1 -1
- package/dist/client/assets/{anthropic-DUwMYY1S.js → anthropic-DUF4nwkM.js} +3 -3
- package/dist/client/assets/{bedrock-BIja-RWN.js → bedrock-B4cfissL.js} +1 -1
- package/dist/client/assets/index-BlT0DvBL.js +335 -0
- package/dist/client/assets/index-CRoXb3R-.css +1 -0
- package/dist/client/assets/{node.browser-C_s9kvmM.js → node.browser-DOES-yqb.js} +1 -1
- package/dist/client/assets/{node.browser-DWucOsQl.js → node.browser-O5T6j_9t.js} +1 -1
- package/dist/client/assets/{openai-mbLa3c0B.js → openai-Bn-iNnJw.js} +1 -1
- package/dist/client/index.html +2 -2
- package/dist/index.d.ts +6 -3
- package/dist/index.js +53 -18
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/dist/client/assets/index-Cl5VyaKo.js +0 -274
- package/dist/client/assets/index-DVz5tq4u.css +0 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
|
|
|
13
13
|
import { initTRPC } from '@trpc/server';
|
|
14
14
|
|
|
15
15
|
// package.json
|
|
16
|
-
var version = "0.
|
|
16
|
+
var version = "0.20.1";
|
|
17
17
|
|
|
18
18
|
// src/cli-args.ts
|
|
19
19
|
var DEFAULT_PORT = 4319;
|
|
@@ -360,6 +360,9 @@ var TraceToolError = class extends Error {
|
|
|
360
360
|
this.name = "TraceToolError";
|
|
361
361
|
}
|
|
362
362
|
};
|
|
363
|
+
function isUnsupportedSchemaVersionError(error) {
|
|
364
|
+
return error instanceof Error && error.name === "UnsupportedSchemaVersionError";
|
|
365
|
+
}
|
|
363
366
|
function shortId(id) {
|
|
364
367
|
return id.length > 12 ? id.slice(0, 8) : id;
|
|
365
368
|
}
|
|
@@ -369,20 +372,24 @@ function compareRunsByStartTime(left, right) {
|
|
|
369
372
|
async function scanTraces(api, query, visit, maxScan = MAX_TRACE_SCAN) {
|
|
370
373
|
let cursor;
|
|
371
374
|
let scanned = 0;
|
|
375
|
+
let skippedIncompatibleCount = 0;
|
|
372
376
|
while (scanned < maxScan) {
|
|
373
377
|
const page = await api.listTraces({
|
|
374
378
|
...query,
|
|
375
379
|
limit: Math.min(SCAN_PAGE_SIZE, maxScan - scanned),
|
|
376
380
|
...cursor ? { cursor } : {}
|
|
377
381
|
});
|
|
382
|
+
skippedIncompatibleCount += page.skippedIncompatibleCount ?? 0;
|
|
378
383
|
for (const trace of page.traces) {
|
|
379
384
|
scanned += 1;
|
|
380
|
-
if (!visit(trace)) return { scanned, exhausted: false };
|
|
385
|
+
if (!visit(trace)) return { scanned, exhausted: false, skippedIncompatibleCount };
|
|
386
|
+
}
|
|
387
|
+
if (!page.nextCursor || page.traces.length === 0) {
|
|
388
|
+
return { scanned, exhausted: true, skippedIncompatibleCount };
|
|
381
389
|
}
|
|
382
|
-
if (!page.nextCursor || page.traces.length === 0) return { scanned, exhausted: true };
|
|
383
390
|
cursor = page.nextCursor;
|
|
384
391
|
}
|
|
385
|
-
return { scanned, exhausted: false };
|
|
392
|
+
return { scanned, exhausted: false, skippedIncompatibleCount };
|
|
386
393
|
}
|
|
387
394
|
async function resolveTrace(api, traceRef) {
|
|
388
395
|
const ref = traceRef.trim();
|
|
@@ -393,7 +400,10 @@ async function resolveTrace(api, traceRef) {
|
|
|
393
400
|
if (!latest) throw new TraceToolError("No traces found in the trace store.");
|
|
394
401
|
return requireRecord(api, latest.traceId);
|
|
395
402
|
}
|
|
396
|
-
const exact = await api.getTrace(ref).catch(() =>
|
|
403
|
+
const exact = await api.getTrace(ref).catch((error) => {
|
|
404
|
+
if (isUnsupportedSchemaVersionError(error)) throw new TraceToolError(error.message);
|
|
405
|
+
return null;
|
|
406
|
+
});
|
|
397
407
|
if (exact) return exact;
|
|
398
408
|
const candidates = [];
|
|
399
409
|
await scanTraces(api, {}, (trace) => {
|
|
@@ -478,6 +488,8 @@ function statusIcon(status) {
|
|
|
478
488
|
return "\u2713";
|
|
479
489
|
case "error":
|
|
480
490
|
return "\u2717";
|
|
491
|
+
case "cancelled":
|
|
492
|
+
return "\u2298";
|
|
481
493
|
default:
|
|
482
494
|
return "\u2026";
|
|
483
495
|
}
|
|
@@ -511,6 +523,8 @@ function formatTraceRow(trace) {
|
|
|
511
523
|
formatTokens(trace.tokens),
|
|
512
524
|
trace.costUsd !== void 0 ? `$${trace.costUsd.toFixed(4)}` : "",
|
|
513
525
|
trace.projectId ? `project=${trace.projectId}` : "",
|
|
526
|
+
trace.sessionId ? `session=${trace.sessionId}` : "",
|
|
527
|
+
trace.userId ? `user=${trace.userId}` : "",
|
|
514
528
|
formatMetadata(trace.metadata),
|
|
515
529
|
trace.annotation ? "[annotated]" : ""
|
|
516
530
|
].filter(Boolean).join(" ");
|
|
@@ -520,6 +534,7 @@ function formatRunLabel(run, options = {}) {
|
|
|
520
534
|
const error = run.error && errorChars > 0 ? ` error: ${clip(run.error.message, errorChars)}` : "";
|
|
521
535
|
return [
|
|
522
536
|
`${statusIcon(run.status)} ${run.type} ${run.name}`,
|
|
537
|
+
run.model ? `model=${run.model}` : "",
|
|
523
538
|
formatMs(run.latencyMs),
|
|
524
539
|
formatTokens(run.tokens),
|
|
525
540
|
`[${shortId(run.runId)}]`
|
|
@@ -930,6 +945,7 @@ var PayloadIndex = class {
|
|
|
930
945
|
this.maxChars = options.maxChars ?? DEFAULT_MAX_CHARS;
|
|
931
946
|
this.concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
|
|
932
947
|
}
|
|
948
|
+
api;
|
|
933
949
|
traces = /* @__PURE__ */ new Map();
|
|
934
950
|
maxChars;
|
|
935
951
|
concurrency;
|
|
@@ -1065,6 +1081,8 @@ function metadataMatches(metadata, expected) {
|
|
|
1065
1081
|
function traceMatchesFilter(trace, filter, namePattern) {
|
|
1066
1082
|
if (filter.status && trace.status !== filter.status) return false;
|
|
1067
1083
|
if (filter.projectId && trace.projectId !== filter.projectId) return false;
|
|
1084
|
+
if (filter.sessionId && trace.sessionId !== filter.sessionId) return false;
|
|
1085
|
+
if (filter.userId && trace.userId !== filter.userId) return false;
|
|
1068
1086
|
if (namePattern && !namePattern.test(trace.name)) return false;
|
|
1069
1087
|
if (filter.minLatencyMs !== void 0 && (trace.latencyMs ?? -1) < filter.minLatencyMs)
|
|
1070
1088
|
return false;
|
|
@@ -1130,8 +1148,11 @@ function searchPayloads(traces, query) {
|
|
|
1130
1148
|
return { groups: [...groups.values()], totalOccurrences, searchedPayloads };
|
|
1131
1149
|
}
|
|
1132
1150
|
|
|
1151
|
+
// src/shared/langgraph-plumbing.ts
|
|
1152
|
+
var LANGGRAPH_PLUMBING_PATTERN = "^(ChannelWrite<.*>|Branch<.*>|__start__|__end__)$";
|
|
1153
|
+
|
|
1133
1154
|
// src/mcp/tree-outline.ts
|
|
1134
|
-
var DEFAULT_HIDE_PATTERN =
|
|
1155
|
+
var DEFAULT_HIDE_PATTERN = LANGGRAPH_PLUMBING_PATTERN;
|
|
1135
1156
|
function renderTreeOutline(roots, options = {}) {
|
|
1136
1157
|
const maxNodes = options.maxNodes ?? 200;
|
|
1137
1158
|
const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
|
|
@@ -1189,17 +1210,20 @@ var TraceTools = class {
|
|
|
1189
1210
|
this.api = api;
|
|
1190
1211
|
this.index = new PayloadIndex(api, options.index);
|
|
1191
1212
|
}
|
|
1213
|
+
api;
|
|
1192
1214
|
index;
|
|
1193
1215
|
async listTraces(input) {
|
|
1194
1216
|
const limit = input.limit ?? 20;
|
|
1195
1217
|
const offset = input.offset ?? 0;
|
|
1196
1218
|
const namePattern = input.name ? compileUserRegex(input.name, "name") : null;
|
|
1197
1219
|
const matches = [];
|
|
1198
|
-
const { scanned, exhausted } = await scanTraces(
|
|
1220
|
+
const { scanned, exhausted, skippedIncompatibleCount } = await scanTraces(
|
|
1199
1221
|
this.api,
|
|
1200
1222
|
{
|
|
1201
1223
|
...input.status ? { status: input.status } : {},
|
|
1202
1224
|
...input.projectId ? { projectId: input.projectId } : {},
|
|
1225
|
+
...input.sessionId ? { sessionId: input.sessionId } : {},
|
|
1226
|
+
...input.userId ? { userId: input.userId } : {},
|
|
1203
1227
|
...input.since ? { startAfter: input.since } : {},
|
|
1204
1228
|
...input.until ? { startBefore: input.until } : {}
|
|
1205
1229
|
},
|
|
@@ -1208,9 +1232,12 @@ var TraceTools = class {
|
|
|
1208
1232
|
return matches.length <= offset + limit;
|
|
1209
1233
|
}
|
|
1210
1234
|
);
|
|
1235
|
+
const incompatibleNote = skippedIncompatibleCount > 0 ? `Note: skipped ${plural(skippedIncompatibleCount, "trace")} written with a newer schemaVersion; upgrade @m4trix/tracing / @m4trix/trace-viewer to view them.` : "";
|
|
1211
1236
|
const page = matches.slice(offset, offset + limit);
|
|
1212
1237
|
if (page.length === 0) {
|
|
1213
|
-
|
|
1238
|
+
const empty = offset > 0 ? `No traces at offset ${offset}.` : "No traces match.";
|
|
1239
|
+
return incompatibleNote ? `${empty}
|
|
1240
|
+
${incompatibleNote}` : empty;
|
|
1214
1241
|
}
|
|
1215
1242
|
const hasMore = matches.length > offset + limit;
|
|
1216
1243
|
const lines = page.map((trace) => {
|
|
@@ -1218,7 +1245,12 @@ var TraceTools = class {
|
|
|
1218
1245
|
return `${formatTraceRow(trace)}${loaded}`;
|
|
1219
1246
|
});
|
|
1220
1247
|
const footer = hasMore ? `More traces available: call again with offset=${offset + limit}.` : !exhausted && scanned >= MAX_TRACE_SCAN ? `Scan stopped after ${MAX_TRACE_SCAN} traces; narrow with since/until/status.` : "";
|
|
1221
|
-
return [
|
|
1248
|
+
return [
|
|
1249
|
+
`${plural(page.length, "trace")} (newest first, offset ${offset}):`,
|
|
1250
|
+
...lines,
|
|
1251
|
+
footer,
|
|
1252
|
+
incompatibleNote
|
|
1253
|
+
].filter(Boolean).join("\n");
|
|
1222
1254
|
}
|
|
1223
1255
|
async getTrace(input) {
|
|
1224
1256
|
const record = await resolveTrace(this.api, input.traceId);
|
|
@@ -1726,7 +1758,8 @@ var scalar = z.union([z.string(), z.number(), z.boolean()]);
|
|
|
1726
1758
|
var traceIdField = z.string().min(1).describe('Trace id, unique prefix, or "latest".');
|
|
1727
1759
|
var runIdField = z.string().min(1).describe("Run id or unique prefix within the trace.");
|
|
1728
1760
|
var sideField = z.enum(["input", "output"]);
|
|
1729
|
-
var statusField = z.enum(["running", "success", "error"]);
|
|
1761
|
+
var statusField = z.enum(["running", "success", "error", "cancelled"]);
|
|
1762
|
+
var runTypesField = z.array(z.string()).max(50);
|
|
1730
1763
|
var readOnly = { readOnlyHint: true, openWorldHint: false };
|
|
1731
1764
|
async function respond(task) {
|
|
1732
1765
|
try {
|
|
@@ -1751,8 +1784,10 @@ function createTraceMcpServer(options) {
|
|
|
1751
1784
|
inputSchema: {
|
|
1752
1785
|
status: statusField.optional(),
|
|
1753
1786
|
projectId: z.string().optional(),
|
|
1787
|
+
sessionId: z.string().optional().describe("Conversation / thread id; lists every turn of one conversation."),
|
|
1788
|
+
userId: z.string().optional(),
|
|
1754
1789
|
name: z.string().optional().describe("Case-insensitive regex against the trace name."),
|
|
1755
|
-
metadata: z.record(scalar).optional().describe('Exact match on trace metadata, e.g. { "env": "dev" }.'),
|
|
1790
|
+
metadata: z.record(z.string(), scalar).optional().describe('Exact match on trace metadata, e.g. { "env": "dev" }.'),
|
|
1756
1791
|
since: z.string().optional().describe("ISO timestamp; only traces started after it."),
|
|
1757
1792
|
until: z.string().optional().describe("ISO timestamp; only traces started before it."),
|
|
1758
1793
|
minLatencyMs: z.number().nonnegative().optional(),
|
|
@@ -1788,15 +1823,15 @@ function createTraceMcpServer(options) {
|
|
|
1788
1823
|
title: "Find runs",
|
|
1789
1824
|
description: "Find runs by structural fields (type, name, status, error message, latency, tokens, metadata) across one or more traces. Does not read payloads.",
|
|
1790
1825
|
inputSchema: {
|
|
1791
|
-
traceIds: z.array(z.string().min(1)).optional().describe("Defaults to the newest traceLimit traces."),
|
|
1826
|
+
traceIds: z.array(z.string().min(1)).max(500).optional().describe("Defaults to the newest traceLimit traces."),
|
|
1792
1827
|
traceLimit: z.number().int().positive().max(500).optional().describe("Default 20."),
|
|
1793
|
-
type:
|
|
1828
|
+
type: runTypesField.optional().describe('Run types, e.g. ["tool", "chat_model"].'),
|
|
1794
1829
|
name: z.string().optional().describe("Case-insensitive regex against run names."),
|
|
1795
1830
|
status: statusField.optional(),
|
|
1796
1831
|
errorContains: z.string().optional(),
|
|
1797
1832
|
minLatencyMs: z.number().nonnegative().optional(),
|
|
1798
1833
|
minTokens: z.number().nonnegative().optional(),
|
|
1799
|
-
metadata: z.record(scalar).optional(),
|
|
1834
|
+
metadata: z.record(z.string(), scalar).optional(),
|
|
1800
1835
|
maxDepth: z.number().int().nonnegative().optional(),
|
|
1801
1836
|
limit: z.number().int().positive().max(500).optional().describe("Default 50.")
|
|
1802
1837
|
},
|
|
@@ -1844,7 +1879,7 @@ function createTraceMcpServer(options) {
|
|
|
1844
1879
|
title: "Load trace payloads",
|
|
1845
1880
|
description: "Load all input/output payloads of traces into the in-memory search index (required before search_payloads can search them). Pass traceIds, or omit them to load the newest `limit` traces matching status/projectId. Reloading a trace only fetches new payloads.",
|
|
1846
1881
|
inputSchema: {
|
|
1847
|
-
traceIds: z.array(z.string().min(1)).optional(),
|
|
1882
|
+
traceIds: z.array(z.string().min(1)).max(100).optional(),
|
|
1848
1883
|
status: statusField.optional(),
|
|
1849
1884
|
projectId: z.string().optional(),
|
|
1850
1885
|
limit: z.number().int().positive().max(100).optional().describe("Default 10 when traceIds is omitted.")
|
|
@@ -1863,7 +1898,7 @@ function createTraceMcpServer(options) {
|
|
|
1863
1898
|
regex: z.boolean().optional(),
|
|
1864
1899
|
caseSensitive: z.boolean().optional(),
|
|
1865
1900
|
traceIds: z.array(z.string().min(1)).max(20).optional(),
|
|
1866
|
-
runType:
|
|
1901
|
+
runType: runTypesField.optional(),
|
|
1867
1902
|
runName: z.string().optional().describe("Case-insensitive regex against run names."),
|
|
1868
1903
|
side: z.enum(["input", "output", "both"]).optional(),
|
|
1869
1904
|
pathPrefix: z.string().optional().describe('Only leaves under this path, e.g. "$.messages".'),
|
|
@@ -1928,7 +1963,7 @@ function createTraceMcpServer(options) {
|
|
|
1928
1963
|
inputSchema: {
|
|
1929
1964
|
traceId: traceIdField,
|
|
1930
1965
|
runId: runIdField.optional(),
|
|
1931
|
-
annotation: z.record(z.unknown()),
|
|
1966
|
+
annotation: z.record(z.string(), z.unknown()),
|
|
1932
1967
|
merge: z.boolean().optional().describe("Default true. false replaces the whole annotation.")
|
|
1933
1968
|
},
|
|
1934
1969
|
annotations: {
|
|
@@ -2012,12 +2047,12 @@ var t = initTRPC.context().create();
|
|
|
2012
2047
|
var listInput = z.object({
|
|
2013
2048
|
limit: z.number().int().positive().max(500).optional(),
|
|
2014
2049
|
cursor: z.string().optional(),
|
|
2015
|
-
status: z.enum(["running", "success", "error"]).optional(),
|
|
2050
|
+
status: z.enum(["running", "success", "error", "cancelled"]).optional(),
|
|
2016
2051
|
projectId: z.string().optional()
|
|
2017
2052
|
}).optional();
|
|
2018
2053
|
var annotationInput = z.object({
|
|
2019
2054
|
traceId: z.string().min(1),
|
|
2020
|
-
annotation: z.record(z.unknown()),
|
|
2055
|
+
annotation: z.record(z.string(), z.unknown()),
|
|
2021
2056
|
merge: z.boolean().optional()
|
|
2022
2057
|
});
|
|
2023
2058
|
var appRouterImpl = t.router({
|