@m4trix/trace-viewer 0.19.0 → 0.20.0

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 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.19.0";
16
+ var version = "0.20.0";
17
17
 
18
18
  // src/cli-args.ts
19
19
  var DEFAULT_PORT = 4319;
@@ -478,6 +478,8 @@ function statusIcon(status) {
478
478
  return "\u2713";
479
479
  case "error":
480
480
  return "\u2717";
481
+ case "cancelled":
482
+ return "\u2298";
481
483
  default:
482
484
  return "\u2026";
483
485
  }
@@ -511,6 +513,8 @@ function formatTraceRow(trace) {
511
513
  formatTokens(trace.tokens),
512
514
  trace.costUsd !== void 0 ? `$${trace.costUsd.toFixed(4)}` : "",
513
515
  trace.projectId ? `project=${trace.projectId}` : "",
516
+ trace.sessionId ? `session=${trace.sessionId}` : "",
517
+ trace.userId ? `user=${trace.userId}` : "",
514
518
  formatMetadata(trace.metadata),
515
519
  trace.annotation ? "[annotated]" : ""
516
520
  ].filter(Boolean).join(" ");
@@ -520,6 +524,7 @@ function formatRunLabel(run, options = {}) {
520
524
  const error = run.error && errorChars > 0 ? ` error: ${clip(run.error.message, errorChars)}` : "";
521
525
  return [
522
526
  `${statusIcon(run.status)} ${run.type} ${run.name}`,
527
+ run.model ? `model=${run.model}` : "",
523
528
  formatMs(run.latencyMs),
524
529
  formatTokens(run.tokens),
525
530
  `[${shortId(run.runId)}]`
@@ -930,6 +935,7 @@ var PayloadIndex = class {
930
935
  this.maxChars = options.maxChars ?? DEFAULT_MAX_CHARS;
931
936
  this.concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
932
937
  }
938
+ api;
933
939
  traces = /* @__PURE__ */ new Map();
934
940
  maxChars;
935
941
  concurrency;
@@ -1065,6 +1071,8 @@ function metadataMatches(metadata, expected) {
1065
1071
  function traceMatchesFilter(trace, filter, namePattern) {
1066
1072
  if (filter.status && trace.status !== filter.status) return false;
1067
1073
  if (filter.projectId && trace.projectId !== filter.projectId) return false;
1074
+ if (filter.sessionId && trace.sessionId !== filter.sessionId) return false;
1075
+ if (filter.userId && trace.userId !== filter.userId) return false;
1068
1076
  if (namePattern && !namePattern.test(trace.name)) return false;
1069
1077
  if (filter.minLatencyMs !== void 0 && (trace.latencyMs ?? -1) < filter.minLatencyMs)
1070
1078
  return false;
@@ -1130,8 +1138,11 @@ function searchPayloads(traces, query) {
1130
1138
  return { groups: [...groups.values()], totalOccurrences, searchedPayloads };
1131
1139
  }
1132
1140
 
1141
+ // src/shared/langgraph-plumbing.ts
1142
+ var LANGGRAPH_PLUMBING_PATTERN = "^(ChannelWrite<.*>|Branch<.*>|__start__|__end__)$";
1143
+
1133
1144
  // src/mcp/tree-outline.ts
1134
- var DEFAULT_HIDE_PATTERN = "^(ChannelWrite<.*>|Branch<.*>|__start__|__end__)$";
1145
+ var DEFAULT_HIDE_PATTERN = LANGGRAPH_PLUMBING_PATTERN;
1135
1146
  function renderTreeOutline(roots, options = {}) {
1136
1147
  const maxNodes = options.maxNodes ?? 200;
1137
1148
  const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
@@ -1189,6 +1200,7 @@ var TraceTools = class {
1189
1200
  this.api = api;
1190
1201
  this.index = new PayloadIndex(api, options.index);
1191
1202
  }
1203
+ api;
1192
1204
  index;
1193
1205
  async listTraces(input) {
1194
1206
  const limit = input.limit ?? 20;
@@ -1200,6 +1212,8 @@ var TraceTools = class {
1200
1212
  {
1201
1213
  ...input.status ? { status: input.status } : {},
1202
1214
  ...input.projectId ? { projectId: input.projectId } : {},
1215
+ ...input.sessionId ? { sessionId: input.sessionId } : {},
1216
+ ...input.userId ? { userId: input.userId } : {},
1203
1217
  ...input.since ? { startAfter: input.since } : {},
1204
1218
  ...input.until ? { startBefore: input.until } : {}
1205
1219
  },
@@ -1726,7 +1740,8 @@ var scalar = z.union([z.string(), z.number(), z.boolean()]);
1726
1740
  var traceIdField = z.string().min(1).describe('Trace id, unique prefix, or "latest".');
1727
1741
  var runIdField = z.string().min(1).describe("Run id or unique prefix within the trace.");
1728
1742
  var sideField = z.enum(["input", "output"]);
1729
- var statusField = z.enum(["running", "success", "error"]);
1743
+ var statusField = z.enum(["running", "success", "error", "cancelled"]);
1744
+ var runTypesField = z.array(z.string()).max(50);
1730
1745
  var readOnly = { readOnlyHint: true, openWorldHint: false };
1731
1746
  async function respond(task) {
1732
1747
  try {
@@ -1751,8 +1766,10 @@ function createTraceMcpServer(options) {
1751
1766
  inputSchema: {
1752
1767
  status: statusField.optional(),
1753
1768
  projectId: z.string().optional(),
1769
+ sessionId: z.string().optional().describe("Conversation / thread id; lists every turn of one conversation."),
1770
+ userId: z.string().optional(),
1754
1771
  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" }.'),
1772
+ metadata: z.record(z.string(), scalar).optional().describe('Exact match on trace metadata, e.g. { "env": "dev" }.'),
1756
1773
  since: z.string().optional().describe("ISO timestamp; only traces started after it."),
1757
1774
  until: z.string().optional().describe("ISO timestamp; only traces started before it."),
1758
1775
  minLatencyMs: z.number().nonnegative().optional(),
@@ -1788,15 +1805,15 @@ function createTraceMcpServer(options) {
1788
1805
  title: "Find runs",
1789
1806
  description: "Find runs by structural fields (type, name, status, error message, latency, tokens, metadata) across one or more traces. Does not read payloads.",
1790
1807
  inputSchema: {
1791
- traceIds: z.array(z.string().min(1)).optional().describe("Defaults to the newest traceLimit traces."),
1808
+ traceIds: z.array(z.string().min(1)).max(500).optional().describe("Defaults to the newest traceLimit traces."),
1792
1809
  traceLimit: z.number().int().positive().max(500).optional().describe("Default 20."),
1793
- type: z.array(z.string()).optional().describe('Run types, e.g. ["tool", "chat_model"].'),
1810
+ type: runTypesField.optional().describe('Run types, e.g. ["tool", "chat_model"].'),
1794
1811
  name: z.string().optional().describe("Case-insensitive regex against run names."),
1795
1812
  status: statusField.optional(),
1796
1813
  errorContains: z.string().optional(),
1797
1814
  minLatencyMs: z.number().nonnegative().optional(),
1798
1815
  minTokens: z.number().nonnegative().optional(),
1799
- metadata: z.record(scalar).optional(),
1816
+ metadata: z.record(z.string(), scalar).optional(),
1800
1817
  maxDepth: z.number().int().nonnegative().optional(),
1801
1818
  limit: z.number().int().positive().max(500).optional().describe("Default 50.")
1802
1819
  },
@@ -1844,7 +1861,7 @@ function createTraceMcpServer(options) {
1844
1861
  title: "Load trace payloads",
1845
1862
  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
1863
  inputSchema: {
1847
- traceIds: z.array(z.string().min(1)).optional(),
1864
+ traceIds: z.array(z.string().min(1)).max(100).optional(),
1848
1865
  status: statusField.optional(),
1849
1866
  projectId: z.string().optional(),
1850
1867
  limit: z.number().int().positive().max(100).optional().describe("Default 10 when traceIds is omitted.")
@@ -1863,7 +1880,7 @@ function createTraceMcpServer(options) {
1863
1880
  regex: z.boolean().optional(),
1864
1881
  caseSensitive: z.boolean().optional(),
1865
1882
  traceIds: z.array(z.string().min(1)).max(20).optional(),
1866
- runType: z.array(z.string()).optional(),
1883
+ runType: runTypesField.optional(),
1867
1884
  runName: z.string().optional().describe("Case-insensitive regex against run names."),
1868
1885
  side: z.enum(["input", "output", "both"]).optional(),
1869
1886
  pathPrefix: z.string().optional().describe('Only leaves under this path, e.g. "$.messages".'),
@@ -1928,7 +1945,7 @@ function createTraceMcpServer(options) {
1928
1945
  inputSchema: {
1929
1946
  traceId: traceIdField,
1930
1947
  runId: runIdField.optional(),
1931
- annotation: z.record(z.unknown()),
1948
+ annotation: z.record(z.string(), z.unknown()),
1932
1949
  merge: z.boolean().optional().describe("Default true. false replaces the whole annotation.")
1933
1950
  },
1934
1951
  annotations: {
@@ -2012,12 +2029,12 @@ var t = initTRPC.context().create();
2012
2029
  var listInput = z.object({
2013
2030
  limit: z.number().int().positive().max(500).optional(),
2014
2031
  cursor: z.string().optional(),
2015
- status: z.enum(["running", "success", "error"]).optional(),
2032
+ status: z.enum(["running", "success", "error", "cancelled"]).optional(),
2016
2033
  projectId: z.string().optional()
2017
2034
  }).optional();
2018
2035
  var annotationInput = z.object({
2019
2036
  traceId: z.string().min(1),
2020
- annotation: z.record(z.unknown()),
2037
+ annotation: z.record(z.string(), z.unknown()),
2021
2038
  merge: z.boolean().optional()
2022
2039
  });
2023
2040
  var appRouterImpl = t.router({