@mcp-shark/mcp-shark 1.4.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.
Files changed (212) hide show
  1. package/LICENSE +85 -0
  2. package/README.md +724 -0
  3. package/bin/mcp-shark.js +93 -0
  4. package/mcp-server/.editorconfig +15 -0
  5. package/mcp-server/.prettierignore +11 -0
  6. package/mcp-server/.prettierrc +12 -0
  7. package/mcp-server/README.md +280 -0
  8. package/mcp-server/commitlint.config.cjs +42 -0
  9. package/mcp-server/eslint.config.js +131 -0
  10. package/mcp-server/lib/auditor/audit.js +228 -0
  11. package/mcp-server/lib/common/error.js +15 -0
  12. package/mcp-server/lib/server/external/all.js +32 -0
  13. package/mcp-server/lib/server/external/config.js +59 -0
  14. package/mcp-server/lib/server/external/kv.js +102 -0
  15. package/mcp-server/lib/server/external/single/client.js +35 -0
  16. package/mcp-server/lib/server/external/single/request.js +49 -0
  17. package/mcp-server/lib/server/external/single/run.js +75 -0
  18. package/mcp-server/lib/server/external/single/transport.js +57 -0
  19. package/mcp-server/lib/server/internal/handlers/common.js +20 -0
  20. package/mcp-server/lib/server/internal/handlers/error.js +7 -0
  21. package/mcp-server/lib/server/internal/handlers/prompts-get.js +22 -0
  22. package/mcp-server/lib/server/internal/handlers/prompts-list.js +12 -0
  23. package/mcp-server/lib/server/internal/handlers/resources-list.js +12 -0
  24. package/mcp-server/lib/server/internal/handlers/resources-read.js +19 -0
  25. package/mcp-server/lib/server/internal/handlers/tools-call.js +37 -0
  26. package/mcp-server/lib/server/internal/handlers/tools-list.js +14 -0
  27. package/mcp-server/lib/server/internal/run.js +49 -0
  28. package/mcp-server/lib/server/internal/server.js +63 -0
  29. package/mcp-server/lib/server/internal/session.js +39 -0
  30. package/mcp-server/mcp-shark.js +72 -0
  31. package/mcp-server/package-lock.json +4784 -0
  32. package/mcp-server/package.json +30 -0
  33. package/package.json +103 -0
  34. package/ui/README.md +212 -0
  35. package/ui/index.html +16 -0
  36. package/ui/package-lock.json +3574 -0
  37. package/ui/package.json +12 -0
  38. package/ui/paths.js +282 -0
  39. package/ui/public/og-image.png +0 -0
  40. package/ui/server/routes/backups.js +251 -0
  41. package/ui/server/routes/composite.js +244 -0
  42. package/ui/server/routes/config.js +175 -0
  43. package/ui/server/routes/conversations.js +25 -0
  44. package/ui/server/routes/help.js +43 -0
  45. package/ui/server/routes/logs.js +32 -0
  46. package/ui/server/routes/playground.js +152 -0
  47. package/ui/server/routes/requests.js +235 -0
  48. package/ui/server/routes/sessions.js +27 -0
  49. package/ui/server/routes/smartscan/discover.js +117 -0
  50. package/ui/server/routes/smartscan/scans/clearCache.js +22 -0
  51. package/ui/server/routes/smartscan/scans/createBatchScans.js +123 -0
  52. package/ui/server/routes/smartscan/scans/createScan.js +42 -0
  53. package/ui/server/routes/smartscan/scans/getCachedResults.js +51 -0
  54. package/ui/server/routes/smartscan/scans/getScan.js +41 -0
  55. package/ui/server/routes/smartscan/scans/listScans.js +24 -0
  56. package/ui/server/routes/smartscan/scans.js +13 -0
  57. package/ui/server/routes/smartscan/token.js +56 -0
  58. package/ui/server/routes/smartscan/transport.js +53 -0
  59. package/ui/server/routes/smartscan.js +24 -0
  60. package/ui/server/routes/statistics.js +83 -0
  61. package/ui/server/utils/config-update.js +212 -0
  62. package/ui/server/utils/config.js +98 -0
  63. package/ui/server/utils/paths.js +23 -0
  64. package/ui/server/utils/port.js +28 -0
  65. package/ui/server/utils/process.js +80 -0
  66. package/ui/server/utils/scan-cache/all-results.js +180 -0
  67. package/ui/server/utils/scan-cache/directory.js +35 -0
  68. package/ui/server/utils/scan-cache/file-operations.js +104 -0
  69. package/ui/server/utils/scan-cache/hash.js +47 -0
  70. package/ui/server/utils/scan-cache/server-operations.js +80 -0
  71. package/ui/server/utils/scan-cache.js +12 -0
  72. package/ui/server/utils/serialization.js +13 -0
  73. package/ui/server/utils/smartscan-token.js +42 -0
  74. package/ui/server.js +199 -0
  75. package/ui/src/App.jsx +153 -0
  76. package/ui/src/CompositeLogs.jsx +164 -0
  77. package/ui/src/CompositeSetup.jsx +285 -0
  78. package/ui/src/HelpGuide/HelpGuideContent.jsx +118 -0
  79. package/ui/src/HelpGuide/HelpGuideFooter.jsx +58 -0
  80. package/ui/src/HelpGuide/HelpGuideHeader.jsx +56 -0
  81. package/ui/src/HelpGuide.jsx +65 -0
  82. package/ui/src/IntroTour.jsx +140 -0
  83. package/ui/src/LogDetail.jsx +122 -0
  84. package/ui/src/LogTable.jsx +242 -0
  85. package/ui/src/PacketDetail.jsx +190 -0
  86. package/ui/src/PacketFilters.jsx +222 -0
  87. package/ui/src/PacketList.jsx +183 -0
  88. package/ui/src/SmartScan.jsx +178 -0
  89. package/ui/src/TabNavigation.jsx +143 -0
  90. package/ui/src/components/App/HelpButton.jsx +64 -0
  91. package/ui/src/components/App/TrafficTab.jsx +69 -0
  92. package/ui/src/components/App/useAppState.js +163 -0
  93. package/ui/src/components/BackupList.jsx +192 -0
  94. package/ui/src/components/CollapsibleSection.jsx +82 -0
  95. package/ui/src/components/ConfigFileSection.jsx +84 -0
  96. package/ui/src/components/ConfigViewerModal.jsx +141 -0
  97. package/ui/src/components/ConfirmationModal.jsx +129 -0
  98. package/ui/src/components/DetailsTab/BodySection.jsx +27 -0
  99. package/ui/src/components/DetailsTab/CollapsibleRequestResponse.jsx +70 -0
  100. package/ui/src/components/DetailsTab/HeadersSection.jsx +25 -0
  101. package/ui/src/components/DetailsTab/InfoSection.jsx +28 -0
  102. package/ui/src/components/DetailsTab/NetworkInfoSection.jsx +63 -0
  103. package/ui/src/components/DetailsTab/ProtocolInfoSection.jsx +75 -0
  104. package/ui/src/components/DetailsTab/RequestDetailsSection.jsx +46 -0
  105. package/ui/src/components/DetailsTab/ResponseDetailsSection.jsx +66 -0
  106. package/ui/src/components/DetailsTab.jsx +31 -0
  107. package/ui/src/components/DetectedPathsList.jsx +171 -0
  108. package/ui/src/components/FileInput.jsx +144 -0
  109. package/ui/src/components/GroupHeader.jsx +76 -0
  110. package/ui/src/components/GroupedByMcpView.jsx +103 -0
  111. package/ui/src/components/GroupedByServerView.jsx +134 -0
  112. package/ui/src/components/GroupedBySessionView.jsx +127 -0
  113. package/ui/src/components/GroupedViews.jsx +2 -0
  114. package/ui/src/components/HexTab.jsx +188 -0
  115. package/ui/src/components/LogsDisplay.jsx +93 -0
  116. package/ui/src/components/LogsToolbar.jsx +193 -0
  117. package/ui/src/components/McpPlayground/LoadingModal.jsx +113 -0
  118. package/ui/src/components/McpPlayground/PromptsSection/PromptCallPanel.jsx +125 -0
  119. package/ui/src/components/McpPlayground/PromptsSection/PromptItem.jsx +48 -0
  120. package/ui/src/components/McpPlayground/PromptsSection/PromptsList.jsx +45 -0
  121. package/ui/src/components/McpPlayground/PromptsSection.jsx +106 -0
  122. package/ui/src/components/McpPlayground/ResourcesSection/ResourceCallPanel.jsx +89 -0
  123. package/ui/src/components/McpPlayground/ResourcesSection/ResourceItem.jsx +59 -0
  124. package/ui/src/components/McpPlayground/ResourcesSection/ResourcesList.jsx +45 -0
  125. package/ui/src/components/McpPlayground/ResourcesSection.jsx +91 -0
  126. package/ui/src/components/McpPlayground/ToolsSection/ToolCallPanel.jsx +125 -0
  127. package/ui/src/components/McpPlayground/ToolsSection/ToolItem.jsx +48 -0
  128. package/ui/src/components/McpPlayground/ToolsSection/ToolsList.jsx +45 -0
  129. package/ui/src/components/McpPlayground/ToolsSection.jsx +107 -0
  130. package/ui/src/components/McpPlayground/common/EmptyState.jsx +17 -0
  131. package/ui/src/components/McpPlayground/common/ErrorState.jsx +17 -0
  132. package/ui/src/components/McpPlayground/common/LoadingState.jsx +17 -0
  133. package/ui/src/components/McpPlayground/useMcpPlayground.js +280 -0
  134. package/ui/src/components/McpPlayground.jsx +171 -0
  135. package/ui/src/components/MessageDisplay.jsx +28 -0
  136. package/ui/src/components/PacketDetailHeader.jsx +88 -0
  137. package/ui/src/components/PacketFilters/ExportControls.jsx +126 -0
  138. package/ui/src/components/PacketFilters/FilterInput.jsx +59 -0
  139. package/ui/src/components/RawTab.jsx +142 -0
  140. package/ui/src/components/RequestRow/OrphanedResponseRow.jsx +155 -0
  141. package/ui/src/components/RequestRow/RequestRowMain.jsx +240 -0
  142. package/ui/src/components/RequestRow/ResponseRow.jsx +158 -0
  143. package/ui/src/components/RequestRow.jsx +70 -0
  144. package/ui/src/components/ServerControl.jsx +133 -0
  145. package/ui/src/components/ServiceSelector.jsx +209 -0
  146. package/ui/src/components/SetupHeader.jsx +30 -0
  147. package/ui/src/components/SharkLogo.jsx +21 -0
  148. package/ui/src/components/SmartScan/AnalysisResult.jsx +64 -0
  149. package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultItem.jsx +215 -0
  150. package/ui/src/components/SmartScan/BatchResultsDisplay/BatchResultsHeader.jsx +94 -0
  151. package/ui/src/components/SmartScan/BatchResultsDisplay.jsx +26 -0
  152. package/ui/src/components/SmartScan/DebugInfoSection.jsx +53 -0
  153. package/ui/src/components/SmartScan/EmptyState.jsx +57 -0
  154. package/ui/src/components/SmartScan/ErrorDisplay.jsx +48 -0
  155. package/ui/src/components/SmartScan/ExpandableSection.jsx +93 -0
  156. package/ui/src/components/SmartScan/FindingsTable.jsx +257 -0
  157. package/ui/src/components/SmartScan/ListViewContent.jsx +75 -0
  158. package/ui/src/components/SmartScan/NotablePatternsSection.jsx +75 -0
  159. package/ui/src/components/SmartScan/OverallSummarySection.jsx +72 -0
  160. package/ui/src/components/SmartScan/RawDataSection.jsx +52 -0
  161. package/ui/src/components/SmartScan/RecommendationsSection.jsx +78 -0
  162. package/ui/src/components/SmartScan/ScanDetailHeader.jsx +92 -0
  163. package/ui/src/components/SmartScan/ScanDetailView.jsx +141 -0
  164. package/ui/src/components/SmartScan/ScanListView/ScanListHeader.jsx +49 -0
  165. package/ui/src/components/SmartScan/ScanListView/ScanListItem.jsx +201 -0
  166. package/ui/src/components/SmartScan/ScanListView.jsx +73 -0
  167. package/ui/src/components/SmartScan/ScanOverviewSection.jsx +123 -0
  168. package/ui/src/components/SmartScan/ScanResultsDisplay.jsx +35 -0
  169. package/ui/src/components/SmartScan/ScanViewContent.jsx +68 -0
  170. package/ui/src/components/SmartScan/ScanningProgress.jsx +47 -0
  171. package/ui/src/components/SmartScan/ServerInfoSection.jsx +43 -0
  172. package/ui/src/components/SmartScan/ServerSelectionRow.jsx +207 -0
  173. package/ui/src/components/SmartScan/SingleResultDisplay.jsx +269 -0
  174. package/ui/src/components/SmartScan/SmartScanControls.jsx +290 -0
  175. package/ui/src/components/SmartScan/SmartScanHeader.jsx +77 -0
  176. package/ui/src/components/SmartScan/ViewModeTabs.jsx +57 -0
  177. package/ui/src/components/SmartScan/hooks/useCacheManagement.js +34 -0
  178. package/ui/src/components/SmartScan/hooks/useMcpDiscovery.js +121 -0
  179. package/ui/src/components/SmartScan/hooks/useScanList.js +193 -0
  180. package/ui/src/components/SmartScan/hooks/useScanOperations.js +87 -0
  181. package/ui/src/components/SmartScan/hooks/useServerStatus.js +26 -0
  182. package/ui/src/components/SmartScan/hooks/useTokenManagement.js +53 -0
  183. package/ui/src/components/SmartScan/scanDataUtils.js +98 -0
  184. package/ui/src/components/SmartScan/useSmartScan.js +72 -0
  185. package/ui/src/components/SmartScan/utils.js +19 -0
  186. package/ui/src/components/SmartScanIcons.jsx +58 -0
  187. package/ui/src/components/TabNavigation/DesktopTabs.jsx +111 -0
  188. package/ui/src/components/TabNavigation/MobileDropdown.jsx +140 -0
  189. package/ui/src/components/TabNavigation.jsx +97 -0
  190. package/ui/src/components/TabNavigationIcons.jsx +40 -0
  191. package/ui/src/components/TableHeader.jsx +164 -0
  192. package/ui/src/components/TourOverlay.jsx +117 -0
  193. package/ui/src/components/TourTooltip/TourTooltipButtons.jsx +117 -0
  194. package/ui/src/components/TourTooltip/TourTooltipHeader.jsx +70 -0
  195. package/ui/src/components/TourTooltip/TourTooltipIcons.jsx +45 -0
  196. package/ui/src/components/TourTooltip/useTooltipPosition.js +108 -0
  197. package/ui/src/components/TourTooltip.jsx +83 -0
  198. package/ui/src/components/ViewModeTabs.jsx +91 -0
  199. package/ui/src/components/WhatThisDoesSection.jsx +61 -0
  200. package/ui/src/config/tourSteps.jsx +141 -0
  201. package/ui/src/hooks/useAnimation.js +92 -0
  202. package/ui/src/hooks/useConfigManagement.js +124 -0
  203. package/ui/src/hooks/useServiceExtraction.js +51 -0
  204. package/ui/src/index.css +42 -0
  205. package/ui/src/main.jsx +10 -0
  206. package/ui/src/theme.js +65 -0
  207. package/ui/src/utils/animations.js +170 -0
  208. package/ui/src/utils/groupingUtils.js +93 -0
  209. package/ui/src/utils/hexUtils.js +24 -0
  210. package/ui/src/utils/mcpGroupingUtils.js +262 -0
  211. package/ui/src/utils/requestUtils.js +297 -0
  212. package/ui/vite.config.js +18 -0
