@tonyclaw/agent-inspector 2.1.17 → 2.1.19

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.
Files changed (44) hide show
  1. package/.output/nitro.json +1 -1
  2. package/.output/public/assets/{CompareDrawer-B9sLBHw5.js → CompareDrawer-CHXN5HYU.js} +1 -1
  3. package/.output/public/assets/ProxyViewerContainer-TZJV7HhE.js +106 -0
  4. package/.output/public/assets/{ReplayDialog-D9I9W9n3.js → ReplayDialog-DQ7nS5Rr.js} +1 -1
  5. package/.output/public/assets/{RequestAnatomy-DGXK_Rii.js → RequestAnatomy-DXWweH_2.js} +1 -1
  6. package/.output/public/assets/{ResponseView-df_JzwsS.js → ResponseView-3PimPfiD.js} +2 -2
  7. package/.output/public/assets/{StreamingChunkSequence-i3DM5IKL.js → StreamingChunkSequence-4v52v-7a.js} +1 -1
  8. package/.output/public/assets/_sessionId-DfkBPvCC.js +1 -0
  9. package/.output/public/assets/{index-Dqc2r1ea.js → index-BuhFRImh.js} +1 -1
  10. package/.output/public/assets/index-ChgjUix0.css +1 -0
  11. package/.output/public/assets/index-Uf87L52J.js +1 -0
  12. package/.output/public/assets/{json-viewer-D3QWQlSB.js → json-viewer-d2gWBDLO.js} +1 -1
  13. package/.output/public/assets/{main-ZhxhOCmF.js → main-Do-E-46G.js} +2 -2
  14. package/.output/server/{_sessionId-YFrP0lZP.mjs → _sessionId-B82aMW2A.mjs} +2 -2
  15. package/.output/server/_ssr/{CompareDrawer-qC3adEeq.mjs → CompareDrawer-Bud_yIrM.mjs} +2 -2
  16. package/.output/server/_ssr/{ProxyViewerContainer-DCZIJC2b.mjs → ProxyViewerContainer-DqgVb0So.mjs} +1976 -1988
  17. package/.output/server/_ssr/{ReplayDialog-CvX4XYCi.mjs → ReplayDialog-DKbV5fnW.mjs} +3 -3
  18. package/.output/server/_ssr/{RequestAnatomy-HQfrxjO1.mjs → RequestAnatomy-MStxp1Wp.mjs} +2 -2
  19. package/.output/server/_ssr/{ResponseView-QSlSD11e.mjs → ResponseView-HLTCpJcF.mjs} +2 -2
  20. package/.output/server/_ssr/{StreamingChunkSequence-DTAiwlnI.mjs → StreamingChunkSequence-DEiyiUs_.mjs} +2 -2
  21. package/.output/server/_ssr/{index-D_EzfXaN.mjs → index-DamOPFDI.mjs} +2 -2
  22. package/.output/server/_ssr/index.mjs +2 -2
  23. package/.output/server/_ssr/{json-viewer-CrIX0e0Q.mjs → json-viewer-MmTWKxqh.mjs} +2 -2
  24. package/.output/server/_ssr/{router-__o2wrfO.mjs → router-50BIB6ED.mjs} +545 -22
  25. package/.output/server/{_tanstack-start-manifest_v-DbqyLpsI.mjs → _tanstack-start-manifest_v-TSwb1vFc.mjs} +1 -1
  26. package/.output/server/index.mjs +66 -66
  27. package/package.json +1 -1
  28. package/src/components/proxy-viewer/ConversationGroupList.tsx +11 -11
  29. package/src/components/proxy-viewer/ConversationHeader.tsx +7 -7
  30. package/src/components/proxy-viewer/LogEntry.tsx +15 -26
  31. package/src/components/proxy-viewer/LogEntryHeader.tsx +11 -14
  32. package/src/components/proxy-viewer/RequestToolsPanel.tsx +15 -15
  33. package/src/components/proxy-viewer/ThreadConnector.tsx +75 -91
  34. package/src/components/proxy-viewer/ToolTraceEvents.tsx +1 -1
  35. package/src/components/proxy-viewer/TurnGroup.tsx +11 -14
  36. package/src/mcp/server.ts +275 -0
  37. package/src/mcp/toolHandlers.ts +380 -3
  38. package/src/proxy/logSearch.ts +3 -0
  39. package/src/proxy/store.ts +40 -15
  40. package/src/routes/api/logs.ts +8 -2
  41. package/.output/public/assets/ProxyViewerContainer-DbWjc_BE.js +0 -106
  42. package/.output/public/assets/_sessionId-CTpCHdFh.js +0 -1
  43. package/.output/public/assets/index-Blqvndcn.js +0 -1
  44. package/.output/public/assets/index-Cs79WRQj.css +0 -1
