@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.
@@ -1 +1 @@
1
- import{A as o}from"./anthropic-DUwMYY1S.js";import"./index-Cl5VyaKo.js";function n(e){return new Proxy({},{get(i,t){if(typeof t!="symbol")throw new o(`\`${e}.${t}\` is not available in this environment; it needs a Node.js-compatible runtime`)}})}const s=n("fs"),f=n("path");export{s as fs,f as path};
1
+ import{A as o}from"./anthropic-lPPXtrig.js";import"./index-C8P-vN-T.js";function n(e){return new Proxy({},{get(i,t){if(typeof t!="symbol")throw new o(`\`${e}.${t}\` is not available in this environment; it needs a Node.js-compatible runtime`)}})}const s=n("fs"),f=n("path");export{s as fs,f as path};
@@ -1 +1 @@
1
- import{A as s}from"./anthropic-DUwMYY1S.js";import{D as R,M as B}from"./anthropic-DUwMYY1S.js";import"./index-Cl5VyaKo.js";function e(o){throw new s(`${o} requires Node.js or a Node-compatible runtime`)}const a=3e4,c=".anthropic-memory-store";class u extends s{constructor(t,r){super(t),this.name="SessionMemoryError",r!==void 0&&(this.cause=r)}}class l{constructor(t,r){e("SessionMemoryStores")}get roots(){return e("SessionMemoryStores")}get readOnlyRoots(){return e("SessionMemoryStores")}download(t){return e("SessionMemoryStores")}finish(){return e("SessionMemoryStores")}syncAll(t){return e("SessionMemoryStores")}syncIfDue(){return e("SessionMemoryStores")}flushWrites(t){return e("SessionMemoryStores")}dispose(){return e("SessionMemoryStores")}}function S(o){return e("setupSkills")}function _(o,t){return e("extractSkillArchive")}function m(o){return e("betaAgentToolset20260401")}function M(o,t){return e("resolvePath")}class h extends s{constructor(t){super(`bash command timed out after ${t}ms`),this.name="BashTimeoutError",this.timeoutMs=t}}class T{constructor(t,r){e("BashSession")}get closed(){return e("BashSession")}exec(t,r={}){return e("BashSession")}close(){e("BashSession")}}function d(o){return e("betaBashTool")}function f(o){return e("betaReadTool")}function b(o){return e("betaWriteTool")}function p(o){return e("betaEditTool")}function y(o){return e("betaGlobTool")}function x(o){return e("betaGrepTool")}export{T as BashSession,h as BashTimeoutError,R as DEFAULT_MEMORY_SYNC_INTERVAL_MS,c as MARKER_PATH,a as MEMORY_FLUSH_TIMEOUT_MS,B as MIN_MEMORY_SYNC_INTERVAL_MS,u as SessionMemoryError,l as SessionMemoryStores,m as betaAgentToolset20260401,d as betaBashTool,p as betaEditTool,y as betaGlobTool,x as betaGrepTool,f as betaReadTool,b as betaWriteTool,_ as extractSkillArchive,M as resolvePath,S as setupSkills};
1
+ import{A as s}from"./anthropic-lPPXtrig.js";import{D as R,M as B}from"./anthropic-lPPXtrig.js";import"./index-C8P-vN-T.js";function e(o){throw new s(`${o} requires Node.js or a Node-compatible runtime`)}const a=3e4,c=".anthropic-memory-store";class u extends s{constructor(t,r){super(t),this.name="SessionMemoryError",r!==void 0&&(this.cause=r)}}class l{constructor(t,r){e("SessionMemoryStores")}get roots(){return e("SessionMemoryStores")}get readOnlyRoots(){return e("SessionMemoryStores")}download(t){return e("SessionMemoryStores")}finish(){return e("SessionMemoryStores")}syncAll(t){return e("SessionMemoryStores")}syncIfDue(){return e("SessionMemoryStores")}flushWrites(t){return e("SessionMemoryStores")}dispose(){return e("SessionMemoryStores")}}function S(o){return e("setupSkills")}function _(o,t){return e("extractSkillArchive")}function m(o){return e("betaAgentToolset20260401")}function M(o,t){return e("resolvePath")}class h extends s{constructor(t){super(`bash command timed out after ${t}ms`),this.name="BashTimeoutError",this.timeoutMs=t}}class T{constructor(t,r){e("BashSession")}get closed(){return e("BashSession")}exec(t,r={}){return e("BashSession")}close(){e("BashSession")}}function d(o){return e("betaBashTool")}function f(o){return e("betaReadTool")}function b(o){return e("betaWriteTool")}function p(o){return e("betaEditTool")}function y(o){return e("betaGlobTool")}function x(o){return e("betaGrepTool")}export{T as BashSession,h as BashTimeoutError,R as DEFAULT_MEMORY_SYNC_INTERVAL_MS,c as MARKER_PATH,a as MEMORY_FLUSH_TIMEOUT_MS,B as MIN_MEMORY_SYNC_INTERVAL_MS,u as SessionMemoryError,l as SessionMemoryStores,m as betaAgentToolset20260401,d as betaBashTool,p as betaEditTool,y as betaGlobTool,x as betaGrepTool,f as betaReadTool,b as betaWriteTool,_ as extractSkillArchive,M as resolvePath,S as setupSkills};
@@ -1,3 +1,3 @@
1
- import{j as p,t as c,P as r,k as l}from"./index-Cl5VyaKo.js";const d="https://api.openai.com/v1/responses",m=32e3;async function f(e){try{return(await e.json()).error?.message??`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}function h(e){return/json/i.test(e)?e:`${e}
1
+ import{j as p,t as c,P as r,k as l}from"./index-C8P-vN-T.js";const d="https://api.openai.com/v1/responses",m=32e3;async function f(e){try{return(await e.json()).error?.message??`HTTP ${e.status}`}catch{return`HTTP ${e.status}`}}function h(e){return/json/i.test(e)?e:`${e}
2
2
 
3
3
  Respond with a single JSON object.`}function w(e,i={}){const u=i.fetch??globalThis.fetch.bind(globalThis);return{id:"openai",async generate(n){let o;try{o=await u(d,{method:"POST",signal:n.signal,headers:{"content-type":"application/json",authorization:`Bearer ${e.credentials.apiKey??""}`},body:JSON.stringify({model:e.model,instructions:n.system,input:h(p(n)),max_output_tokens:n.maxTokens??m,text:{format:{type:"json_object"}}})})}catch(t){throw c(t)}if(!o.ok)throw new r(l(o.status),await f(o),o.status);const s=await o.json(),a=(s.output??[]).filter(t=>t.type==="message").flatMap(t=>t.content??[]);if(a.some(t=>t.type==="refusal"))throw new r("refusal",a.find(t=>t.type==="refusal")?.refusal??"Refused.");if(s.status==="incomplete"){const t=s.incomplete_details?.reason??"unknown";throw new r(t==="max_output_tokens"?"truncated":"other",`Response incomplete (${t}).`)}return{text:a.filter(t=>t.type==="output_text").map(t=>t.text??"").join("").trim(),model:s.model??e.model,usage:{inputTokens:s.usage?.input_tokens,outputTokens:s.usage?.output_tokens}}}}}export{d as OPENAI_RESPONSES_URL,w as createOpenAIProvider,h as openAIJsonModeInput};
@@ -4,8 +4,8 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>m4trix trace viewer</title>
7
- <script type="module" crossorigin src="/assets/index-Cl5VyaKo.js"></script>
8
- <link rel="stylesheet" crossorigin href="/assets/index-DVz5tq4u.css">
7
+ <script type="module" crossorigin src="/assets/index-C8P-vN-T.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-BSgeyMwl.css">
9
9
  </head>
10
10
  <body>
11
11
  <div id="root"></div>
package/dist/index.d.ts CHANGED
@@ -128,7 +128,7 @@ type RunFilter = {
128
128
  type?: string[];
129
129
  /** Case-insensitive regex against run names. */
130
130
  name?: string;
131
- status?: 'running' | 'success' | 'error';
131
+ status?: Trace['status'];
132
132
  /** Case-insensitive substring of the run error message. */
133
133
  errorContains?: string;
134
134
  minLatencyMs?: number;
@@ -141,6 +141,9 @@ type RunFilter = {
141
141
  type TraceFilter = {
142
142
  status?: Trace['status'];
143
143
  projectId?: string;
144
+ /** Conversation or thread the trace belongs to. */
145
+ sessionId?: string;
146
+ userId?: string;
144
147
  /** Case-insensitive regex against trace names. */
145
148
  name?: string;
146
149
  metadata?: Record<string, string | number | boolean>;
@@ -289,9 +292,9 @@ declare const appRouterImpl: _trpc_server.TRPCBuiltRouter<{
289
292
  }, _trpc_server.TRPCDecorateCreateRouterOptions<{
290
293
  list: _trpc_server.TRPCQueryProcedure<{
291
294
  input: {
292
- status?: "error" | "running" | "success" | undefined;
293
295
  limit?: number | undefined;
294
296
  cursor?: string | undefined;
297
+ status?: "error" | "running" | "success" | "cancelled" | undefined;
295
298
  projectId?: string | undefined;
296
299
  } | undefined;
297
300
  output: _m4trix_tracing.ListTracesResult;
@@ -326,8 +329,8 @@ declare const appRouterImpl: _trpc_server.TRPCBuiltRouter<{
326
329
  patchRunAnnotation: _trpc_server.TRPCMutationProcedure<{
327
330
  input: {
328
331
  traceId: string;
329
- runId: string;
330
332
  annotation: Record<string, unknown>;
333
+ runId: string;
331
334
  merge?: boolean | undefined;
332
335
  };
333
336
  output: _m4trix_tracing.TraceRun | null;
package/dist/index.js CHANGED
@@ -476,6 +476,8 @@ function statusIcon(status) {
476
476
  return "\u2713";
477
477
  case "error":
478
478
  return "\u2717";
479
+ case "cancelled":
480
+ return "\u2298";
479
481
  default:
480
482
  return "\u2026";
481
483
  }
@@ -509,6 +511,8 @@ function formatTraceRow(trace) {
509
511
  formatTokens(trace.tokens),
510
512
  trace.costUsd !== void 0 ? `$${trace.costUsd.toFixed(4)}` : "",
511
513
  trace.projectId ? `project=${trace.projectId}` : "",
514
+ trace.sessionId ? `session=${trace.sessionId}` : "",
515
+ trace.userId ? `user=${trace.userId}` : "",
512
516
  formatMetadata(trace.metadata),
513
517
  trace.annotation ? "[annotated]" : ""
514
518
  ].filter(Boolean).join(" ");
@@ -518,6 +522,7 @@ function formatRunLabel(run, options = {}) {
518
522
  const error = run.error && errorChars > 0 ? ` error: ${clip(run.error.message, errorChars)}` : "";
519
523
  return [
520
524
  `${statusIcon(run.status)} ${run.type} ${run.name}`,
525
+ run.model ? `model=${run.model}` : "",
521
526
  formatMs(run.latencyMs),
522
527
  formatTokens(run.tokens),
523
528
  `[${shortId(run.runId)}]`
@@ -928,6 +933,7 @@ var PayloadIndex = class {
928
933
  this.maxChars = options.maxChars ?? DEFAULT_MAX_CHARS;
929
934
  this.concurrency = options.concurrency ?? DEFAULT_CONCURRENCY;
930
935
  }
936
+ api;
931
937
  traces = /* @__PURE__ */ new Map();
932
938
  maxChars;
933
939
  concurrency;
@@ -1063,6 +1069,8 @@ function metadataMatches(metadata, expected) {
1063
1069
  function traceMatchesFilter(trace, filter, namePattern) {
1064
1070
  if (filter.status && trace.status !== filter.status) return false;
1065
1071
  if (filter.projectId && trace.projectId !== filter.projectId) return false;
1072
+ if (filter.sessionId && trace.sessionId !== filter.sessionId) return false;
1073
+ if (filter.userId && trace.userId !== filter.userId) return false;
1066
1074
  if (namePattern && !namePattern.test(trace.name)) return false;
1067
1075
  if (filter.minLatencyMs !== void 0 && (trace.latencyMs ?? -1) < filter.minLatencyMs)
1068
1076
  return false;
@@ -1128,8 +1136,11 @@ function searchPayloads(traces, query) {
1128
1136
  return { groups: [...groups.values()], totalOccurrences, searchedPayloads };
1129
1137
  }
1130
1138
 
1139
+ // src/shared/langgraph-plumbing.ts
1140
+ var LANGGRAPH_PLUMBING_PATTERN = "^(ChannelWrite<.*>|Branch<.*>|__start__|__end__)$";
1141
+
1131
1142
  // src/mcp/tree-outline.ts
1132
- var DEFAULT_HIDE_PATTERN = "^(ChannelWrite<.*>|Branch<.*>|__start__|__end__)$";
1143
+ var DEFAULT_HIDE_PATTERN = LANGGRAPH_PLUMBING_PATTERN;
1133
1144
  function renderTreeOutline(roots, options = {}) {
1134
1145
  const maxNodes = options.maxNodes ?? 200;
1135
1146
  const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
@@ -1187,6 +1198,7 @@ var TraceTools = class {
1187
1198
  this.api = api;
1188
1199
  this.index = new PayloadIndex(api, options.index);
1189
1200
  }
1201
+ api;
1190
1202
  index;
1191
1203
  async listTraces(input) {
1192
1204
  const limit = input.limit ?? 20;
@@ -1198,6 +1210,8 @@ var TraceTools = class {
1198
1210
  {
1199
1211
  ...input.status ? { status: input.status } : {},
1200
1212
  ...input.projectId ? { projectId: input.projectId } : {},
1213
+ ...input.sessionId ? { sessionId: input.sessionId } : {},
1214
+ ...input.userId ? { userId: input.userId } : {},
1201
1215
  ...input.since ? { startAfter: input.since } : {},
1202
1216
  ...input.until ? { startBefore: input.until } : {}
1203
1217
  },
@@ -1724,7 +1738,8 @@ var scalar = z.union([z.string(), z.number(), z.boolean()]);
1724
1738
  var traceIdField = z.string().min(1).describe('Trace id, unique prefix, or "latest".');
1725
1739
  var runIdField = z.string().min(1).describe("Run id or unique prefix within the trace.");
1726
1740
  var sideField = z.enum(["input", "output"]);
1727
- var statusField = z.enum(["running", "success", "error"]);
1741
+ var statusField = z.enum(["running", "success", "error", "cancelled"]);
1742
+ var runTypesField = z.array(z.string()).max(50);
1728
1743
  var readOnly = { readOnlyHint: true, openWorldHint: false };
1729
1744
  async function respond(task) {
1730
1745
  try {
@@ -1749,8 +1764,10 @@ function createTraceMcpServer(options) {
1749
1764
  inputSchema: {
1750
1765
  status: statusField.optional(),
1751
1766
  projectId: z.string().optional(),
1767
+ sessionId: z.string().optional().describe("Conversation / thread id; lists every turn of one conversation."),
1768
+ userId: z.string().optional(),
1752
1769
  name: z.string().optional().describe("Case-insensitive regex against the trace name."),
1753
- metadata: z.record(scalar).optional().describe('Exact match on trace metadata, e.g. { "env": "dev" }.'),
1770
+ metadata: z.record(z.string(), scalar).optional().describe('Exact match on trace metadata, e.g. { "env": "dev" }.'),
1754
1771
  since: z.string().optional().describe("ISO timestamp; only traces started after it."),
1755
1772
  until: z.string().optional().describe("ISO timestamp; only traces started before it."),
1756
1773
  minLatencyMs: z.number().nonnegative().optional(),
@@ -1786,15 +1803,15 @@ function createTraceMcpServer(options) {
1786
1803
  title: "Find runs",
1787
1804
  description: "Find runs by structural fields (type, name, status, error message, latency, tokens, metadata) across one or more traces. Does not read payloads.",
1788
1805
  inputSchema: {
1789
- traceIds: z.array(z.string().min(1)).optional().describe("Defaults to the newest traceLimit traces."),
1806
+ traceIds: z.array(z.string().min(1)).max(500).optional().describe("Defaults to the newest traceLimit traces."),
1790
1807
  traceLimit: z.number().int().positive().max(500).optional().describe("Default 20."),
1791
- type: z.array(z.string()).optional().describe('Run types, e.g. ["tool", "chat_model"].'),
1808
+ type: runTypesField.optional().describe('Run types, e.g. ["tool", "chat_model"].'),
1792
1809
  name: z.string().optional().describe("Case-insensitive regex against run names."),
1793
1810
  status: statusField.optional(),
1794
1811
  errorContains: z.string().optional(),
1795
1812
  minLatencyMs: z.number().nonnegative().optional(),
1796
1813
  minTokens: z.number().nonnegative().optional(),
1797
- metadata: z.record(scalar).optional(),
1814
+ metadata: z.record(z.string(), scalar).optional(),
1798
1815
  maxDepth: z.number().int().nonnegative().optional(),
1799
1816
  limit: z.number().int().positive().max(500).optional().describe("Default 50.")
1800
1817
  },
@@ -1842,7 +1859,7 @@ function createTraceMcpServer(options) {
1842
1859
  title: "Load trace payloads",
1843
1860
  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.",
1844
1861
  inputSchema: {
1845
- traceIds: z.array(z.string().min(1)).optional(),
1862
+ traceIds: z.array(z.string().min(1)).max(100).optional(),
1846
1863
  status: statusField.optional(),
1847
1864
  projectId: z.string().optional(),
1848
1865
  limit: z.number().int().positive().max(100).optional().describe("Default 10 when traceIds is omitted.")
@@ -1861,7 +1878,7 @@ function createTraceMcpServer(options) {
1861
1878
  regex: z.boolean().optional(),
1862
1879
  caseSensitive: z.boolean().optional(),
1863
1880
  traceIds: z.array(z.string().min(1)).max(20).optional(),
1864
- runType: z.array(z.string()).optional(),
1881
+ runType: runTypesField.optional(),
1865
1882
  runName: z.string().optional().describe("Case-insensitive regex against run names."),
1866
1883
  side: z.enum(["input", "output", "both"]).optional(),
1867
1884
  pathPrefix: z.string().optional().describe('Only leaves under this path, e.g. "$.messages".'),
@@ -1926,7 +1943,7 @@ function createTraceMcpServer(options) {
1926
1943
  inputSchema: {
1927
1944
  traceId: traceIdField,
1928
1945
  runId: runIdField.optional(),
1929
- annotation: z.record(z.unknown()),
1946
+ annotation: z.record(z.string(), z.unknown()),
1930
1947
  merge: z.boolean().optional().describe("Default true. false replaces the whole annotation.")
1931
1948
  },
1932
1949
  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({