@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,299 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Blocks,
|
|
3
|
-
Check,
|
|
4
|
-
ChevronDown,
|
|
5
|
-
ChevronRight,
|
|
6
|
-
Code2,
|
|
7
|
-
Copy,
|
|
8
|
-
FileText,
|
|
9
|
-
Globe,
|
|
10
|
-
MoreHorizontal,
|
|
11
|
-
MousePointerClick,
|
|
12
|
-
Search,
|
|
13
|
-
Terminal,
|
|
14
|
-
Wrench,
|
|
15
|
-
} from "lucide-react";
|
|
16
|
-
import { memo, Suspense, useMemo, useState, type JSX } from "react";
|
|
17
|
-
import { cn } from "../../lib/utils";
|
|
18
|
-
import { Badge } from "../ui/badge";
|
|
19
|
-
import { Button } from "../ui/button";
|
|
20
|
-
import { Collapsible, CollapsibleContent } from "../ui/collapsible";
|
|
21
|
-
import { safeJsonValue } from "../ui/json-viewer-bulk";
|
|
22
|
-
import { ScrollArea } from "../ui/scroll-area";
|
|
23
|
-
import type {
|
|
24
|
-
RequestToolCategory,
|
|
25
|
-
RequestToolDefinition,
|
|
26
|
-
RequestToolsSummary,
|
|
27
|
-
} from "./requestTools";
|
|
28
|
-
import { LazyJsonViewer } from "./lazy";
|
|
29
|
-
import { useCopyFeedback } from "./useCopyFeedback";
|
|
30
|
-
|
|
31
|
-
type RequestToolsProps = {
|
|
32
|
-
summary: RequestToolsSummary | null;
|
|
33
|
-
calledToolNames: readonly string[];
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const CATEGORY_LABELS: Record<RequestToolCategory, string> = {
|
|
37
|
-
file: "file",
|
|
38
|
-
shell: "shell",
|
|
39
|
-
browser: "browser",
|
|
40
|
-
web: "web",
|
|
41
|
-
mcp: "MCP",
|
|
42
|
-
code: "code",
|
|
43
|
-
other: "other",
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const CATEGORY_CLASSES: Record<RequestToolCategory, string> = {
|
|
47
|
-
file: "border-transparent bg-blue-400/5 text-blue-300",
|
|
48
|
-
shell: "border-transparent bg-teal-400/5 text-teal-300",
|
|
49
|
-
browser: "border-transparent bg-cyan-400/5 text-cyan-300",
|
|
50
|
-
web: "border-transparent bg-sky-400/5 text-sky-300",
|
|
51
|
-
mcp: "border-transparent bg-violet-400/5 text-violet-300",
|
|
52
|
-
code: "border-transparent bg-emerald-400/5 text-emerald-300",
|
|
53
|
-
other: "border-transparent bg-muted/30 text-muted-foreground",
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function CategoryIcon({ category }: { category: RequestToolCategory }): JSX.Element {
|
|
57
|
-
switch (category) {
|
|
58
|
-
case "file":
|
|
59
|
-
return <FileText className="size-3.5" />;
|
|
60
|
-
case "shell":
|
|
61
|
-
return <Terminal className="size-3.5" />;
|
|
62
|
-
case "browser":
|
|
63
|
-
return <MousePointerClick className="size-3.5" />;
|
|
64
|
-
case "web":
|
|
65
|
-
return <Globe className="size-3.5" />;
|
|
66
|
-
case "mcp":
|
|
67
|
-
return <Blocks className="size-3.5" />;
|
|
68
|
-
case "code":
|
|
69
|
-
return <Code2 className="size-3.5" />;
|
|
70
|
-
case "other":
|
|
71
|
-
return <MoreHorizontal className="size-3.5" />;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function RequiredParameters({ names }: { names: readonly string[] }): JSX.Element | null {
|
|
76
|
-
if (names.length === 0) return null;
|
|
77
|
-
return (
|
|
78
|
-
<div className="flex min-w-0 flex-wrap items-center gap-1">
|
|
79
|
-
<span className="text-[10px] uppercase tracking-wide text-muted-foreground">required</span>
|
|
80
|
-
{names.slice(0, 4).map((name) => (
|
|
81
|
-
<Badge
|
|
82
|
-
key={name}
|
|
83
|
-
variant="outline"
|
|
84
|
-
className="h-5 max-w-36 truncate rounded-md px-1.5 py-0 font-mono text-[10px]"
|
|
85
|
-
>
|
|
86
|
-
{name}
|
|
87
|
-
</Badge>
|
|
88
|
-
))}
|
|
89
|
-
{names.length > 4 && (
|
|
90
|
-
<span className="font-mono text-[10px] text-muted-foreground">+{names.length - 4}</span>
|
|
91
|
-
)}
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function ToolRow({ tool, called }: { tool: RequestToolDefinition; called: boolean }): JSX.Element {
|
|
97
|
-
const [open, setOpen] = useState(false);
|
|
98
|
-
const nameCopy = useCopyFeedback(tool.name);
|
|
99
|
-
const hasDetails =
|
|
100
|
-
tool.description !== null || tool.requiredParameters.length > 0 || tool.schema !== null;
|
|
101
|
-
|
|
102
|
-
return (
|
|
103
|
-
<Collapsible open={open} onOpenChange={setOpen}>
|
|
104
|
-
<div className="bg-white/[0.035] rounded-[8px]">
|
|
105
|
-
<div className="flex min-w-0 items-center gap-2 px-2.5 py-2">
|
|
106
|
-
<button
|
|
107
|
-
type="button"
|
|
108
|
-
className="flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
109
|
-
onClick={() => setOpen((value) => !value)}
|
|
110
|
-
aria-expanded={open}
|
|
111
|
-
disabled={!hasDetails}
|
|
112
|
-
>
|
|
113
|
-
<CategoryIcon category={tool.category} />
|
|
114
|
-
<span className="min-w-0 truncate font-mono text-xs font-semibold text-foreground/90">
|
|
115
|
-
{tool.name}
|
|
116
|
-
</span>
|
|
117
|
-
{called && (
|
|
118
|
-
<Badge
|
|
119
|
-
variant="outline"
|
|
120
|
-
className="h-5 rounded-md border-emerald-400/20 bg-emerald-400/5 px-1.5 py-0 text-[10px] text-emerald-300"
|
|
121
|
-
>
|
|
122
|
-
called
|
|
123
|
-
</Badge>
|
|
124
|
-
)}
|
|
125
|
-
<span className="font-mono text-[10px] text-muted-foreground">
|
|
126
|
-
{tool.parameterCount} params
|
|
127
|
-
</span>
|
|
128
|
-
{tool.descriptionPreview !== null && (
|
|
129
|
-
<span className="hidden min-w-0 truncate text-xs text-muted-foreground md:inline">
|
|
130
|
-
{tool.descriptionPreview}
|
|
131
|
-
</span>
|
|
132
|
-
)}
|
|
133
|
-
<span className="flex-1" />
|
|
134
|
-
{hasDetails &&
|
|
135
|
-
(open ? (
|
|
136
|
-
<ChevronDown className="size-3.5 shrink-0 text-muted-foreground" />
|
|
137
|
-
) : (
|
|
138
|
-
<ChevronRight className="size-3.5 shrink-0 text-muted-foreground" />
|
|
139
|
-
))}
|
|
140
|
-
</button>
|
|
141
|
-
<button
|
|
142
|
-
type="button"
|
|
143
|
-
className="bg-white/[0.045] hover:bg-white/[0.075] inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
144
|
-
onClick={nameCopy.copy}
|
|
145
|
-
aria-label={nameCopy.copied ? "Copied tool name" : "Copy tool name"}
|
|
146
|
-
>
|
|
147
|
-
{nameCopy.copied ? (
|
|
148
|
-
<Check className="size-3.5 text-emerald-400" />
|
|
149
|
-
) : (
|
|
150
|
-
<Copy className="size-3.5" />
|
|
151
|
-
)}
|
|
152
|
-
</button>
|
|
153
|
-
</div>
|
|
154
|
-
<CollapsibleContent>
|
|
155
|
-
{open && (
|
|
156
|
-
<div className="space-y-2 bg-white/[0.025] px-2.5 py-2">
|
|
157
|
-
{tool.description !== null && (
|
|
158
|
-
<p className="text-xs leading-relaxed text-muted-foreground">{tool.description}</p>
|
|
159
|
-
)}
|
|
160
|
-
<RequiredParameters names={tool.requiredParameters} />
|
|
161
|
-
{tool.schema !== null && (
|
|
162
|
-
<ScrollArea className="bg-black/[0.16] max-h-64 rounded-[8px] p-2">
|
|
163
|
-
<Suspense
|
|
164
|
-
fallback={<div className="text-xs text-muted-foreground">Loading JSON...</div>}
|
|
165
|
-
>
|
|
166
|
-
<LazyJsonViewer data={safeJsonValue(tool.schema)} defaultExpandDepth={0} />
|
|
167
|
-
</Suspense>
|
|
168
|
-
</ScrollArea>
|
|
169
|
-
)}
|
|
170
|
-
</div>
|
|
171
|
-
)}
|
|
172
|
-
</CollapsibleContent>
|
|
173
|
-
</div>
|
|
174
|
-
</Collapsible>
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function matchesQuery(tool: RequestToolDefinition, query: string): boolean {
|
|
179
|
-
if (query.length === 0) return true;
|
|
180
|
-
const haystack = `${tool.name} ${tool.description ?? ""} ${CATEGORY_LABELS[tool.category]}`
|
|
181
|
-
.toLowerCase()
|
|
182
|
-
.trim();
|
|
183
|
-
return haystack.includes(query);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
187
|
-
export const RequestTools = memo(function RequestTools({
|
|
188
|
-
summary,
|
|
189
|
-
calledToolNames,
|
|
190
|
-
}: RequestToolsProps): JSX.Element | null {
|
|
191
|
-
const [expanded, setExpanded] = useState(false);
|
|
192
|
-
const [query, setQuery] = useState("");
|
|
193
|
-
const calledNames = useMemo(() => new Set(calledToolNames), [calledToolNames]);
|
|
194
|
-
const normalizedQuery = query.trim().toLowerCase();
|
|
195
|
-
const visibleTools = useMemo(
|
|
196
|
-
() =>
|
|
197
|
-
summary === null ? [] : summary.tools.filter((tool) => matchesQuery(tool, normalizedQuery)),
|
|
198
|
-
[normalizedQuery, summary],
|
|
199
|
-
);
|
|
200
|
-
|
|
201
|
-
if (summary === null) return null;
|
|
202
|
-
|
|
203
|
-
const previewTools = summary.tools.slice(0, 6);
|
|
204
|
-
const hiddenPreviewCount = summary.tools.length - previewTools.length;
|
|
205
|
-
|
|
206
|
-
return (
|
|
207
|
-
<section className="bg-black/[0.10] mb-3 overflow-hidden rounded-[8px]">
|
|
208
|
-
<div className="flex min-w-0 flex-wrap items-center gap-2 px-3 py-2">
|
|
209
|
-
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
210
|
-
<Wrench className="size-4 shrink-0 text-sky-300/80" />
|
|
211
|
-
<div className="min-w-0">
|
|
212
|
-
<div className="flex min-w-0 flex-wrap items-center gap-1.5">
|
|
213
|
-
<span className="text-sm font-semibold text-foreground">Request Tools</span>
|
|
214
|
-
<Badge variant="outline" className="h-5 rounded-md px-1.5 py-0 font-mono text-[10px]">
|
|
215
|
-
{summary.tools.length}
|
|
216
|
-
</Badge>
|
|
217
|
-
{summary.toolChoiceLabel !== null && (
|
|
218
|
-
<Badge
|
|
219
|
-
variant="outline"
|
|
220
|
-
className="h-5 rounded-md px-1.5 py-0 font-mono text-[10px] text-muted-foreground"
|
|
221
|
-
>
|
|
222
|
-
tool_choice: {summary.toolChoiceLabel}
|
|
223
|
-
</Badge>
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
226
|
-
<div className="mt-1 flex min-w-0 flex-wrap gap-1">
|
|
227
|
-
{summary.categories.map((category) => (
|
|
228
|
-
<Badge
|
|
229
|
-
key={category.category}
|
|
230
|
-
variant="outline"
|
|
231
|
-
className={cn(
|
|
232
|
-
"h-5 rounded-md px-1.5 py-0 font-mono text-[10px]",
|
|
233
|
-
CATEGORY_CLASSES[category.category],
|
|
234
|
-
)}
|
|
235
|
-
>
|
|
236
|
-
{category.count} {CATEGORY_LABELS[category.category]}
|
|
237
|
-
</Badge>
|
|
238
|
-
))}
|
|
239
|
-
</div>
|
|
240
|
-
</div>
|
|
241
|
-
</div>
|
|
242
|
-
<Button
|
|
243
|
-
type="button"
|
|
244
|
-
variant="ghost"
|
|
245
|
-
size="sm"
|
|
246
|
-
className="h-7 px-2 text-muted-foreground hover:text-cyan-100"
|
|
247
|
-
onClick={() => setExpanded((value) => !value)}
|
|
248
|
-
aria-expanded={expanded}
|
|
249
|
-
>
|
|
250
|
-
{expanded ? <ChevronDown className="size-3.5" /> : <ChevronRight className="size-3.5" />}
|
|
251
|
-
{expanded ? "Hide" : "Show"}
|
|
252
|
-
</Button>
|
|
253
|
-
</div>
|
|
254
|
-
|
|
255
|
-
<div className="flex min-w-0 flex-wrap gap-1.5 bg-white/[0.025] px-3 py-2">
|
|
256
|
-
{previewTools.map((tool) => (
|
|
257
|
-
<Badge
|
|
258
|
-
key={tool.name}
|
|
259
|
-
variant="outline"
|
|
260
|
-
className={cn(
|
|
261
|
-
"h-5 max-w-44 truncate rounded-md px-1.5 py-0 font-mono text-[10px]",
|
|
262
|
-
calledNames.has(tool.name) && "border-emerald-400/20 text-emerald-300",
|
|
263
|
-
)}
|
|
264
|
-
>
|
|
265
|
-
{tool.name}
|
|
266
|
-
</Badge>
|
|
267
|
-
))}
|
|
268
|
-
{hiddenPreviewCount > 0 && (
|
|
269
|
-
<span className="font-mono text-[10px] leading-5 text-muted-foreground">
|
|
270
|
-
+{hiddenPreviewCount}
|
|
271
|
-
</span>
|
|
272
|
-
)}
|
|
273
|
-
</div>
|
|
274
|
-
|
|
275
|
-
{expanded && (
|
|
276
|
-
<div className="space-y-2 bg-black/10 px-3 py-3">
|
|
277
|
-
<label className="bg-white/[0.045] hover:bg-white/[0.075] flex h-8 items-center gap-2 rounded-md px-2 text-xs">
|
|
278
|
-
<Search className="size-3.5 shrink-0 text-muted-foreground" />
|
|
279
|
-
<input
|
|
280
|
-
value={query}
|
|
281
|
-
onChange={(event) => setQuery(event.target.value)}
|
|
282
|
-
placeholder="Filter tools"
|
|
283
|
-
className="min-w-0 flex-1 bg-transparent font-mono text-xs outline-none placeholder:text-muted-foreground/70"
|
|
284
|
-
/>
|
|
285
|
-
</label>
|
|
286
|
-
<div className="grid gap-1.5">
|
|
287
|
-
{visibleTools.length > 0 ? (
|
|
288
|
-
visibleTools.map((tool) => (
|
|
289
|
-
<ToolRow key={tool.name} tool={tool} called={calledNames.has(tool.name)} />
|
|
290
|
-
))
|
|
291
|
-
) : (
|
|
292
|
-
<p className="py-2 text-xs text-muted-foreground">No matching tools</p>
|
|
293
|
-
)}
|
|
294
|
-
</div>
|
|
295
|
-
</div>
|
|
296
|
-
)}
|
|
297
|
-
</section>
|
|
298
|
-
);
|
|
299
|
-
});
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { AlertTriangle, Zap } from "lucide-react";
|
|
2
|
-
import type { JSX } from "react";
|
|
3
|
-
import { memo, useEffect, useState } from "react";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { cn, formatTokens, getStatusCategory, type StatusCategory } from "../../lib/utils";
|
|
6
|
-
import type { ApiFormat } from "../../contracts";
|
|
7
|
-
import { AnswerMarkdown } from "./AnswerMarkdown";
|
|
8
|
-
import { formatViewFor } from "./formats";
|
|
9
|
-
import { getLogFormatAdapter } from "./log-formats";
|
|
10
|
-
|
|
11
|
-
export type ResponseViewProps = {
|
|
12
|
-
responseText: string | null;
|
|
13
|
-
responseStatus: number | null;
|
|
14
|
-
streaming: boolean;
|
|
15
|
-
inputTokens: number | null;
|
|
16
|
-
outputTokens: number | null;
|
|
17
|
-
cacheCreationInputTokens?: number | null;
|
|
18
|
-
cacheReadInputTokens?: number | null;
|
|
19
|
-
apiFormat?: ApiFormat;
|
|
20
|
-
/** SSE error message from streaming response */
|
|
21
|
-
error?: string | null;
|
|
22
|
-
focusedToolIndex?: number | null;
|
|
23
|
-
toolFocusNonce?: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function getStatusClasses(category: StatusCategory): string {
|
|
27
|
-
switch (category) {
|
|
28
|
-
case "success":
|
|
29
|
-
return "text-emerald-400";
|
|
30
|
-
case "client_error":
|
|
31
|
-
return "text-amber-400";
|
|
32
|
-
case "server_error":
|
|
33
|
-
return "text-red-400";
|
|
34
|
-
case "pending":
|
|
35
|
-
return "text-muted-foreground";
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function StatusIndicator({ status }: { status: number | null }): JSX.Element {
|
|
40
|
-
const category = getStatusCategory(status);
|
|
41
|
-
const classes = getStatusClasses(category);
|
|
42
|
-
|
|
43
|
-
if (status === null) {
|
|
44
|
-
return <span className="text-xs text-muted-foreground italic">pending</span>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<span className={cn("flex items-center gap-1 text-xs font-mono font-semibold", classes)}>
|
|
49
|
-
{category === "server_error" && <AlertTriangle className="size-3" />}
|
|
50
|
-
{status}
|
|
51
|
-
</span>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function ErrorResponseView({ text }: { text: string }): JSX.Element {
|
|
56
|
-
return (
|
|
57
|
-
<div className="rounded-md border border-red-500/30 bg-red-500/5 p-3">
|
|
58
|
-
<pre className="text-xs text-red-300 whitespace-pre-wrap font-mono leading-relaxed overflow-auto max-h-[60vh]">
|
|
59
|
-
{text}
|
|
60
|
-
</pre>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function MarkdownFallbackView({ text }: { text: string }): JSX.Element {
|
|
66
|
-
return <AnswerMarkdown text={text} />;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const RESPONSE_AUTO_PARSE_MAX_CHARS = 1024 * 1024;
|
|
70
|
-
|
|
71
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow -- named function gives React DevTools a readable displayName
|
|
72
|
-
export const ResponseView = memo(function ResponseView({
|
|
73
|
-
responseText,
|
|
74
|
-
responseStatus,
|
|
75
|
-
streaming,
|
|
76
|
-
inputTokens,
|
|
77
|
-
outputTokens,
|
|
78
|
-
cacheCreationInputTokens,
|
|
79
|
-
cacheReadInputTokens,
|
|
80
|
-
apiFormat,
|
|
81
|
-
error,
|
|
82
|
-
focusedToolIndex = null,
|
|
83
|
-
toolFocusNonce = 0,
|
|
84
|
-
}: ResponseViewProps): JSX.Element {
|
|
85
|
-
const resolvedFormat = apiFormat ?? "unknown";
|
|
86
|
-
const [parseLargeResponse, setParseLargeResponse] = useState(false);
|
|
87
|
-
const shouldDeferStructuredParse =
|
|
88
|
-
responseText !== null && responseText.length > RESPONSE_AUTO_PARSE_MAX_CHARS;
|
|
89
|
-
const responseTextForStructuredParse =
|
|
90
|
-
responseText === null || (shouldDeferStructuredParse && !parseLargeResponse)
|
|
91
|
-
? null
|
|
92
|
-
: responseText;
|
|
93
|
-
const parsed = useMemo(
|
|
94
|
-
() =>
|
|
95
|
-
getLogFormatAdapter(resolvedFormat).analyzeResponse(responseTextForStructuredParse).parsed,
|
|
96
|
-
[resolvedFormat, responseTextForStructuredParse],
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
useEffect(() => {
|
|
100
|
-
setParseLargeResponse(false);
|
|
101
|
-
}, [responseText]);
|
|
102
|
-
|
|
103
|
-
if (responseText === null && error === undefined) {
|
|
104
|
-
return (
|
|
105
|
-
<div className="flex items-center gap-2 py-3">
|
|
106
|
-
<StatusIndicator status={responseStatus} />
|
|
107
|
-
<span className="text-xs text-muted-foreground italic">No response</span>
|
|
108
|
-
</div>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const isHttpError = responseStatus !== null && responseStatus >= 400;
|
|
113
|
-
|
|
114
|
-
if (isHttpError) {
|
|
115
|
-
return (
|
|
116
|
-
<div className="space-y-2">
|
|
117
|
-
<StatusIndicator status={responseStatus} />
|
|
118
|
-
<ErrorResponseView text={responseText ?? ""} />
|
|
119
|
-
{error !== undefined && error !== null && (
|
|
120
|
-
<div className="rounded border border-destructive/50 bg-destructive/10 p-3 text-xs">
|
|
121
|
-
<div className="font-semibold text-destructive mb-1">SSE Error</div>
|
|
122
|
-
<div className="text-muted-foreground font-mono">{error}</div>
|
|
123
|
-
</div>
|
|
124
|
-
)}
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (error !== undefined && error !== null) {
|
|
130
|
-
return (
|
|
131
|
-
<div className="space-y-2">
|
|
132
|
-
<StatusIndicator status={responseStatus} />
|
|
133
|
-
<div className="rounded border border-destructive/50 bg-destructive/10 p-3 text-xs">
|
|
134
|
-
<div className="font-semibold text-destructive mb-1">SSE Error</div>
|
|
135
|
-
<div className="text-muted-foreground font-mono">{error}</div>
|
|
136
|
-
</div>
|
|
137
|
-
{responseText !== null && (
|
|
138
|
-
<div className="mt-2">
|
|
139
|
-
<ErrorResponseView text={responseText} />
|
|
140
|
-
</div>
|
|
141
|
-
)}
|
|
142
|
-
</div>
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (parsed !== null) {
|
|
147
|
-
return (
|
|
148
|
-
<div className="space-y-2">
|
|
149
|
-
<StatusIndicator status={responseStatus} />
|
|
150
|
-
{formatViewFor(resolvedFormat, parsed, { focusedToolIndex, toolFocusNonce })}
|
|
151
|
-
</div>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<div className="space-y-2">
|
|
157
|
-
<div className="flex items-center gap-2">
|
|
158
|
-
<StatusIndicator status={responseStatus} />
|
|
159
|
-
{streaming && (inputTokens !== null || outputTokens !== null) && (
|
|
160
|
-
<span className="flex items-center gap-1 text-muted-foreground text-xs">
|
|
161
|
-
<Zap className="size-3" />
|
|
162
|
-
<span className="font-mono tabular-nums">
|
|
163
|
-
{inputTokens !== null ? formatTokens(inputTokens) : "—"} in /{" "}
|
|
164
|
-
{outputTokens !== null ? formatTokens(outputTokens) : "—"} out
|
|
165
|
-
</span>
|
|
166
|
-
{cacheCreationInputTokens !== null &&
|
|
167
|
-
cacheCreationInputTokens !== undefined &&
|
|
168
|
-
cacheCreationInputTokens > 0 && (
|
|
169
|
-
<span className="font-mono tabular-nums text-emerald-400">
|
|
170
|
-
KV Cache +{formatTokens(cacheCreationInputTokens)}
|
|
171
|
-
</span>
|
|
172
|
-
)}
|
|
173
|
-
{cacheReadInputTokens !== null &&
|
|
174
|
-
cacheReadInputTokens !== undefined &&
|
|
175
|
-
cacheReadInputTokens > 0 && (
|
|
176
|
-
<span className="font-mono tabular-nums text-purple-400">
|
|
177
|
-
KV Cache ~{formatTokens(cacheReadInputTokens)}
|
|
178
|
-
</span>
|
|
179
|
-
)}
|
|
180
|
-
</span>
|
|
181
|
-
)}
|
|
182
|
-
</div>
|
|
183
|
-
{shouldDeferStructuredParse && !parseLargeResponse && (
|
|
184
|
-
<div className="rounded-md border border-amber-300/20 bg-amber-300/[0.06] px-3 py-2 text-xs text-muted-foreground">
|
|
185
|
-
<div className="mb-2">
|
|
186
|
-
This response is {responseText.length.toLocaleString()} characters, so structured
|
|
187
|
-
parsing is deferred to keep the UI responsive. The final Response remains available here
|
|
188
|
-
without rendering the raw event stream by default.
|
|
189
|
-
</div>
|
|
190
|
-
<button
|
|
191
|
-
type="button"
|
|
192
|
-
className="rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground"
|
|
193
|
-
onClick={() => setParseLargeResponse(true)}
|
|
194
|
-
>
|
|
195
|
-
Parse full structured response
|
|
196
|
-
</button>
|
|
197
|
-
</div>
|
|
198
|
-
)}
|
|
199
|
-
<MarkdownFallbackView text={responseText ?? ""} />
|
|
200
|
-
</div>
|
|
201
|
-
);
|
|
202
|
-
});
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { type JSX } from "react";
|
|
2
|
-
import { cn } from "../../lib/utils";
|
|
3
|
-
|
|
4
|
-
export type SessionLoadProgress = {
|
|
5
|
-
label: string;
|
|
6
|
-
elapsedMs: number;
|
|
7
|
-
timeoutMs: number;
|
|
8
|
-
loadedLogs: number;
|
|
9
|
-
loadedPages: number;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
function formatDurationSeconds(ms: number): string {
|
|
13
|
-
return `${Math.max(0, Math.ceil(ms / 1000)).toString()}s`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function SessionLoadProgressBar({
|
|
17
|
-
progress,
|
|
18
|
-
}: {
|
|
19
|
-
progress: SessionLoadProgress;
|
|
20
|
-
}): JSX.Element {
|
|
21
|
-
const elapsedRatio = Math.min(1, progress.elapsedMs / progress.timeoutMs);
|
|
22
|
-
const percent = Math.max(4, Math.round(elapsedRatio * 100));
|
|
23
|
-
const remainingMs = Math.max(0, progress.timeoutMs - progress.elapsedMs);
|
|
24
|
-
const nearTimeout = elapsedRatio >= 0.75;
|
|
25
|
-
const details = [
|
|
26
|
-
progress.loadedLogs > 0 ? `${progress.loadedLogs.toString()} logs` : null,
|
|
27
|
-
progress.loadedPages > 0
|
|
28
|
-
? `${progress.loadedPages.toString()} page${progress.loadedPages === 1 ? "" : "s"}`
|
|
29
|
-
: null,
|
|
30
|
-
`${formatDurationSeconds(remainingMs)} before timeout`,
|
|
31
|
-
].filter((item): item is string => item !== null);
|
|
32
|
-
const valueText = `${progress.label}: ${details.join(", ")}`;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<div className="min-w-0 space-y-1 px-1 pb-1">
|
|
36
|
-
<div className="flex min-w-0 items-center justify-between gap-3 font-mono text-[10px] text-muted-foreground">
|
|
37
|
-
<span className="min-w-0 truncate">{progress.label}</span>
|
|
38
|
-
<span className={cn("shrink-0 tabular-nums", nearTimeout && "text-amber-300")}>
|
|
39
|
-
{details.join(" / ")}
|
|
40
|
-
</span>
|
|
41
|
-
</div>
|
|
42
|
-
<div
|
|
43
|
-
role="progressbar"
|
|
44
|
-
aria-label={progress.label}
|
|
45
|
-
aria-valuemin={0}
|
|
46
|
-
aria-valuemax={progress.timeoutMs}
|
|
47
|
-
aria-valuenow={Math.min(progress.elapsedMs, progress.timeoutMs)}
|
|
48
|
-
aria-valuetext={valueText}
|
|
49
|
-
className="h-1.5 overflow-hidden rounded-full bg-white/[0.06]"
|
|
50
|
-
>
|
|
51
|
-
<div
|
|
52
|
-
className={cn(
|
|
53
|
-
"h-full rounded-full transition-all duration-300 motion-reduce:transition-none",
|
|
54
|
-
nearTimeout ? "bg-amber-300/80" : "bg-cyan-300/70",
|
|
55
|
-
)}
|
|
56
|
-
style={{ width: `${percent.toString()}%` }}
|
|
57
|
-
/>
|
|
58
|
-
</div>
|
|
59
|
-
</div>
|
|
60
|
-
);
|
|
61
|
-
}
|