package/src/mcp/server.ts CHANGED
@@ -52,7 +52,9 @@ import {
52
52
  import { callApi } from "./loopback";
53
53
  import {
54
54
  addGroupSessionImpl,
55
+ addGroupProcessImpl,
55
56
  addProviderImpl,
57
+ diagnoseCaptureImpl,
56
58
  diagnoseProviderTestImpl,
57
59
  exportEvidenceBundleImpl,
58
60
  createGroupImpl,
@@ -66,8 +68,12 @@ import {
66
68
  exportGroupEvidenceBundleImpl,
67
69
  getGroupEvidenceFilesImpl,
68
70
  getGroupImpl,
71
+ getLogHeadersImpl,
69
72
  getRecentFailuresImpl,
73
+ getProcessImpl,
74
+ getProcessTimelineImpl,
70
75
  getProjectContextImpl,
76
+ getRuntimeConfigImpl,
71
77
  getRunImpl,
72
78
  getSessionImpl,
73
79
  getSessionTimelineImpl,
@@ -78,6 +84,7 @@ import {
78
84
  listKnowledgeCandidatesImpl,
79
85
  listLogsImpl,
80
86
  listModelsImpl,
87
+ listProcessesImpl,
81
88
  listProvidersImpl,
82
89
  listSessionsImpl,
83
90
  promoteKnowledgeCandidateImpl,
@@ -265,6 +272,10 @@ const LogResourceListResponseSchema = z.object({
265
272
  logs: z.array(z.object({ id: z.number().int().positive() })),
266
273
  });
267
274
 
275
+ const ProcessResourceListResponseSchema = z.object({
276
+ logs: z.array(z.object({ clientPid: z.number().int().positive().nullable().optional() })),
277
+ });
278
+
268
279
  type ResourceDescriptor = {
269
280
  uri: string;
270
281
  name: string;
@@ -317,6 +328,7 @@ const WRITE_TOOL_NAMES = new Set<string>([
317
328
  "inspector_update_group",
318
329
  "inspector_delete_group",
319
330
  "inspector_add_group_session",
331
+ "inspector_add_group_process",
320
332
  "inspector_export_group_evidence",
321
333
  "inspector_export_group_evidence_bundle",
322
334
  "inspector_set_current_context",
@@ -514,6 +526,44 @@ async function listLogResources(): Promise<ListResourcesResult> {
514
526
  }
515
527
  }
516
528
 
529
+ async function listProcessResources(): Promise<ListResourcesResult> {
530
+ try {
531
+ const response = await callApi("/api/logs?q=&offset=0&limit=50&scanLimit=200");
532
+ if (!response.ok) return listResult([]);
533
+ const parsed = ProcessResourceListResponseSchema.safeParse(await response.json());
534
+ if (!parsed.success) return listResult([]);
535
+ const pids = [
536
+ ...new Set(
537
+ parsed.data.logs
538
+ .map((log) => log.clientPid ?? null)
539
+ .filter((pid): pid is number => pid !== null),
540
+ ),
541
+ ].sort((left, right) => left - right);
542
+ return listResult(
543
+ pids.map((pid) => ({
544
+ uri: `inspector://processes/${String(pid)}`,
545
+ name: `process:${String(pid)}`,
546
+ title: `Inspector process ${String(pid)}`,
547
+ mimeType: "application/json",
548
+ })),
549
+ );
550
+ } catch {
551
+ return listResult([]);
552
+ }
553
+ }
554
+
555
+ async function listProcessTimelineResources(): Promise<ListResourcesResult> {
556
+ const processResources = await listProcessResources();
557
+ return listResult(
558
+ processResources.resources.map((resource) => ({
559
+ uri: `${resource.uri}/timeline`,
560
+ name: `${resource.name}:timeline`,
561
+ title: `${resource.title ?? resource.name} timeline`,
562
+ mimeType: "application/json",
563
+ })),
564
+ );
565
+ }
566
+
517
567
  function listRunResources(): ListResourcesResult {
518
568
  return listResult(
519
569
  listInspectorRuns().runs.map((run) => ({
@@ -639,6 +689,12 @@ function registerTools(server: McpServer): void {
639
689
  .describe("How many summaries to return. Hard-capped at 5."),
640
690
  sessionId: z.string().optional().describe("Filter by session/affinity id."),
641
691
  model: z.string().optional().describe("Filter by model name."),
692
+ clientPid: z
693
+ .number()
694
+ .int()
695
+ .positive()
696
+ .optional()
697
+ .describe("Filter by originating client process PID."),
642
698
  }),
643
699
  },
644
700
  (args) => safeCall(() => listLogsImpl(callApi, args)),
@@ -671,6 +727,12 @@ function registerTools(server: McpServer): void {
671
727
  .describe("How many recent compact logs to scan before filtering. Default 200."),
672
728
  sessionId: z.string().optional().describe("Optional session/affinity id filter."),
673
729
  model: z.string().optional().describe("Optional model name filter."),
730
+ clientPid: z
731
+ .number()
732
+ .int()
733
+ .positive()
734
+ .optional()
735
+ .describe("Optional originating client process PID filter."),
674
736
  }),
675
737
  },
676
738
  (args) => safeCall(() => searchLogsImpl(callApi, args)),
@@ -702,6 +764,87 @@ function registerTools(server: McpServer): void {
702
764
  ({ id }) => safeCall(() => getLogChunksImpl(callApi, id)),
703
765
  );
704
766
 
767
+ server.registerTool(
768
+ "inspector_get_log_headers",
769
+ {
770
+ title: "Get captured log headers",
771
+ description:
772
+ "Returns header-focused evidence for one log without large request/response bodies: raw headers, upstream headers, user-agent, origin, client PID/port, session id, model, and API path.",
773
+ inputSchema: z.object({
774
+ id: z.number().int().positive().describe("The log id."),
775
+ }),
776
+ },
777
+ ({ id }) => safeCall(() => getLogHeadersImpl(callApi, id)),
778
+ );
779
+
780
+ server.registerTool(
781
+ "inspector_list_processes",
782
+ {
783
+ title: "List observed client processes",
784
+ description:
785
+ "Groups recent compact logs by originating client PID and returns sessions, agents, user-agents, models, providers, ports, error counts, and latest logs. Useful for IDE -> process -> session navigation.",
786
+ inputSchema: z.object({
787
+ scanLimit: z
788
+ .number()
789
+ .int()
790
+ .positive()
791
+ .max(200)
792
+ .optional()
793
+ .describe("How many recent logs to scan. Default 50, max 200."),
794
+ limit: z
795
+ .number()
796
+ .int()
797
+ .positive()
798
+ .max(200)
799
+ .optional()
800
+ .describe("Alias for scanLimit for simpler MCP clients."),
801
+ }),
802
+ },
803
+ (args) => safeCall(() => listProcessesImpl(callApi, args)),
804
+ );
805
+
806
+ server.registerTool(
807
+ "inspector_get_process",
808
+ {
809
+ title: "Get process summary",
810
+ description:
811
+ "Returns a bounded summary for one originating client PID across sessions, including user-agents, ports, models, providers, errors, and latest compact logs.",
812
+ inputSchema: z.object({
813
+ clientPid: z.number().int().positive().describe("Originating client process PID."),
814
+ offset: z.number().int().nonnegative().optional().describe("Skip this many matching logs."),
815
+ limit: z
816
+ .number()
817
+ .int()
818
+ .positive()
819
+ .max(200)
820
+ .optional()
821
+ .describe("Maximum logs to summarize. Default 50, max 200."),
822
+ }),
823
+ },
824
+ (args) => safeCall(() => getProcessImpl(callApi, args)),
825
+ );
826
+
827
+ server.registerTool(
828
+ "inspector_get_process_timeline",
829
+ {
830
+ title: "Get process timeline",
831
+ description:
832
+ "Returns a bounded chronological timeline for one originating client PID, spanning all sessions observed for that process.",
833
+ inputSchema: z.object({
834
+ clientPid: z.number().int().positive().describe("Originating client process PID."),
835
+ offset: z.number().int().nonnegative().optional().describe("Skip this many matching logs."),
836
+ limit: z
837
+ .number()
838
+ .int()
839
+ .positive()
840
+ .max(50)
841
+ .optional()
842
+ .describe("Maximum timeline events to return. Default 20, max 50."),
843
+ }),
844
+ },
845
+ (args) => safeCall(() => getProcessTimelineImpl(callApi, args)),
846
+ );
847
+
705
848
  server.registerTool(
706
849
  "inspector_list_sessions",
707
850
  {
@@ -790,6 +933,30 @@ function registerTools(server: McpServer): void {
790
933
  (args) => safeWriteCall("inspector_set_current_context", () => setCurrentContextImpl(args)),
791
934
  );
792
935
 
936
+ server.registerTool(
937
+ "inspector_get_runtime_config",
938
+ {
939
+ title: "Get Inspector runtime config",
940
+ description:
941
+ "Read-only runtime diagnostics: current proxy config plus log storage stats, including captureMode and log/chunk directories. Does not expose provider secrets.",
942
+ inputSchema: z.object({}),
943
+ },
944
+ () => safeCall(() => getRuntimeConfigImpl(callApi)),
945
+ );
946
+
947
+ server.registerTool(
948
+ "inspector_diagnose_capture",
949
+ {
950
+ title: "Diagnose capture detail availability",
951
+ description:
952
+ "Explains why headers or bodies may be missing for the current runtime or a specific log, including captureMode, compact body mode, rawHeaders presence, and next-step recommendations.",
953
+ inputSchema: z.object({
954
+ id: z.number().int().positive().optional().describe("Optional log id to inspect."),
955
+ }),
956
+ },
957
+ (args) => safeCall(() => diagnoseCaptureImpl(callApi, args)),
958
+ );
959
+
793
960
  server.registerTool(
794
961
  "inspector_create_run",
795
962
  {
@@ -1009,6 +1176,26 @@ function registerTools(server: McpServer): void {
1009
1176
  (args) => safeWriteCall("inspector_add_group_session", () => addGroupSessionImpl(args)),
1010
1177
  );
1011
1178
 
1179
+ server.registerTool(
1180
+ "inspector_add_group_process",
1181
+ {
1182
+ title: "Attach a process to an Inspector group",
1183
+ description:
1184
+ "Finds sessions observed for one client PID and attaches each session to a group with inferred agent/model/provider metadata. Useful when a process has both process fallback and explicit sessions.",
1185
+ inputSchema: z.object({
1186
+ groupId: z.string().min(1).describe("The Inspector group id."),
1187
+ clientPid: z.number().int().positive().describe("Originating client process PID."),
1188
+ labelPrefix: z
1189
+ .string()
1190
+ .min(1)
1191
+ .optional()
1192
+ .describe("Optional label prefix. Defaults to PID <clientPid>."),
1193
+ }),
1194
+ },
1195
+ (args) =>
1196
+ safeWriteCall("inspector_add_group_process", () => addGroupProcessImpl(callApi, args)),
1197
+ );
1198
+
1012
1199
  server.registerTool(
1013
1200
  "inspector_export_group_evidence",
1014
1201
  {
@@ -1281,6 +1468,22 @@ function registerResources(server: McpServer): void {
1281
1468
  (uri) => jsonResource(uri, getCurrentContext()),
1282
1469
  );
1283
1470
 
1471
+ server.registerResource(
1472
+ "inspector_runtime_config",
1473
+ "inspector://runtime/config",
1474
+ {
1475
+ title: "Inspector runtime config",
1476
+ description: "Read-only runtime config and log storage stats.",
1477
+ mimeType: "application/json",
1478
+ },
1479
+ async (uri) => {
1480
+ const result = await getRuntimeConfigImpl(callApi);
1481
+ const first = result.content[0];
1482
+ const text = first?.text ?? "";
1483
+ return textResource(uri, result.isError === true ? "text/plain" : "application/json", text);
1484
+ },
1485
+ );
1486
+
1284
1487
  server.registerResource(
1285
1488
  "inspector_sessions",
1286
1489
  "inspector://sessions",
@@ -1351,6 +1554,67 @@ function registerResources(server: McpServer): void {
1351
1554
  },
1352
1555
  );
1353
1556
 
1557
+ server.registerResource(
1558
+ "inspector_processes",
1559
+ "inspector://processes",
1560
+ {
1561
+ title: "Inspector client processes",
1562
+ description: "Observed originating client process PIDs grouped from recent logs.",
1563
+ mimeType: "application/json",
1564
+ },
1565
+ async (uri) => {
1566
+ const result = await listProcessesImpl(callApi, { scanLimit: 200 });
1567
+ const first = result.content[0];
1568
+ const text = first?.text ?? "";
1569
+ return textResource(uri, result.isError === true ? "text/plain" : "application/json", text);
1570
+ },
1571
+ );
1572
+
1573
+ server.registerResource(
1574
+ "inspector_process",
1575
+ new ResourceTemplate("inspector://processes/{clientPid}", { list: listProcessResources }),
1576
+ {
1577
+ title: "Inspector process",
1578
+ description:
1579
+ "One originating client process summary with sessions, agents, user-agents, ports, models, providers, errors, and latest logs.",
1580
+ mimeType: "application/json",
1581
+ },
1582
+ async (uri, variables) => {
1583
+ const clientPid = variableString(variables, "clientPid");
1584
+ const parsed = clientPid === null ? Number.NaN : Number(clientPid);
1585
+ if (!Number.isInteger(parsed) || parsed <= 0) {
1586
+ return textResource(uri, "text/plain", "Invalid clientPid");
1587
+ }
1588
+ const result = await getProcessImpl(callApi, { clientPid: parsed });
1589
+ const first = result.content[0];
1590
+ const text = first?.text ?? "";
1591
+ return textResource(uri, result.isError === true ? "text/plain" : "application/json", text);
1592
+ },
1593
+ );
1594
+
1595
+ server.registerResource(
1596
+ "inspector_process_timeline",
1597
+ new ResourceTemplate("inspector://processes/{clientPid}/timeline", {
1598
+ list: listProcessTimelineResources,
1599
+ }),
1600
+ {
1601
+ title: "Inspector process timeline",
1602
+ description: "Bounded chronological timeline for one originating client process PID.",
1603
+ mimeType: "application/json",
1604
+ },
1605
+ async (uri, variables) => {
1606
+ const clientPid = variableString(variables, "clientPid");
1607
+ const parsed = clientPid === null ? Number.NaN : Number(clientPid);
1608
+ if (!Number.isInteger(parsed) || parsed <= 0) {
1609
+ return textResource(uri, "text/plain", "Invalid clientPid");
1610
+ }
1611
+ const result = await getProcessTimelineImpl(callApi, { clientPid: parsed, limit: 50 });
1612
+ const first = result.content[0];
1613
+ const text = first?.text ?? "";
1614
+ return textResource(uri, result.isError === true ? "text/plain" : "application/json", text);
1615
+ },
1616
+ );
1617
+
1354
1618
  server.registerResource(
1355
1619
  "inspector_runs",
1356
1620
  "inspector://runs",
@@ -1661,11 +1925,17 @@ export const TOOL_NAMES = [
1661
1925
  "inspector_search_logs",
1662
1926
  "inspector_get_log",
1663
1927
  "inspector_get_log_chunks",
1928
+ "inspector_get_log_headers",
1929
+ "inspector_list_processes",
1930
+ "inspector_get_process",
1931
+ "inspector_get_process_timeline",
1664
1932
  "inspector_list_sessions",
1665
1933
  "inspector_get_session",
1666
1934
  "inspector_get_session_timeline",
1667
1935
  "inspector_get_current_context",
1668
1936
  "inspector_set_current_context",
1937
+ "inspector_get_runtime_config",
1938
+ "inspector_diagnose_capture",
1669
1939
  "inspector_create_run",
1670
1940
  "inspector_get_run",
1671
1941
  "inspector_update_run",
@@ -1679,6 +1949,7 @@ export const TOOL_NAMES = [
1679
1949
  "inspector_update_group",
1680
1950
  "inspector_delete_group",
1681
1951
  "inspector_add_group_session",
1952
+ "inspector_add_group_process",
1682
1953
  "inspector_export_group_evidence",
1683
1954
  "inspector_get_group_evidence_files",
1684
1955
  "inspector_export_group_evidence_bundle",
@@ -1702,10 +1973,14 @@ export const RESOURCE_NAMES = [
1702
1973
  "inspector_mcp_capabilities",
1703
1974
  "inspector_mcp_config",
1704
1975
  "inspector_current_context",
1976
+ "inspector_runtime_config",
1705
1977
  "inspector_sessions",
1706
1978
  "inspector_session",
1707
1979
  "inspector_session_timeline",
1708
1980
  "inspector_log",
1981
+ "inspector_processes",
1982
+ "inspector_process",
1983
+ "inspector_process_timeline",
1709
1984
  "inspector_runs",
1710
1985
  "inspector_recent_failures",
1711
1986
  "inspector_run",