@@ -0,0 +1,140 @@
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import TourOverlay from './components/TourOverlay';
3
+ import TourTooltip from './components/TourTooltip';
4
+
5
+ function IntroTour({ steps, onComplete, onSkip, onStepChange }) {
6
+ const [currentStep, setCurrentStep] = useState(0);
7
+ const [highlightedElement, setHighlightedElement] = useState(null);
8
+ const [elementRect, setElementRect] = useState(null);
9
+ const overlayRef = useRef(null);
10
+
11
+ useEffect(() => {
12
+ if (!highlightedElement) return;
13
+
14
+ const updatePosition = () => {
15
+ if (highlightedElement) {
16
+ const rect = highlightedElement.getBoundingClientRect();
17
+ setElementRect(rect);
18
+ }
19
+ };
20
+
21
+ updatePosition();
22
+
23
+ const options = { passive: true, capture: true };
24
+ window.addEventListener('scroll', updatePosition, options);
25
+ window.addEventListener('resize', updatePosition, { passive: true });
26
+
27
+ return () => {
28
+ window.removeEventListener('scroll', updatePosition, options);
29
+ window.removeEventListener('resize', updatePosition, { passive: true });
30
+ };
31
+ }, [highlightedElement]);
32
+
33
+ useEffect(() => {
34
+ if (steps.length === 0) return;
35
+
36
+ const step = steps[currentStep];
37
+ if (!step) return;
38
+
39
+ if (onStepChange) {
40
+ onStepChange(currentStep);
41
+ }
42
+
43
+ const timer = setTimeout(() => {
44
+ const element = document.querySelector(step.target);
45
+ if (element) {
46
+ setHighlightedElement(element);
47
+ element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' });
48
+ setTimeout(() => {
49
+ const rect = element.getBoundingClientRect();
50
+ setElementRect(rect);
51
+ }, 300);
52
+ } else {
53
+ setHighlightedElement(null);
54
+ setElementRect(null);
55
+ }
56
+ }, 200);
57
+
58
+ return () => clearTimeout(timer);
59
+ }, [currentStep, steps, onStepChange]);
60
+
61
+ const handleNext = () => {
62
+ if (currentStep < steps.length - 1) {
63
+ const nextStep = currentStep + 1;
64
+ setCurrentStep(nextStep);
65
+ if (onStepChange) {
66
+ onStepChange(nextStep);
67
+ }
68
+ } else {
69
+ handleComplete();
70
+ }
71
+ };
72
+
73
+ const handlePrevious = () => {
74
+ if (currentStep > 0) {
75
+ const prevStep = currentStep - 1;
76
+ setCurrentStep(prevStep);
77
+ if (onStepChange) {
78
+ onStepChange(prevStep);
79
+ }
80
+ }
81
+ };
82
+
83
+ const handleComplete = async () => {
84
+ try {
85
+ await fetch('/api/help/dismiss', {
86
+ method: 'POST',
87
+ headers: { 'Content-Type': 'application/json' },
88
+ body: JSON.stringify({ tourCompleted: true }),
89
+ });
90
+ } catch (error) {
91
+ console.error('Failed to save tour state:', error);
92
+ }
93
+ onComplete();
94
+ };
95
+
96
+ const handleSkip = () => {
97
+ handleComplete();
98
+ if (onSkip) onSkip();
99
+ };
100
+
101
+ if (steps.length === 0 || currentStep >= steps.length) {
102
+ return null;
103
+ }
104
+
105
+ const step = steps[currentStep];
106
+
107
+ return (
108
+ <>
109
+ <div
110
+ ref={overlayRef}
111
+ style={{
112
+ position: 'fixed',
113
+ top: 0,
114
+ left: 0,
115
+ right: 0,
116
+ bottom: 0,
117
+ zIndex: 9998,
118
+ pointerEvents: 'auto',
119
+ }}
120
+ onClick={handleSkip}
121
+ >
122
+ <TourOverlay elementRect={elementRect} />
123
+ </div>
124
+
125
+ {elementRect && (
126
+ <TourTooltip
127
+ elementRect={elementRect}
128
+ step={step}
129
+ currentStep={currentStep}
130
+ totalSteps={steps.length}
131
+ onNext={handleNext}
132
+ onPrevious={handlePrevious}
133
+ onSkip={handleSkip}
134
+ />
135
+ )}
136
+ </>
137
+ );
138
+ }
139
+
140
+ export default IntroTour;
@@ -0,0 +1,122 @@
1
+ import { colors, fonts } from './theme';
2
+
3
+ function LogDetail({ log, onClose }) {
4
+ const payload = log.payload_json ? JSON.parse(log.payload_json) : null;
5
+
6
+ return (
7
+ <div style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
8
+ <div
9
+ style={{
10
+ padding: '12px',
11
+ borderBottom: `1px solid ${colors.borderLight}`,
12
+ display: 'flex',
13
+ justifyContent: 'space-between',
14
+ alignItems: 'center',
15
+ }}
16
+ >
17
+ <h3 style={{ fontSize: '14px', fontWeight: 'normal' }}>Details</h3>
18
+ <button
19
+ onClick={onClose}
20
+ style={{
21
+ background: 'none',
22
+ border: 'none',
23
+ color: colors.textPrimary,
24
+ cursor: 'pointer',
25
+ fontSize: '18px',
26
+ }}
27
+ >
28
+ ×
29
+ </button>
30
+ </div>
31
+ <div style={{ flex: 1, overflow: 'auto', padding: '12px', fontSize: '12px' }}>
32
+ <div style={{ marginBottom: '16px' }}>
33
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
34
+ ID
35
+ </div>
36
+ <div style={{ fontFamily: 'monospace' }}>{log.id}</div>
37
+ </div>
38
+ <div style={{ marginBottom: '16px' }}>
39
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
40
+ Timestamp
41
+ </div>
42
+ <div style={{ fontFamily: 'monospace' }}>{log.timestamp_iso}</div>
43
+ </div>
44
+ <div style={{ marginBottom: '16px' }}>
45
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
46
+ Server
47
+ </div>
48
+ <div>{log.server_name}</div>
49
+ </div>
50
+ <div style={{ marginBottom: '16px' }}>
51
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
52
+ Direction
53
+ </div>
54
+ <div>{log.direction}</div>
55
+ </div>
56
+ <div style={{ marginBottom: '16px' }}>
57
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
58
+ Method
59
+ </div>
60
+ <div>{log.method || '-'}</div>
61
+ </div>
62
+ <div style={{ marginBottom: '16px' }}>
63
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
64
+ Status
65
+ </div>
66
+ <div>{log.status || '-'}</div>
67
+ </div>
68
+ {log.request_id && (
69
+ <div style={{ marginBottom: '16px' }}>
70
+ <div
71
+ style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}
72
+ >
73
+ Request ID
74
+ </div>
75
+ <div style={{ fontFamily: 'monospace', fontSize: '11px' }}>{log.request_id}</div>
76
+ </div>
77
+ )}
78
+ {log.duration_ms && (
79
+ <div style={{ marginBottom: '16px' }}>
80
+ <div
81
+ style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}
82
+ >
83
+ Duration
84
+ </div>
85
+ <div>{log.duration_ms.toFixed(2)}ms</div>
86
+ </div>
87
+ )}
88
+ {log.error_message && (
89
+ <div style={{ marginBottom: '16px' }}>
90
+ <div
91
+ style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}
92
+ >
93
+ Error
94
+ </div>
95
+ <div style={{ color: colors.error, fontFamily: fonts.body }}>{log.error_message}</div>
96
+ </div>
97
+ )}
98
+ <div style={{ marginBottom: '16px' }}>
99
+ <div style={{ color: colors.textTertiary, marginBottom: '4px', fontFamily: fonts.body }}>
100
+ Payload
101
+ </div>
102
+ <pre
103
+ style={{
104
+ background: colors.bgTertiary,
105
+ padding: '8px',
106
+ borderRadius: '8px',
107
+ border: `1px solid ${colors.borderLight}`,
108
+ overflow: 'auto',
109
+ fontSize: '11px',
110
+ fontFamily: 'monospace',
111
+ maxHeight: '400px',
112
+ }}
113
+ >
114
+ {JSON.stringify(payload, null, 2)}
115
+ </pre>
116
+ </div>
117
+ </div>
118
+ </div>
119
+ );
120
+ }
121
+
122
+ export default LogDetail;
@@ -0,0 +1,242 @@
1
+ import { colors, fonts, withOpacity } from './theme';
2
+
3
+ function LogTable({ logs, selected, onSelect }) {
4
+ const getStatusColor = (status) => {
5
+ if (status === 'error') return colors.error;
6
+ if (status === 'success') return colors.success;
7
+ if (status === 'pending') return colors.warning;
8
+ return colors.textTertiary;
9
+ };
10
+
11
+ const formatTime = (iso) => {
12
+ return new Date(iso).toLocaleTimeString();
13
+ };
14
+
15
+ return (
16
+ <div style={{ flex: 1, overflow: 'auto', background: colors.bgPrimary }}>
17
+ <table
18
+ style={{
19
+ width: '100%',
20
+ borderCollapse: 'collapse',
21
+ fontSize: '12px',
22
+ fontFamily: fonts.body,
23
+ }}
24
+ >
25
+ <thead
26
+ style={{
27
+ position: 'sticky',
28
+ top: 0,
29
+ background: colors.bgCard,
30
+ zIndex: 1,
31
+ boxShadow: `0 2px 4px ${colors.shadowSm}`,
32
+ }}
33
+ >
34
+ <tr>
35
+ <th
36
+ style={{
37
+ padding: '12px 16px',
38
+ textAlign: 'left',
39
+ borderBottom: `1px solid ${colors.borderLight}`,
40
+ color: colors.textSecondary,
41
+ fontWeight: '600',
42
+ fontSize: '11px',
43
+ textTransform: 'uppercase',
44
+ letterSpacing: '0.05em',
45
+ background: colors.bgCard,
46
+ }}
47
+ >
48
+ Time
49
+ </th>
50
+ <th
51
+ style={{
52
+ padding: '12px 16px',
53
+ textAlign: 'left',
54
+ borderBottom: `1px solid ${colors.borderLight}`,
55
+ color: colors.textSecondary,
56
+ fontWeight: '600',
57
+ fontSize: '11px',
58
+ textTransform: 'uppercase',
59
+ letterSpacing: '0.05em',
60
+ background: colors.bgCard,
61
+ }}
62
+ >
63
+ Server
64
+ </th>
65
+ <th
66
+ style={{
67
+ padding: '12px 16px',
68
+ textAlign: 'left',
69
+ borderBottom: `1px solid ${colors.borderLight}`,
70
+ color: colors.textSecondary,
71
+ fontWeight: '600',
72
+ fontSize: '11px',
73
+ textTransform: 'uppercase',
74
+ letterSpacing: '0.05em',
75
+ background: colors.bgCard,
76
+ }}
77
+ >
78
+ Dir
79
+ </th>
80
+ <th
81
+ style={{
82
+ padding: '12px 16px',
83
+ textAlign: 'left',
84
+ borderBottom: `1px solid ${colors.borderLight}`,
85
+ color: colors.textSecondary,
86
+ fontWeight: '600',
87
+ fontSize: '11px',
88
+ textTransform: 'uppercase',
89
+ letterSpacing: '0.05em',
90
+ background: colors.bgCard,
91
+ }}
92
+ >
93
+ Method
94
+ </th>
95
+ <th
96
+ style={{
97
+ padding: '12px 16px',
98
+ textAlign: 'left',
99
+ borderBottom: `1px solid ${colors.borderLight}`,
100
+ color: colors.textSecondary,
101
+ fontWeight: '600',
102
+ fontSize: '11px',
103
+ textTransform: 'uppercase',
104
+ letterSpacing: '0.05em',
105
+ background: colors.bgCard,
106
+ }}
107
+ >
108
+ Status
109
+ </th>
110
+ <th
111
+ style={{
112
+ padding: '12px 16px',
113
+ textAlign: 'right',
114
+ borderBottom: `1px solid ${colors.borderLight}`,
115
+ color: colors.textSecondary,
116
+ fontWeight: '600',
117
+ fontSize: '11px',
118
+ textTransform: 'uppercase',
119
+ letterSpacing: '0.05em',
120
+ background: colors.bgCard,
121
+ }}
122
+ >
123
+ Duration
124
+ </th>
125
+ <th
126
+ style={{
127
+ padding: '12px 16px',
128
+ textAlign: 'right',
129
+ borderBottom: `1px solid ${colors.borderLight}`,
130
+ color: colors.textSecondary,
131
+ fontWeight: '600',
132
+ fontSize: '11px',
133
+ textTransform: 'uppercase',
134
+ letterSpacing: '0.05em',
135
+ background: colors.bgCard,
136
+ }}
137
+ >
138
+ Size
139
+ </th>
140
+ </tr>
141
+ </thead>
142
+ <tbody>
143
+ {logs.map((log) => (
144
+ <tr
145
+ key={log.id}
146
+ onClick={() => onSelect(log)}
147
+ style={{
148
+ cursor: 'pointer',
149
+ background: selected?.id === log.id ? colors.bgSelected : colors.bgCard,
150
+ borderBottom: `1px solid ${colors.borderLight}`,
151
+ transition: 'background-color 0.15s ease',
152
+ }}
153
+ onMouseEnter={(e) => {
154
+ if (selected?.id !== log.id) e.currentTarget.style.background = colors.bgHover;
155
+ }}
156
+ onMouseLeave={(e) => {
157
+ if (selected?.id !== log.id) e.currentTarget.style.background = colors.bgCard;
158
+ }}
159
+ >
160
+ <td
161
+ style={{
162
+ padding: '16px',
163
+ color: colors.textTertiary,
164
+ fontFamily: fonts.mono,
165
+ fontSize: '12px',
166
+ }}
167
+ >
168
+ {formatTime(log.timestamp_iso)}
169
+ </td>
170
+ <td
171
+ style={{
172
+ padding: '16px',
173
+ color: colors.textPrimary,
174
+ fontSize: '12px',
175
+ fontFamily: fonts.body,
176
+ }}
177
+ >
178
+ {log.server_name}
179
+ </td>
180
+ <td
181
+ style={{
182
+ padding: '16px',
183
+ color: log.direction === 'request' ? colors.accentBlue : colors.accentOrange,
184
+ fontSize: '12px',
185
+ fontWeight: '500',
186
+ fontFamily: fonts.body,
187
+ }}
188
+ >
189
+ {log.direction}
190
+ </td>
191
+ <td
192
+ style={{
193
+ padding: '16px',
194
+ color: colors.textPrimary,
195
+ fontSize: '12px',
196
+ fontFamily: fonts.body,
197
+ }}
198
+ >
199
+ {log.method || '-'}
200
+ </td>
201
+ <td
202
+ style={{
203
+ padding: '16px',
204
+ color: getStatusColor(log.status),
205
+ fontSize: '12px',
206
+ fontWeight: '500',
207
+ fontFamily: fonts.body,
208
+ }}
209
+ >
210
+ {log.status || '-'}
211
+ </td>
212
+ <td
213
+ style={{
214
+ padding: '16px',
215
+ textAlign: 'right',
216
+ color: colors.textSecondary,
217
+ fontSize: '12px',
218
+ fontFamily: fonts.mono,
219
+ }}
220
+ >
221
+ {log.duration_ms ? `${log.duration_ms.toFixed(2)}ms` : '-'}
222
+ </td>
223
+ <td
224
+ style={{
225
+ padding: '16px',
226
+ textAlign: 'right',
227
+ color: colors.textSecondary,
228
+ fontSize: '12px',
229
+ fontFamily: fonts.mono,
230
+ }}
231
+ >
232
+ {log.payload_size ? `${(log.payload_size / 1024).toFixed(1)}KB` : '-'}
233
+ </td>
234
+ </tr>
235
+ ))}
236
+ </tbody>
237
+ </table>
238
+ </div>
239
+ );
240
+ }
241
+
242
+ export default LogTable;
@@ -0,0 +1,190 @@
1
+ import { useState, useEffect, useRef } from 'react';
2
+ import { colors, fonts } from './theme';
3
+ import PacketDetailHeader from './components/PacketDetailHeader';
4
+ import TabNavigation from './components/TabNavigation';
5
+ import DetailsTab from './components/DetailsTab';
6
+ import HexTab from './components/HexTab';
7
+ import RawTab from './components/RawTab';
8
+ import { generateHexDump, createFullRequestText } from './utils/hexUtils.js';
9
+ import { fadeIn } from './utils/animations';
10
+
11
+ function RequestDetail({ request, onClose, requests = [] }) {
12
+ const [activeTab, setActiveTab] = useState('details');
13
+ const tabContentRef = useRef(null);
14
+ const prevTabRef = useRef(activeTab);
15
+
16
+ useEffect(() => {
17
+ if (prevTabRef.current !== activeTab && tabContentRef.current) {
18
+ fadeIn(tabContentRef.current, { duration: 300 });
19
+ prevTabRef.current = activeTab;
20
+ }
21
+ }, [activeTab]);
22
+
23
+ if (!request) return null;
24
+
25
+ // Helper function to extract JSON-RPC method
26
+ const getJsonRpcMethod = (req) => {
27
+ // First check the jsonrpc_method field (most reliable)
28
+ if (req.jsonrpc_method) {
29
+ return req.jsonrpc_method;
30
+ }
31
+
32
+ // For requests, try to extract from body
33
+ if (req.direction === 'request') {
34
+ if (req.body_json) {
35
+ try {
36
+ const body =
37
+ typeof req.body_json === 'string' ? JSON.parse(req.body_json) : req.body_json;
38
+ if (body && typeof body === 'object' && body.method) {
39
+ return body.method;
40
+ }
41
+ } catch (e) {
42
+ // Failed to parse
43
+ }
44
+ }
45
+ if (req.body_raw) {
46
+ try {
47
+ const body = typeof req.body_raw === 'string' ? JSON.parse(req.body_raw) : req.body_raw;
48
+ if (body && typeof body === 'object' && body.method) {
49
+ return body.method;
50
+ }
51
+ } catch (e) {
52
+ // Failed to parse
53
+ }
54
+ }
55
+ }
56
+
57
+ return null;
58
+ };
59
+
60
+ // Find matching request/response pair
61
+ const findMatchingPair = () => {
62
+ const matches = (req, resp) => {
63
+ // Session ID must match
64
+ if (req.session_id !== resp.session_id) return false;
65
+
66
+ // JSON-RPC Method must match
67
+ const reqMethod = getJsonRpcMethod(req);
68
+ const respMethod = getJsonRpcMethod(resp);
69
+
70
+ // Both must have a method, and they must match
71
+ if (!reqMethod || !respMethod) {
72
+ // If either doesn't have a method, we can't match by method
73
+ // Fall back to JSON-RPC ID matching only
74
+ if (req.jsonrpc_id && resp.jsonrpc_id) {
75
+ return req.jsonrpc_id === resp.jsonrpc_id;
76
+ }
77
+ // If no method and no ID, we can't match reliably
78
+ return false;
79
+ }
80
+
81
+ if (reqMethod !== respMethod) return false;
82
+
83
+ // If JSON-RPC ID exists, it must match
84
+ if (req.jsonrpc_id && resp.jsonrpc_id) {
85
+ return req.jsonrpc_id === resp.jsonrpc_id;
86
+ }
87
+
88
+ return true;
89
+ };
90
+
91
+ if (request.direction === 'request') {
92
+ // Find the corresponding response
93
+ return requests.find(
94
+ (r) =>
95
+ r.direction === 'response' && matches(request, r) && r.frame_number > request.frame_number
96
+ );
97
+ } else {
98
+ // Find the corresponding request
99
+ return requests.find(
100
+ (r) =>
101
+ r.direction === 'request' && matches(r, request) && r.frame_number < request.frame_number
102
+ );
103
+ }
104
+ };
105
+
106
+ const matchingPair = findMatchingPair();
107
+ const displayRequest = request.direction === 'request' ? request : matchingPair || request;
108
+ const displayResponse = request.direction === 'response' ? request : matchingPair;
109
+
110
+ const requestHeaders = displayRequest?.headers_json
111
+ ? JSON.parse(displayRequest.headers_json)
112
+ : {};
113
+ const requestBody = displayRequest?.body_json
114
+ ? JSON.parse(displayRequest.body_json)
115
+ : displayRequest?.body_raw;
116
+ const requestFullText = displayRequest
117
+ ? createFullRequestText(requestHeaders, displayRequest.body_raw)
118
+ : '';
119
+ const requestHexLines = displayRequest ? generateHexDump(requestFullText) : [];
120
+
121
+ const responseHeaders = displayResponse?.headers_json
122
+ ? JSON.parse(displayResponse.headers_json)
123
+ : {};
124
+ const responseBody = displayResponse?.body_json
125
+ ? JSON.parse(displayResponse.body_json)
126
+ : displayResponse?.body_raw;
127
+ const responseFullText = displayResponse
128
+ ? createFullRequestText(responseHeaders, displayResponse.body_raw)
129
+ : '';
130
+ const responseHexLines = displayResponse ? generateHexDump(responseFullText) : [];
131
+
132
+ return (
133
+ <div
134
+ style={{
135
+ height: '100%',
136
+ display: 'flex',
137
+ flexDirection: 'column',
138
+ background: colors.bgPrimary,
139
+ }}
140
+ >
141
+ <PacketDetailHeader request={request} onClose={onClose} matchingPair={matchingPair} />
142
+
143
+ <TabNavigation
144
+ tabs={['details', 'hex', 'raw']}
145
+ activeTab={activeTab}
146
+ onTabChange={setActiveTab}
147
+ />
148
+
149
+ <div
150
+ ref={tabContentRef}
151
+ style={{
152
+ flex: 1,
153
+ overflow: 'auto',
154
+ background: colors.bgPrimary,
155
+ }}
156
+ >
157
+ {activeTab === 'details' && (
158
+ <DetailsTab
159
+ request={displayRequest}
160
+ response={displayResponse}
161
+ requestHeaders={requestHeaders}
162
+ requestBody={requestBody}
163
+ responseHeaders={responseHeaders}
164
+ responseBody={responseBody}
165
+ />
166
+ )}
167
+
168
+ {activeTab === 'hex' && (
169
+ <HexTab
170
+ requestHexLines={requestHexLines}
171
+ responseHexLines={responseHexLines}
172
+ hasRequest={!!displayRequest}
173
+ hasResponse={!!displayResponse}
174
+ />
175
+ )}
176
+
177
+ {activeTab === 'raw' && (
178
+ <RawTab
179
+ requestFullText={requestFullText}
180
+ responseFullText={responseFullText}
181
+ hasRequest={!!displayRequest}
182
+ hasResponse={!!displayResponse}
183
+ />
184
+ )}
185
+ </div>
186
+ </div>
187
+ );
188
+ }
189
+
190
+ export default RequestDetail;