@tonyclaw/agent-inspector 3.1.32 → 4.0.2
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +241 -120
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-oXUk3MBR.mjs → router-BBY_zWRK.mjs} +91 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-BtfPSpkV.js → CompareDrawer-rtNElN-B.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D9DPPQ3n.js → InspectorPet-QaAiuF3d.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Buu8vkCK.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-BER-QzpD.js → ReplayDialog-B7KlziO2.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-C8Zwxrr7.js → RequestAnatomy-2XVFBrW4.js} +1 -1
- package/.output/ui/assets/{ResponseView-DDpKdYk6.js → ResponseView-BULgzLVB.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-sMPGG7Sw.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
- package/.output/ui/assets/{_sessionId-e4IheHnP.js → _sessionId-D2dmJi3G.js} +1 -1
- package/.output/ui/assets/{_sessionId-C5Uv72Fx.js → _sessionId-DcS0s1Mr.js} +1 -1
- package/.output/ui/assets/{index-B__qT0Yd.js → index-B0TN1KKO.js} +2 -2
- package/.output/ui/assets/{index-Be3bTCzi.js → index-Bva1zHEs.js} +1 -1
- package/.output/ui/assets/{index-C9q__p8J.js → index-BzBExOxu.js} +1 -1
- package/.output/ui/assets/{index-CtB0deSZ.js → index-k6sRQz55.js} +1 -1
- package/.output/ui/assets/{json-viewer-Db0AFp-7.js → json-viewer-CWM4tY-j.js} +1 -1
- package/.output/ui/assets/{jszip.min-DkY0Ym_q.js → jszip.min-BkWvRFlo.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +8 -13
- package/src/assets/IDE/claudecode-color.svg +0 -1
- package/src/assets/IDE/codex-color.svg +0 -1
- package/src/assets/IDE/opencode.svg +0 -1
- package/src/assets/IDE/xiaomimimo.svg +0 -1
- package/src/assets/favicon.svg +0 -21
- package/src/assets/logos/alibaba.svg +0 -1
- package/src/assets/logos/anthropic.svg +0 -1
- package/src/assets/logos/claude-code.svg +0 -4
- package/src/assets/logos/deepseek.svg +0 -1
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +0 -1
- package/src/assets/logos/opencode.svg +0 -4
- package/src/assets/logos/qwen.webp +0 -0
- package/src/assets/logos/zhipuai.svg +0 -219
- package/src/backend/router.tsx +0 -36
- package/src/backend/routes/$.ts +0 -26
- package/src/backend/routes/__root.ts +0 -4
- package/src/backend/routes/api/-instances.ts +0 -7
- package/src/backend/routes/api/alerts.summary.ts +0 -28
- package/src/backend/routes/api/alerts.ts +0 -70
- package/src/backend/routes/api/config.paths.ts +0 -14
- package/src/backend/routes/api/config.ts +0 -73
- package/src/backend/routes/api/ecosystem.packages.$packageId.help.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.install.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.runner-presets.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.upgrade.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.ts +0 -21
- package/src/backend/routes/api/ecosystem.recipes.$recipeId.run.ts +0 -11
- package/src/backend/routes/api/ecosystem.tasks.$taskId.ts +0 -16
- package/src/backend/routes/api/ecosystem.tasks.ts +0 -12
- package/src/backend/routes/api/groups.$groupId.evidence.ts +0 -55
- package/src/backend/routes/api/groups.$groupId.sessions.ts +0 -50
- package/src/backend/routes/api/groups.$groupId.ts +0 -93
- package/src/backend/routes/api/groups.ts +0 -79
- package/src/backend/routes/api/health.ts +0 -22
- package/src/backend/routes/api/instances.$name.connection.ts +0 -12
- package/src/backend/routes/api/instances.$name.restart.ts +0 -23
- package/src/backend/routes/api/instances.$name.start.ts +0 -18
- package/src/backend/routes/api/instances.$name.stop.ts +0 -23
- package/src/backend/routes/api/instances.$name.ts +0 -12
- package/src/backend/routes/api/instances.ts +0 -16
- package/src/backend/routes/api/knowledge.candidates.$candidateId.promote.ts +0 -32
- package/src/backend/routes/api/knowledge.candidates.$candidateId.ts +0 -50
- package/src/backend/routes/api/knowledge.candidates.ts +0 -10
- package/src/backend/routes/api/knowledge.project-context.ts +0 -29
- package/src/backend/routes/api/knowledge.search.ts +0 -62
- package/src/backend/routes/api/knowledge.sessions.$sessionId.candidates.ts +0 -26
- package/src/backend/routes/api/logs.$id.body.ts +0 -58
- package/src/backend/routes/api/logs.$id.chunks.ts +0 -37
- package/src/backend/routes/api/logs.$id.replay.ts +0 -297
- package/src/backend/routes/api/logs.$id.ts +0 -23
- package/src/backend/routes/api/logs.import.ts +0 -39
- package/src/backend/routes/api/logs.stream.ts +0 -174
- package/src/backend/routes/api/logs.ts +0 -214
- package/src/backend/routes/api/mcp.ts +0 -25
- package/src/backend/routes/api/models.ts +0 -10
- package/src/backend/routes/api/pi-agent.ts +0 -29
- package/src/backend/routes/api/providers.$providerId.model-metadata.ts +0 -173
- package/src/backend/routes/api/providers.$providerId.test.log.ts +0 -342
- package/src/backend/routes/api/providers.$providerId.ts +0 -111
- package/src/backend/routes/api/providers.export.ts +0 -44
- package/src/backend/routes/api/providers.import.ts +0 -81
- package/src/backend/routes/api/providers.scan.ts +0 -28
- package/src/backend/routes/api/providers.ts +0 -102
- package/src/backend/routes/api/runs.$runId.evidence.ts +0 -55
- package/src/backend/routes/api/runs.$runId.ts +0 -50
- package/src/backend/routes/api/runs.ts +0 -62
- package/src/backend/routes/api/runtime.ts +0 -46
- package/src/backend/routes/api/sessions.ts +0 -51
- package/src/backend/routes/api/storage.ts +0 -56
- package/src/backend/routes/livez.ts +0 -13
- package/src/backend/routes/metrics.ts +0 -14
- package/src/backend/routes/proxy/$.ts +0 -15
- package/src/backend/routes/readyz.ts +0 -18
- package/src/backend/start.ts +0 -10
- package/src/cli/alias.ts +0 -431
- package/src/cli/detect-tools.ts +0 -123
- package/src/cli/doctor.ts +0 -836
- package/src/cli/instance.ts +0 -1071
- package/src/cli/instanceApi.ts +0 -213
- package/src/cli/instanceArgs.ts +0 -301
- package/src/cli/instanceControl.ts +0 -191
- package/src/cli/instanceModel.ts +0 -276
- package/src/cli/instanceRegistry.ts +0 -731
- package/src/cli/networkHints.ts +0 -170
- package/src/cli/onboard.ts +0 -1668
- package/src/cli/onboardTarget.ts +0 -228
- package/src/cli/rustBackendPackage.ts +0 -458
- package/src/cli/startupOutput.ts +0 -16
- package/src/cli/templates/codex-skill-onboard.ts +0 -320
- package/src/cli/templates/command-onboard.ts +0 -25
- package/src/cli/templates/skill-onboard.ts +0 -625
- package/src/cli.ts +0 -1397
- package/src/components/OnboardingBanner.tsx +0 -115
- package/src/components/ProxyViewer.tsx +0 -2259
- package/src/components/ProxyViewerContainer.tsx +0 -1076
- package/src/components/alerts/AlertsDialog.tsx +0 -615
- package/src/components/clients/ClientLogo.tsx +0 -175
- package/src/components/ecosystem/AgentLabDialog.tsx +0 -947
- package/src/components/errors/SafeErrorBoundary.tsx +0 -201
- package/src/components/groups/GroupsDialog.tsx +0 -1304
- package/src/components/inspector-pet/InspectorPet.tsx +0 -398
- package/src/components/inspector-pet/InspectorPetCrab3D.tsx +0 -455
- package/src/components/inspector-pet/inspectorPetLogic.ts +0 -272
- package/src/components/pi-agent/PiAgentPanel.tsx +0 -446
- package/src/components/pi-agent/piAgentChatLogic.ts +0 -273
- package/src/components/providers/ImportWizardDialog.tsx +0 -281
- package/src/components/providers/ProviderCard.tsx +0 -347
- package/src/components/providers/ProviderForm.tsx +0 -1183
- package/src/components/providers/ProviderLogo.tsx +0 -122
- package/src/components/providers/ProviderTestResultsView.tsx +0 -734
- package/src/components/providers/ProvidersPanel.tsx +0 -714
- package/src/components/providers/SettingsDialog.tsx +0 -1042
- package/src/components/providers/providerFormCapabilities.ts +0 -36
- package/src/components/proxy-viewer/AgentTraceSummary.tsx +0 -902
- package/src/components/proxy-viewer/AnswerMarkdown.tsx +0 -51
- package/src/components/proxy-viewer/ApplicationBar.tsx +0 -123
- package/src/components/proxy-viewer/CompareDrawer.tsx +0 -984
- package/src/components/proxy-viewer/ConversationGroup.tsx +0 -208
- package/src/components/proxy-viewer/ConversationGroupList.tsx +0 -652
- package/src/components/proxy-viewer/ConversationHeader.tsx +0 -429
- package/src/components/proxy-viewer/LiveConnectionStatus.tsx +0 -186
- package/src/components/proxy-viewer/LogEntry.tsx +0 -1419
- package/src/components/proxy-viewer/LogEntryHeader.tsx +0 -596
- package/src/components/proxy-viewer/ProviderLogoStack.tsx +0 -57
- package/src/components/proxy-viewer/RawExportWarning.tsx +0 -77
- package/src/components/proxy-viewer/ReplayDialog.tsx +0 -636
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +0 -299
- package/src/components/proxy-viewer/ResponseView.tsx +0 -202
- package/src/components/proxy-viewer/SessionLoadProgressBar.tsx +0 -61
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +0 -265
- package/src/components/proxy-viewer/ThreadConnector.tsx +0 -165
- package/src/components/proxy-viewer/ToolTraceEvents.tsx +0 -64
- package/src/components/proxy-viewer/TurnGroup.tsx +0 -383
- package/src/components/proxy-viewer/TurnGroupList.tsx +0 -156
- package/src/components/proxy-viewer/accessibility.ts +0 -8
- package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +0 -887
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +0 -222
- package/src/components/proxy-viewer/anatomy/contextIntelligence.ts +0 -737
- package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +0 -268
- package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +0 -53
- package/src/components/proxy-viewer/anatomy/types.ts +0 -41
- package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +0 -114
- package/src/components/proxy-viewer/bodyHydration.ts +0 -123
- package/src/components/proxy-viewer/cacheTrend.ts +0 -50
- package/src/components/proxy-viewer/diff/DiffView.tsx +0 -321
- package/src/components/proxy-viewer/diff/computeDiff.ts +0 -178
- package/src/components/proxy-viewer/diff/index.ts +0 -3
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +0 -194
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +0 -81
- package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +0 -21
- package/src/components/proxy-viewer/formats/index.tsx +0 -47
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +0 -442
- package/src/components/proxy-viewer/index.ts +0 -9
- package/src/components/proxy-viewer/lazy.ts +0 -41
- package/src/components/proxy-viewer/liveConnectionState.ts +0 -158
- package/src/components/proxy-viewer/log-formats/anthropic.ts +0 -191
- package/src/components/proxy-viewer/log-formats/index.ts +0 -23
- package/src/components/proxy-viewer/log-formats/openai.ts +0 -256
- package/src/components/proxy-viewer/log-formats/types.ts +0 -40
- package/src/components/proxy-viewer/log-formats/unknown.ts +0 -18
- package/src/components/proxy-viewer/logEntryVisibility.ts +0 -73
- package/src/components/proxy-viewer/logFocus.ts +0 -54
- package/src/components/proxy-viewer/proxyViewerContainerLogic.ts +0 -124
- package/src/components/proxy-viewer/proxyViewerLogic.ts +0 -488
- package/src/components/proxy-viewer/replayComparison.ts +0 -131
- package/src/components/proxy-viewer/requestDiff.ts +0 -277
- package/src/components/proxy-viewer/requestTools.ts +0 -220
- package/src/components/proxy-viewer/useCopyFeedback.ts +0 -38
- package/src/components/proxy-viewer/useKeyboardNavigation.ts +0 -232
- package/src/components/proxy-viewer/viewerState.ts +0 -176
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/button.tsx +0 -47
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/confirm-dialog.tsx +0 -51
- package/src/components/ui/crab-logo.tsx +0 -45
- package/src/components/ui/crab-variants.tsx +0 -467
- package/src/components/ui/dialog.tsx +0 -130
- package/src/components/ui/icon-trigger.ts +0 -2
- package/src/components/ui/json-viewer-bulk.ts +0 -132
- package/src/components/ui/json-viewer.tsx +0 -508
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/select.tsx +0 -178
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -88
- package/src/components/ui/tooltip.tsx +0 -51
- package/src/components/ui/transient-toast.tsx +0 -105
- package/src/contracts/anthropic.ts +0 -230
- package/src/contracts/index.ts +0 -59
- package/src/contracts/json.ts +0 -37
- package/src/contracts/log.ts +0 -139
- package/src/contracts/openai.ts +0 -267
- package/src/index.css +0 -11
- package/src/knowledge/candidateStore.ts +0 -94
- package/src/knowledge/distiller.ts +0 -98
- package/src/knowledge/openclawClient.ts +0 -161
- package/src/knowledge/openclawGatewayClient.ts +0 -249
- package/src/knowledge/openclawMarkdown.ts +0 -146
- package/src/knowledge/redactor.ts +0 -80
- package/src/knowledge/types.ts +0 -83
- package/src/lib/alertContract.ts +0 -76
- package/src/lib/apiClient.ts +0 -166
- package/src/lib/apiFormat.ts +0 -29
- package/src/lib/backendImplementation.ts +0 -16
- package/src/lib/basePath.ts +0 -107
- package/src/lib/browserRuntimeContract.ts +0 -124
- package/src/lib/browserRuntimeResolver.ts +0 -333
- package/src/lib/chunkLoadRecovery.ts +0 -83
- package/src/lib/claudeCodeStrip.ts +0 -98
- package/src/lib/clipboard.ts +0 -67
- package/src/lib/codingAgentEndpoints.ts +0 -54
- package/src/lib/ecosystemContract.ts +0 -130
- package/src/lib/export-logs.ts +0 -287
- package/src/lib/groupContract.ts +0 -166
- package/src/lib/instanceContract.ts +0 -239
- package/src/lib/jsonFile.ts +0 -46
- package/src/lib/logImportContract.ts +0 -12
- package/src/lib/managedInstance.ts +0 -112
- package/src/lib/mask.ts +0 -4
- package/src/lib/objectUtils.ts +0 -22
- package/src/lib/piAgentContract.ts +0 -102
- package/src/lib/providerContract.ts +0 -125
- package/src/lib/providerImportContract.ts +0 -27
- package/src/lib/providerModelMetadata.ts +0 -458
- package/src/lib/providerTestContract.ts +0 -170
- package/src/lib/providerTestPrompt.ts +0 -100
- package/src/lib/publicBasePathContext.ts +0 -137
- package/src/lib/resourceLimits.ts +0 -345
- package/src/lib/runContract.ts +0 -164
- package/src/lib/runtimeConfig.ts +0 -43
- package/src/lib/safeDiagnostic.ts +0 -38
- package/src/lib/safeFetch.ts +0 -508
- package/src/lib/serverPort.ts +0 -47
- package/src/lib/sessionInfoContract.ts +0 -78
- package/src/lib/sessionUrl.ts +0 -46
- package/src/lib/ssrfGuard.ts +0 -133
- package/src/lib/stopReason.ts +0 -130
- package/src/lib/themeMode.ts +0 -41
- package/src/lib/timeDisplay.ts +0 -22
- package/src/lib/toolTrace.ts +0 -290
- package/src/lib/uiScale.ts +0 -117
- package/src/lib/unknown.ts +0 -27
- package/src/lib/upstreamUrl.ts +0 -150
- package/src/lib/useAlerts.ts +0 -82
- package/src/lib/useGroupEvidence.ts +0 -37
- package/src/lib/useGroups.ts +0 -32
- package/src/lib/useOnboarding.ts +0 -93
- package/src/lib/useProviders.ts +0 -30
- package/src/lib/useStripConfig.ts +0 -154
- package/src/lib/useThemeMode.ts +0 -40
- package/src/lib/useUiScale.ts +0 -52
- package/src/lib/utils.ts +0 -78
- package/src/mcp/currentContext.ts +0 -65
- package/src/mcp/instanceHandlers.ts +0 -151
- package/src/mcp/loopback.ts +0 -88
- package/src/mcp/mode.ts +0 -75
- package/src/mcp/previewExtractor.ts +0 -233
- package/src/mcp/server.ts +0 -2274
- package/src/mcp/toolHandlers.ts +0 -1533
- package/src/proxy/alerts.ts +0 -664
- package/src/proxy/chunkStorage.ts +0 -123
- package/src/proxy/config.ts +0 -218
- package/src/proxy/constants.ts +0 -66
- package/src/proxy/dataDir.ts +0 -147
- package/src/proxy/ecosystemExecutionConfirmation.ts +0 -114
- package/src/proxy/ecosystemExecutionRoute.ts +0 -116
- package/src/proxy/ecosystemRegistry.ts +0 -296
- package/src/proxy/ecosystemTasks.ts +0 -415
- package/src/proxy/evidenceAnalysis.ts +0 -526
- package/src/proxy/evidenceExporter.ts +0 -235
- package/src/proxy/formats/anthropic/anthropicProvider.ts +0 -75
- package/src/proxy/formats/anthropic/handler.ts +0 -75
- package/src/proxy/formats/anthropic/index.ts +0 -13
- package/src/proxy/formats/anthropic/register.ts +0 -4
- package/src/proxy/formats/anthropic/schemas.ts +0 -6
- package/src/proxy/formats/anthropic/stream.ts +0 -205
- package/src/proxy/formats/handler.ts +0 -46
- package/src/proxy/formats/index.ts +0 -13
- package/src/proxy/formats/jsonSchema.ts +0 -2
- package/src/proxy/formats/openai/alibabaProvider.ts +0 -34
- package/src/proxy/formats/openai/codexMetadata.ts +0 -61
- package/src/proxy/formats/openai/handler.ts +0 -133
- package/src/proxy/formats/openai/index.ts +0 -33
- package/src/proxy/formats/openai/provider.ts +0 -50
- package/src/proxy/formats/openai/register.ts +0 -4
- package/src/proxy/formats/openai/schemas.ts +0 -25
- package/src/proxy/formats/openai/stream.ts +0 -600
- package/src/proxy/formats/openai/zhipuProvider.ts +0 -31
- package/src/proxy/formats/providerAdapter.ts +0 -50
- package/src/proxy/formats/providerRegistry.ts +0 -51
- package/src/proxy/formats/providers/index.ts +0 -3
- package/src/proxy/formats/registry.ts +0 -65
- package/src/proxy/groupEvidenceExporter.ts +0 -371
- package/src/proxy/groupStore.ts +0 -336
- package/src/proxy/handler.ts +0 -729
- package/src/proxy/identityProxy.ts +0 -1842
- package/src/proxy/jsonlRecovery.ts +0 -554
- package/src/proxy/logBodyChunks.ts +0 -91
- package/src/proxy/logFinalizer.ts +0 -777
- package/src/proxy/logFinalizer.worker.ts +0 -24
- package/src/proxy/logImportUpload.ts +0 -128
- package/src/proxy/logImporter.ts +0 -813
- package/src/proxy/logIndex.ts +0 -663
- package/src/proxy/logSearch.ts +0 -122
- package/src/proxy/logger.ts +0 -537
- package/src/proxy/openaiOrphanToolStrip.ts +0 -142
- package/src/proxy/platformCommands.ts +0 -253
- package/src/proxy/privateDataPath.ts +0 -419
- package/src/proxy/providerImporters.ts +0 -578
- package/src/proxy/providerScanStore.ts +0 -87
- package/src/proxy/providerSecretStore.ts +0 -216
- package/src/proxy/providers.ts +0 -998
- package/src/proxy/rawStreamCapture.ts +0 -342
- package/src/proxy/runFailures.ts +0 -94
- package/src/proxy/runStore.ts +0 -214
- package/src/proxy/runtimeAdmission.ts +0 -55
- package/src/proxy/runtimeHealth.ts +0 -221
- package/src/proxy/runtimeMetrics.ts +0 -149
- package/src/proxy/runtimeShutdown.ts +0 -157
- package/src/proxy/schemas.ts +0 -112
- package/src/proxy/sessionArchive.ts +0 -479
- package/src/proxy/sessionInfo.ts +0 -266
- package/src/proxy/sessionProcess.ts +0 -194
- package/src/proxy/sessionRuntime.ts +0 -121
- package/src/proxy/sessionSupervisor.ts +0 -305
- package/src/proxy/sessionWorkerEntry.ts +0 -26
- package/src/proxy/shutdownCoordinator.ts +0 -90
- package/src/proxy/socketTracker.ts +0 -639
- package/src/proxy/sqliteLogIndex.ts +0 -733
- package/src/proxy/storageLifecycle.ts +0 -432
- package/src/proxy/store.ts +0 -1773
- package/src/proxy/streamTiming.ts +0 -31
- package/src/proxy/toolSchemaWarnings.ts +0 -529
- package/src/proxy/uiAssetServer.ts +0 -106
- package/src/proxy/upstream.ts +0 -127
- package/src/services/alerts.ts +0 -12
- package/src/services/groups.ts +0 -119
- package/src/services/piAgent.ts +0 -421
- package/src/services/piAgentRetrieval.ts +0 -1180
- package/src/services/result.ts +0 -17
- package/src/services/runs.ts +0 -76
- package/src/ui/bootstrap.ts +0 -167
- package/src/ui/index.html +0 -38
- package/src/ui/logsStreamClient.ts +0 -20
- package/src/ui/main.tsx +0 -13
- package/src/ui/public/runtime-config.js +0 -2
- package/src/ui/router.tsx +0 -13
- package/src/ui/routes/__root.tsx +0 -69
- package/src/ui/routes/index.tsx +0 -35
- package/src/ui/routes/session/$sessionId.tsx +0 -50
- package/src/ui/runtimeDiscovery.ts +0 -50
|
@@ -1,636 +0,0 @@
|
|
|
1
|
-
import { Braces, Minimize2, RotateCcw } from "lucide-react";
|
|
2
|
-
import type { JSX } from "react";
|
|
3
|
-
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
4
|
-
import { z } from "zod";
|
|
5
|
-
import { useProviders } from "../../lib/useProviders";
|
|
6
|
-
import { Button } from "../ui/button";
|
|
7
|
-
import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from "../ui/tooltip";
|
|
8
|
-
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "../ui/dialog";
|
|
9
|
-
import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs";
|
|
10
|
-
import { ResponseView } from "./ResponseView";
|
|
11
|
-
import { CapturedLogSchema, type CapturedLog } from "../../contracts";
|
|
12
|
-
import { ApiTimeoutError, fetchJsonWithTimeout } from "../../lib/apiClient";
|
|
13
|
-
import { dispatchLogFocusRequest } from "./logFocus";
|
|
14
|
-
import {
|
|
15
|
-
buildReplayComparisons,
|
|
16
|
-
buildReplayMetrics,
|
|
17
|
-
readRequestModel,
|
|
18
|
-
replaceRequestModel,
|
|
19
|
-
type ReplayMetricComparison,
|
|
20
|
-
type ReplayMetricValue,
|
|
21
|
-
} from "./replayComparison";
|
|
22
|
-
|
|
23
|
-
const ReplayResultSchema = z.object({
|
|
24
|
-
success: z.boolean(),
|
|
25
|
-
error: z.string().optional(),
|
|
26
|
-
responseStatus: z.number().nullable().optional(),
|
|
27
|
-
responseText: z.string().nullable().optional(),
|
|
28
|
-
inputTokens: z.number().nullable().optional(),
|
|
29
|
-
outputTokens: z.number().nullable().optional(),
|
|
30
|
-
elapsedMs: z.number().nullable().optional(),
|
|
31
|
-
streaming: z.boolean().optional(),
|
|
32
|
-
replayLogId: z.number().optional(),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
type ReplayResult = z.infer<typeof ReplayResultSchema>;
|
|
36
|
-
|
|
37
|
-
type ReplayDialogProps = {
|
|
38
|
-
log: CapturedLog;
|
|
39
|
-
displayNumber: number;
|
|
40
|
-
open: boolean;
|
|
41
|
-
onOpenChange: (open: boolean) => void;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
type ReplayModelOption = {
|
|
45
|
-
key: string;
|
|
46
|
-
providerName: string;
|
|
47
|
-
model: string;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
type JsonEditState = { valid: true; message: string } | { valid: false; message: string };
|
|
51
|
-
|
|
52
|
-
const ReplayHistorySchema = z.object({
|
|
53
|
-
logs: z.array(CapturedLogSchema),
|
|
54
|
-
total: z.number(),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const REPLAY_TIMEOUT_MS = 60_000;
|
|
58
|
-
const REPLAY_HISTORY_TIMEOUT_MS = 10_000;
|
|
59
|
-
|
|
60
|
-
function formatJsonForEdit(value: string): string {
|
|
61
|
-
try {
|
|
62
|
-
const parsed: unknown = JSON.parse(value);
|
|
63
|
-
return JSON.stringify(parsed, null, 2);
|
|
64
|
-
} catch {
|
|
65
|
-
return value;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function compactJsonForEdit(value: string): string {
|
|
70
|
-
try {
|
|
71
|
-
const parsed: unknown = JSON.parse(value);
|
|
72
|
-
return JSON.stringify(parsed);
|
|
73
|
-
} catch {
|
|
74
|
-
return value;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function readJsonEditState(value: string): JsonEditState {
|
|
79
|
-
try {
|
|
80
|
-
JSON.parse(value);
|
|
81
|
-
return { valid: true, message: "Valid JSON" };
|
|
82
|
-
} catch (err) {
|
|
83
|
-
return {
|
|
84
|
-
valid: false,
|
|
85
|
-
message: err instanceof Error ? err.message : "Invalid JSON",
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function formatElapsed(ms: number): string {
|
|
91
|
-
if (ms < 1000) return `${String(ms)}ms`;
|
|
92
|
-
return `${(ms / 1000).toFixed(1)}s`;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function formatMetricValue(
|
|
96
|
-
value: ReplayMetricValue,
|
|
97
|
-
metricId: ReplayMetricComparison["id"],
|
|
98
|
-
): string {
|
|
99
|
-
if (value === null) return "-";
|
|
100
|
-
if (typeof value === "boolean") return value ? "stream" : "non-stream";
|
|
101
|
-
switch (metricId) {
|
|
102
|
-
case "elapsed":
|
|
103
|
-
return formatElapsed(value);
|
|
104
|
-
case "input":
|
|
105
|
-
case "output":
|
|
106
|
-
case "bytes":
|
|
107
|
-
return value.toLocaleString();
|
|
108
|
-
case "status":
|
|
109
|
-
return String(value);
|
|
110
|
-
case "streaming":
|
|
111
|
-
return value ? "stream" : "non-stream";
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
function formatDelta(delta: number | null, metricId: ReplayMetricComparison["id"]): string {
|
|
116
|
-
if (delta === null) return "-";
|
|
117
|
-
const sign = delta > 0 ? "+" : "";
|
|
118
|
-
switch (metricId) {
|
|
119
|
-
case "elapsed":
|
|
120
|
-
return `${sign}${formatElapsed(delta)}`;
|
|
121
|
-
case "input":
|
|
122
|
-
case "output":
|
|
123
|
-
case "bytes":
|
|
124
|
-
case "status":
|
|
125
|
-
return `${sign}${delta.toLocaleString()}`;
|
|
126
|
-
case "streaming":
|
|
127
|
-
return "-";
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
function deltaToneClass(delta: number | null): string {
|
|
132
|
-
if (delta === null || delta === 0) return "text-muted-foreground";
|
|
133
|
-
if (delta > 0) return "text-amber-400";
|
|
134
|
-
return "text-emerald-400";
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function ReplayComparisonTable({
|
|
138
|
-
comparisons,
|
|
139
|
-
}: {
|
|
140
|
-
comparisons: ReplayMetricComparison[];
|
|
141
|
-
}): JSX.Element {
|
|
142
|
-
return (
|
|
143
|
-
<div className="overflow-hidden rounded-md border border-border">
|
|
144
|
-
<div className="grid grid-cols-[1fr_1fr_1fr_1fr] bg-muted/40 px-3 py-2 text-[11px] font-medium text-muted-foreground">
|
|
145
|
-
<span>Metric</span>
|
|
146
|
-
<span>Original</span>
|
|
147
|
-
<span>Replay</span>
|
|
148
|
-
<span>Delta</span>
|
|
149
|
-
</div>
|
|
150
|
-
{comparisons.map((comparison) => (
|
|
151
|
-
<div
|
|
152
|
-
key={comparison.id}
|
|
153
|
-
className="grid grid-cols-[1fr_1fr_1fr_1fr] border-t border-border px-3 py-2 text-xs"
|
|
154
|
-
>
|
|
155
|
-
<span className="text-muted-foreground">{comparison.label}</span>
|
|
156
|
-
<span className="font-mono">{formatMetricValue(comparison.original, comparison.id)}</span>
|
|
157
|
-
<span className="font-mono">{formatMetricValue(comparison.replay, comparison.id)}</span>
|
|
158
|
-
<span className={`font-mono ${deltaToneClass(comparison.delta)}`}>
|
|
159
|
-
{formatDelta(comparison.delta, comparison.id)}
|
|
160
|
-
</span>
|
|
161
|
-
</div>
|
|
162
|
-
))}
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export function ReplayDialog({
|
|
168
|
-
log,
|
|
169
|
-
displayNumber,
|
|
170
|
-
open,
|
|
171
|
-
onOpenChange,
|
|
172
|
-
}: ReplayDialogProps): JSX.Element {
|
|
173
|
-
const { providers } = useProviders();
|
|
174
|
-
const originalBody = log.rawRequestBody ?? "{}";
|
|
175
|
-
const [modifiedBody, setModifiedBody] = useState<string>(() => {
|
|
176
|
-
return formatJsonForEdit(originalBody);
|
|
177
|
-
});
|
|
178
|
-
const [replayResult, setReplayResult] = useState<ReplayResult | null>(null);
|
|
179
|
-
const [replayHistory, setReplayHistory] = useState<CapturedLog[]>([]);
|
|
180
|
-
const [loading, setLoading] = useState(false);
|
|
181
|
-
const [error, setError] = useState<string | null>(null);
|
|
182
|
-
const replayAbortRef = useRef<AbortController | null>(null);
|
|
183
|
-
const replayRequestIdRef = useRef(0);
|
|
184
|
-
const jsonEditState = useMemo(() => readJsonEditState(modifiedBody), [modifiedBody]);
|
|
185
|
-
|
|
186
|
-
const cancelReplay = useCallback(() => {
|
|
187
|
-
replayRequestIdRef.current += 1;
|
|
188
|
-
replayAbortRef.current?.abort();
|
|
189
|
-
replayAbortRef.current = null;
|
|
190
|
-
setLoading(false);
|
|
191
|
-
}, []);
|
|
192
|
-
|
|
193
|
-
const refreshReplayHistory = useCallback(async (): Promise<void> => {
|
|
194
|
-
if (!open) return;
|
|
195
|
-
try {
|
|
196
|
-
const data = await fetchJsonWithTimeout(
|
|
197
|
-
`/api/logs?replayOf=${String(log.id)}`,
|
|
198
|
-
ReplayHistorySchema,
|
|
199
|
-
REPLAY_HISTORY_TIMEOUT_MS,
|
|
200
|
-
);
|
|
201
|
-
setReplayHistory(data.logs);
|
|
202
|
-
} catch {
|
|
203
|
-
// Replay history is helpful context, not required for replay itself.
|
|
204
|
-
}
|
|
205
|
-
}, [log.id, open]);
|
|
206
|
-
|
|
207
|
-
useEffect(() => {
|
|
208
|
-
void refreshReplayHistory();
|
|
209
|
-
}, [refreshReplayHistory]);
|
|
210
|
-
|
|
211
|
-
useEffect(() => {
|
|
212
|
-
if (open) return undefined;
|
|
213
|
-
cancelReplay();
|
|
214
|
-
return undefined;
|
|
215
|
-
}, [cancelReplay, open]);
|
|
216
|
-
|
|
217
|
-
useEffect(() => {
|
|
218
|
-
return () => {
|
|
219
|
-
replayRequestIdRef.current += 1;
|
|
220
|
-
replayAbortRef.current?.abort();
|
|
221
|
-
replayAbortRef.current = null;
|
|
222
|
-
};
|
|
223
|
-
}, []);
|
|
224
|
-
|
|
225
|
-
async function handleReplay() {
|
|
226
|
-
if (!jsonEditState.valid) {
|
|
227
|
-
setError("Request body must be valid JSON before replay.");
|
|
228
|
-
return;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
replayAbortRef.current?.abort();
|
|
232
|
-
const requestId = replayRequestIdRef.current + 1;
|
|
233
|
-
replayRequestIdRef.current = requestId;
|
|
234
|
-
const controller = new AbortController();
|
|
235
|
-
replayAbortRef.current = controller;
|
|
236
|
-
|
|
237
|
-
setLoading(true);
|
|
238
|
-
setError(null);
|
|
239
|
-
setReplayResult(null);
|
|
240
|
-
|
|
241
|
-
try {
|
|
242
|
-
const data = await fetchJsonWithTimeout(
|
|
243
|
-
`/api/logs/${log.id}/replay`,
|
|
244
|
-
ReplayResultSchema,
|
|
245
|
-
REPLAY_TIMEOUT_MS,
|
|
246
|
-
{
|
|
247
|
-
method: "POST",
|
|
248
|
-
headers: { "Content-Type": "application/json" },
|
|
249
|
-
body: JSON.stringify({ modifiedBody }),
|
|
250
|
-
signal: controller.signal,
|
|
251
|
-
},
|
|
252
|
-
);
|
|
253
|
-
if (replayRequestIdRef.current !== requestId) return;
|
|
254
|
-
setReplayResult(data);
|
|
255
|
-
await refreshReplayHistory();
|
|
256
|
-
if (!data.success) {
|
|
257
|
-
setError(data.error ?? "Replay failed");
|
|
258
|
-
}
|
|
259
|
-
} catch (err) {
|
|
260
|
-
if (replayRequestIdRef.current !== requestId) return;
|
|
261
|
-
if (
|
|
262
|
-
err instanceof ApiTimeoutError ||
|
|
263
|
-
(err instanceof DOMException && err.name === "AbortError")
|
|
264
|
-
) {
|
|
265
|
-
setError("Replay timed out or was canceled.");
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
setError(err instanceof Error ? err.message : "Network error");
|
|
269
|
-
} finally {
|
|
270
|
-
if (replayRequestIdRef.current === requestId) {
|
|
271
|
-
replayAbortRef.current = null;
|
|
272
|
-
setLoading(false);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
function handleClose() {
|
|
278
|
-
cancelReplay();
|
|
279
|
-
setReplayResult(null);
|
|
280
|
-
setError(null);
|
|
281
|
-
onOpenChange(false);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function handleBodyChange(value: string): void {
|
|
285
|
-
setModifiedBody(value);
|
|
286
|
-
setReplayResult(null);
|
|
287
|
-
setError(null);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function handleFormatBody(): void {
|
|
291
|
-
handleBodyChange(formatJsonForEdit(modifiedBody));
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
function handleCompactBody(): void {
|
|
295
|
-
handleBodyChange(compactJsonForEdit(modifiedBody));
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
function handleResetBody(): void {
|
|
299
|
-
handleBodyChange(formatJsonForEdit(originalBody));
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
function handleOpenReplayLog(logId: number): void {
|
|
303
|
-
window.location.hash = `log-${String(logId)}`;
|
|
304
|
-
dispatchLogFocusRequest({ logId, tab: "request" });
|
|
305
|
-
onOpenChange(false);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const replayModelOptions = useMemo<ReplayModelOption[]>(() => {
|
|
309
|
-
const options: ReplayModelOption[] = [];
|
|
310
|
-
for (const provider of providers) {
|
|
311
|
-
for (const model of provider.models) {
|
|
312
|
-
if (model.trim().length === 0) continue;
|
|
313
|
-
options.push({
|
|
314
|
-
key: `${provider.id}:${model}`,
|
|
315
|
-
providerName: provider.name,
|
|
316
|
-
model,
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return options;
|
|
321
|
-
}, [providers]);
|
|
322
|
-
const currentReplayModel = readRequestModel(modifiedBody) ?? log.model ?? "";
|
|
323
|
-
|
|
324
|
-
function handleReplayModelChange(model: string): void {
|
|
325
|
-
const result = replaceRequestModel(modifiedBody, model);
|
|
326
|
-
if (result.error !== null) {
|
|
327
|
-
setError(result.error);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
handleBodyChange(formatJsonForEdit(result.body));
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
const originalMetrics = buildReplayMetrics({
|
|
334
|
-
status: log.responseStatus,
|
|
335
|
-
elapsedMs: log.elapsedMs,
|
|
336
|
-
inputTokens: log.inputTokens,
|
|
337
|
-
outputTokens: log.outputTokens,
|
|
338
|
-
responseText: log.responseText,
|
|
339
|
-
streaming: log.streaming,
|
|
340
|
-
});
|
|
341
|
-
const replayMetrics =
|
|
342
|
-
replayResult === null
|
|
343
|
-
? null
|
|
344
|
-
: buildReplayMetrics({
|
|
345
|
-
status: replayResult.responseStatus,
|
|
346
|
-
elapsedMs: replayResult.elapsedMs,
|
|
347
|
-
inputTokens: replayResult.inputTokens,
|
|
348
|
-
outputTokens: replayResult.outputTokens,
|
|
349
|
-
responseText: replayResult.responseText,
|
|
350
|
-
streaming: replayResult.streaming,
|
|
351
|
-
});
|
|
352
|
-
const replayComparisons =
|
|
353
|
-
replayMetrics === null ? [] : buildReplayComparisons(originalMetrics, replayMetrics);
|
|
354
|
-
const latestReplayHistory = replayHistory.slice(-5).reverse();
|
|
355
|
-
|
|
356
|
-
return (
|
|
357
|
-
<Dialog open={open} onOpenChange={handleClose}>
|
|
358
|
-
<DialogContent className="max-w-4xl max-h-[85vh] overflow-auto">
|
|
359
|
-
<DialogHeader>
|
|
360
|
-
<DialogTitle className="flex items-center gap-2">
|
|
361
|
-
<RotateCcw className="size-4" />
|
|
362
|
-
<span title={`Log ID ${String(log.id)}`}>Replay Request #{displayNumber}</span>
|
|
363
|
-
</DialogTitle>
|
|
364
|
-
</DialogHeader>
|
|
365
|
-
|
|
366
|
-
<Tabs defaultValue="modified">
|
|
367
|
-
<TabsList>
|
|
368
|
-
<TabsTrigger value="modified">Modified Request</TabsTrigger>
|
|
369
|
-
<TabsTrigger value="original">Original Response</TabsTrigger>
|
|
370
|
-
{replayResult && <TabsTrigger value="replay">Replay Response</TabsTrigger>}
|
|
371
|
-
{replayResult && <TabsTrigger value="compare">Compare</TabsTrigger>}
|
|
372
|
-
</TabsList>
|
|
373
|
-
|
|
374
|
-
<TabsContent value="modified" className="space-y-4">
|
|
375
|
-
{replayModelOptions.length > 0 && (
|
|
376
|
-
<div className="grid gap-1.5">
|
|
377
|
-
<label htmlFor={`replay-model-${String(log.id)}`} className="text-sm font-medium">
|
|
378
|
-
Replay target
|
|
379
|
-
</label>
|
|
380
|
-
<select
|
|
381
|
-
id={`replay-model-${String(log.id)}`}
|
|
382
|
-
value={currentReplayModel}
|
|
383
|
-
onChange={(event) => handleReplayModelChange(event.currentTarget.value)}
|
|
384
|
-
className="h-8 rounded-md border border-input bg-background px-2 text-sm"
|
|
385
|
-
>
|
|
386
|
-
{currentReplayModel === "" && <option value="">Select model</option>}
|
|
387
|
-
{currentReplayModel !== "" &&
|
|
388
|
-
!replayModelOptions.some((option) => option.model === currentReplayModel) && (
|
|
389
|
-
<option value={currentReplayModel}>{currentReplayModel}</option>
|
|
390
|
-
)}
|
|
391
|
-
{replayModelOptions.map((option) => (
|
|
392
|
-
<option key={option.key} value={option.model}>
|
|
393
|
-
{option.providerName} / {option.model}
|
|
394
|
-
</option>
|
|
395
|
-
))}
|
|
396
|
-
</select>
|
|
397
|
-
</div>
|
|
398
|
-
)}
|
|
399
|
-
{latestReplayHistory.length > 0 && (
|
|
400
|
-
<div className="space-y-2 rounded-md border border-border bg-muted/20 px-3 py-2">
|
|
401
|
-
<div className="flex items-center justify-between gap-2">
|
|
402
|
-
<div className="text-xs font-medium">Replay history</div>
|
|
403
|
-
<Button
|
|
404
|
-
type="button"
|
|
405
|
-
variant="ghost"
|
|
406
|
-
size="sm"
|
|
407
|
-
onClick={() => {
|
|
408
|
-
void refreshReplayHistory();
|
|
409
|
-
}}
|
|
410
|
-
>
|
|
411
|
-
Refresh
|
|
412
|
-
</Button>
|
|
413
|
-
</div>
|
|
414
|
-
<div className="grid gap-1">
|
|
415
|
-
{latestReplayHistory.map((historyLog) => (
|
|
416
|
-
<button
|
|
417
|
-
key={historyLog.id}
|
|
418
|
-
type="button"
|
|
419
|
-
onClick={() => handleOpenReplayLog(historyLog.id)}
|
|
420
|
-
className="grid grid-cols-[auto_1fr_auto_auto] items-center gap-2 rounded-sm px-2 py-1 text-left text-xs hover:bg-muted"
|
|
421
|
-
>
|
|
422
|
-
<span className="font-mono text-emerald-600">#{historyLog.id}</span>
|
|
423
|
-
<span className="truncate font-mono text-muted-foreground">
|
|
424
|
-
{historyLog.model ?? "unknown"}
|
|
425
|
-
</span>
|
|
426
|
-
<span className="font-mono text-muted-foreground">
|
|
427
|
-
{historyLog.responseStatus ?? "-"}
|
|
428
|
-
</span>
|
|
429
|
-
<span className="font-mono text-muted-foreground">
|
|
430
|
-
{historyLog.elapsedMs === null ? "-" : formatElapsed(historyLog.elapsedMs)}
|
|
431
|
-
</span>
|
|
432
|
-
</button>
|
|
433
|
-
))}
|
|
434
|
-
</div>
|
|
435
|
-
</div>
|
|
436
|
-
)}
|
|
437
|
-
<div className="space-y-2">
|
|
438
|
-
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
439
|
-
<label htmlFor={`replay-body-${String(log.id)}`} className="text-sm font-medium">
|
|
440
|
-
Request Body
|
|
441
|
-
</label>
|
|
442
|
-
<div className="flex items-center gap-2">
|
|
443
|
-
<span
|
|
444
|
-
className={
|
|
445
|
-
jsonEditState.valid ? "text-xs text-emerald-500" : "text-xs text-destructive"
|
|
446
|
-
}
|
|
447
|
-
>
|
|
448
|
-
{jsonEditState.message}
|
|
449
|
-
</span>
|
|
450
|
-
<Button
|
|
451
|
-
type="button"
|
|
452
|
-
variant="outline"
|
|
453
|
-
size="sm"
|
|
454
|
-
onClick={handleFormatBody}
|
|
455
|
-
disabled={!jsonEditState.valid}
|
|
456
|
-
title="Format JSON"
|
|
457
|
-
>
|
|
458
|
-
<Braces className="size-3.5" />
|
|
459
|
-
Format
|
|
460
|
-
</Button>
|
|
461
|
-
<Button
|
|
462
|
-
type="button"
|
|
463
|
-
variant="outline"
|
|
464
|
-
size="sm"
|
|
465
|
-
onClick={handleCompactBody}
|
|
466
|
-
disabled={!jsonEditState.valid}
|
|
467
|
-
title="Compact JSON"
|
|
468
|
-
>
|
|
469
|
-
<Minimize2 className="size-3.5" />
|
|
470
|
-
Compact
|
|
471
|
-
</Button>
|
|
472
|
-
<Button
|
|
473
|
-
type="button"
|
|
474
|
-
variant="ghost"
|
|
475
|
-
size="sm"
|
|
476
|
-
onClick={handleResetBody}
|
|
477
|
-
title="Reset to original request"
|
|
478
|
-
>
|
|
479
|
-
<RotateCcw className="size-3.5" />
|
|
480
|
-
Reset
|
|
481
|
-
</Button>
|
|
482
|
-
</div>
|
|
483
|
-
</div>
|
|
484
|
-
<TooltipProvider>
|
|
485
|
-
<Tooltip>
|
|
486
|
-
<TooltipTrigger asChild>
|
|
487
|
-
<textarea
|
|
488
|
-
id={`replay-body-${String(log.id)}`}
|
|
489
|
-
className="w-full min-h-80 p-3 font-mono text-xs leading-5 bg-muted rounded-md border border-input resize-y tabular-nums focus:outline-none focus:ring-2 focus:ring-ring"
|
|
490
|
-
value={modifiedBody}
|
|
491
|
-
onChange={(e) => handleBodyChange(e.target.value)}
|
|
492
|
-
spellCheck={false}
|
|
493
|
-
/>
|
|
494
|
-
</TooltipTrigger>
|
|
495
|
-
<TooltipContent>
|
|
496
|
-
Edit formatted JSON before re-sending to the provider
|
|
497
|
-
</TooltipContent>
|
|
498
|
-
</Tooltip>
|
|
499
|
-
</TooltipProvider>
|
|
500
|
-
</div>
|
|
501
|
-
|
|
502
|
-
{error !== null && error !== "" && (
|
|
503
|
-
<div className="text-sm text-destructive bg-destructive/10 px-3 py-2 rounded-md">
|
|
504
|
-
{error}
|
|
505
|
-
</div>
|
|
506
|
-
)}
|
|
507
|
-
|
|
508
|
-
<div className="flex justify-end">
|
|
509
|
-
<Button
|
|
510
|
-
onClick={() => {
|
|
511
|
-
void handleReplay();
|
|
512
|
-
}}
|
|
513
|
-
disabled={loading || !jsonEditState.valid}
|
|
514
|
-
>
|
|
515
|
-
{loading ? "Replaying..." : "Replay"}
|
|
516
|
-
</Button>
|
|
517
|
-
</div>
|
|
518
|
-
|
|
519
|
-
{replayResult !== null && (
|
|
520
|
-
<ReplayComparisonTable comparisons={replayComparisons.slice(0, 4)} />
|
|
521
|
-
)}
|
|
522
|
-
|
|
523
|
-
{replayResult?.success === true && replayResult.replayLogId !== undefined && (
|
|
524
|
-
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border border-emerald-500/25 bg-emerald-500/10 px-3 py-2 text-xs text-emerald-600">
|
|
525
|
-
<span>Replay saved as test log #{replayResult.replayLogId}.</span>
|
|
526
|
-
<Button
|
|
527
|
-
type="button"
|
|
528
|
-
variant="outline"
|
|
529
|
-
size="sm"
|
|
530
|
-
onClick={() => handleOpenReplayLog(replayResult.replayLogId ?? log.id)}
|
|
531
|
-
>
|
|
532
|
-
Open saved log
|
|
533
|
-
</Button>
|
|
534
|
-
</div>
|
|
535
|
-
)}
|
|
536
|
-
|
|
537
|
-
{replayResult && replayResult.success && (
|
|
538
|
-
<Tabs defaultValue="parsed">
|
|
539
|
-
<TabsList>
|
|
540
|
-
<TabsTrigger value="parsed">Response</TabsTrigger>
|
|
541
|
-
<TabsTrigger value="raw">Raw Response</TabsTrigger>
|
|
542
|
-
</TabsList>
|
|
543
|
-
<TabsContent value="parsed">
|
|
544
|
-
<ResponseView
|
|
545
|
-
responseText={replayResult.responseText ?? null}
|
|
546
|
-
responseStatus={replayResult.responseStatus ?? null}
|
|
547
|
-
streaming={replayResult.streaming ?? false}
|
|
548
|
-
inputTokens={replayResult.inputTokens ?? null}
|
|
549
|
-
outputTokens={replayResult.outputTokens ?? null}
|
|
550
|
-
apiFormat={log.apiFormat}
|
|
551
|
-
/>
|
|
552
|
-
</TabsContent>
|
|
553
|
-
<TabsContent value="raw">
|
|
554
|
-
<pre className="font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto">
|
|
555
|
-
{replayResult.responseText ?? "No response"}
|
|
556
|
-
</pre>
|
|
557
|
-
</TabsContent>
|
|
558
|
-
</Tabs>
|
|
559
|
-
)}
|
|
560
|
-
</TabsContent>
|
|
561
|
-
|
|
562
|
-
<TabsContent value="original">
|
|
563
|
-
{log.responseText !== null ? (
|
|
564
|
-
<Tabs defaultValue="parsed">
|
|
565
|
-
<TabsList>
|
|
566
|
-
<TabsTrigger value="parsed">Response</TabsTrigger>
|
|
567
|
-
<TabsTrigger value="raw">Raw Response</TabsTrigger>
|
|
568
|
-
</TabsList>
|
|
569
|
-
<TabsContent value="parsed">
|
|
570
|
-
<ResponseView
|
|
571
|
-
responseText={log.responseText}
|
|
572
|
-
responseStatus={log.responseStatus}
|
|
573
|
-
streaming={log.streaming}
|
|
574
|
-
inputTokens={log.inputTokens}
|
|
575
|
-
outputTokens={log.outputTokens}
|
|
576
|
-
cacheCreationInputTokens={log.cacheCreationInputTokens}
|
|
577
|
-
cacheReadInputTokens={log.cacheReadInputTokens}
|
|
578
|
-
apiFormat={log.apiFormat}
|
|
579
|
-
/>
|
|
580
|
-
</TabsContent>
|
|
581
|
-
<TabsContent value="raw">
|
|
582
|
-
<pre className="font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto">
|
|
583
|
-
{log.responseText}
|
|
584
|
-
</pre>
|
|
585
|
-
</TabsContent>
|
|
586
|
-
</Tabs>
|
|
587
|
-
) : (
|
|
588
|
-
<p className="text-sm text-muted-foreground italic">No original response</p>
|
|
589
|
-
)}
|
|
590
|
-
</TabsContent>
|
|
591
|
-
|
|
592
|
-
{replayResult && replayResult.success && (
|
|
593
|
-
<TabsContent value="replay">
|
|
594
|
-
{(replayResult.responseText ?? null) !== null ? (
|
|
595
|
-
<Tabs defaultValue="parsed">
|
|
596
|
-
<TabsList>
|
|
597
|
-
<TabsTrigger value="parsed">Response</TabsTrigger>
|
|
598
|
-
<TabsTrigger value="raw">Raw Response</TabsTrigger>
|
|
599
|
-
</TabsList>
|
|
600
|
-
<TabsContent value="parsed">
|
|
601
|
-
<ResponseView
|
|
602
|
-
responseText={replayResult.responseText ?? null}
|
|
603
|
-
responseStatus={replayResult.responseStatus ?? null}
|
|
604
|
-
streaming={replayResult.streaming ?? false}
|
|
605
|
-
inputTokens={replayResult.inputTokens ?? null}
|
|
606
|
-
outputTokens={replayResult.outputTokens ?? null}
|
|
607
|
-
apiFormat={log.apiFormat}
|
|
608
|
-
/>
|
|
609
|
-
</TabsContent>
|
|
610
|
-
<TabsContent value="raw">
|
|
611
|
-
<pre className="font-mono text-xs whitespace-pre-wrap bg-muted p-3 rounded-md max-h-96 overflow-auto">
|
|
612
|
-
{replayResult.responseText ?? ""}
|
|
613
|
-
</pre>
|
|
614
|
-
</TabsContent>
|
|
615
|
-
</Tabs>
|
|
616
|
-
) : (
|
|
617
|
-
<p className="text-sm text-muted-foreground italic">No replay response</p>
|
|
618
|
-
)}
|
|
619
|
-
</TabsContent>
|
|
620
|
-
)}
|
|
621
|
-
|
|
622
|
-
{replayResult && (
|
|
623
|
-
<TabsContent value="compare" className="space-y-3">
|
|
624
|
-
<ReplayComparisonTable comparisons={replayComparisons} />
|
|
625
|
-
{replayResult.success ? null : (
|
|
626
|
-
<div className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive">
|
|
627
|
-
{replayResult.error ?? "Replay failed"}
|
|
628
|
-
</div>
|
|
629
|
-
)}
|
|
630
|
-
</TabsContent>
|
|
631
|
-
)}
|
|
632
|
-
</Tabs>
|
|
633
|
-
</DialogContent>
|
|
634
|
-
</Dialog>
|
|
635
|
-
);
|
|
636
|
-
}
|