@tonyclaw/agent-inspector 4.0.1 → 4.0.3
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 +193 -110
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CTHqmroT.mjs → router-ChILzhmz.mjs} +92 -4
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-L3n4J-Or.js → CompareDrawer-Co3cUF_I.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D5o_3OZS.js → InspectorPet-jFcrL37X.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Ocagx75S.js → ProxyViewerContainer-BPzt_VpM.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-Bk7x1h-y.js → ReplayDialog-C6O_zuwI.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-U4lzL7Sc.js → RequestAnatomy-Ca6NvB7L.js} +1 -1
- package/.output/ui/assets/{ResponseView-LOWfvBLK.js → ResponseView-BzqKcveJ.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DPfsrrXQ.js → StreamingChunkSequence-9pCZIsS_.js} +1 -1
- package/.output/ui/assets/{_sessionId-0MlWS-CO.js → _sessionId-BMP3KVGR.js} +1 -1
- package/.output/ui/assets/{_sessionId-OdX2Jvt1.js → _sessionId-y4eRoT1H.js} +1 -1
- package/.output/ui/assets/{index-Ea-c8hPg.js → index-CH5w-haG.js} +1 -1
- package/.output/ui/assets/{index-zVVS53Hd.js → index-CmocEhyU.js} +1 -1
- package/.output/ui/assets/{index-Du4qNOOt.js → index-DT8sMJ_n.js} +2 -2
- package/.output/ui/assets/{index-gvFj_9K6.js → index-bfsbIRZa.js} +1 -1
- package/.output/ui/assets/{json-viewer-C1WAMzg3.js → json-viewer-BfFOSDG5.js} +1 -1
- package/.output/ui/assets/{jszip.min-B8AKu2zm.js → jszip.min-BkbVkOsp.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +5 -10
- 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 -1433
- 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 -258
- 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,615 +0,0 @@
|
|
|
1
|
-
import { type JSX, useEffect, useMemo, useState } from "react";
|
|
2
|
-
import { AlertTriangle, Bell, Clock3, Loader2, RefreshCw, ShieldAlert, Siren } from "lucide-react";
|
|
3
|
-
import type { Alert, AlertCategory, AlertSeverity, AlertSource } from "../../lib/alertContract";
|
|
4
|
-
import { type AlertListFilters, useAlerts, useAlertSummary } from "../../lib/useAlerts";
|
|
5
|
-
import { cn } from "../../lib/utils";
|
|
6
|
-
import { Badge } from "../ui/badge";
|
|
7
|
-
import { Button } from "../ui/button";
|
|
8
|
-
import { INSPECTOR_ICON_TRIGGER_CLASS } from "../ui/icon-trigger";
|
|
9
|
-
import {
|
|
10
|
-
Dialog,
|
|
11
|
-
DialogContent,
|
|
12
|
-
DialogDescription,
|
|
13
|
-
DialogHeader,
|
|
14
|
-
DialogTitle,
|
|
15
|
-
DialogTrigger,
|
|
16
|
-
} from "../ui/dialog";
|
|
17
|
-
|
|
18
|
-
type SeverityFilter = AlertSeverity | "all";
|
|
19
|
-
type CategoryFilter = AlertCategory | "all";
|
|
20
|
-
|
|
21
|
-
const ALERT_CATEGORIES: AlertCategory[] = [
|
|
22
|
-
"request-failure",
|
|
23
|
-
"request-timeout",
|
|
24
|
-
"slow-response",
|
|
25
|
-
"tool-schema",
|
|
26
|
-
"run-failure",
|
|
27
|
-
"group-failure",
|
|
28
|
-
"group-incomplete",
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
function severityLabel(severity: AlertSeverity): string {
|
|
32
|
-
switch (severity) {
|
|
33
|
-
case "critical":
|
|
34
|
-
return "Critical";
|
|
35
|
-
case "warning":
|
|
36
|
-
return "Warning";
|
|
37
|
-
case "notice":
|
|
38
|
-
return "Notice";
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function sourceLabel(source: AlertSource): string {
|
|
43
|
-
switch (source) {
|
|
44
|
-
case "proxy":
|
|
45
|
-
return "Proxy";
|
|
46
|
-
case "tool-schema":
|
|
47
|
-
return "Tool schema";
|
|
48
|
-
case "run":
|
|
49
|
-
return "Run";
|
|
50
|
-
case "group":
|
|
51
|
-
return "Group";
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function categoryLabel(category: AlertCategory): string {
|
|
56
|
-
switch (category) {
|
|
57
|
-
case "request-failure":
|
|
58
|
-
return "Request failure";
|
|
59
|
-
case "request-timeout":
|
|
60
|
-
return "Timeout";
|
|
61
|
-
case "slow-response":
|
|
62
|
-
return "Slow response";
|
|
63
|
-
case "tool-schema":
|
|
64
|
-
return "Tool calling";
|
|
65
|
-
case "run-failure":
|
|
66
|
-
return "Run failure";
|
|
67
|
-
case "group-failure":
|
|
68
|
-
return "Group failure";
|
|
69
|
-
case "group-incomplete":
|
|
70
|
-
return "Group incomplete";
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function severityAccent(severity: AlertSeverity): string {
|
|
75
|
-
switch (severity) {
|
|
76
|
-
case "critical":
|
|
77
|
-
return "border-status-danger/40 bg-status-danger/10 text-status-danger";
|
|
78
|
-
case "warning":
|
|
79
|
-
return "border-status-watch/40 bg-status-watch/10 text-status-watch";
|
|
80
|
-
case "notice":
|
|
81
|
-
return "border-status-cool/40 bg-status-cool/10 text-status-cool";
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function severityDot(severity: AlertSeverity): string {
|
|
86
|
-
switch (severity) {
|
|
87
|
-
case "critical":
|
|
88
|
-
return "bg-status-danger";
|
|
89
|
-
case "warning":
|
|
90
|
-
return "bg-status-watch";
|
|
91
|
-
case "notice":
|
|
92
|
-
return "bg-status-cool";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function severityText(severity: AlertSeverity): string {
|
|
97
|
-
switch (severity) {
|
|
98
|
-
case "critical":
|
|
99
|
-
return "text-status-danger";
|
|
100
|
-
case "warning":
|
|
101
|
-
return "text-status-watch";
|
|
102
|
-
case "notice":
|
|
103
|
-
return "text-status-cool";
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function categoryIcon(category: AlertCategory): JSX.Element {
|
|
108
|
-
switch (category) {
|
|
109
|
-
case "request-failure":
|
|
110
|
-
case "run-failure":
|
|
111
|
-
case "group-failure":
|
|
112
|
-
return <ShieldAlert className="size-3.5" />;
|
|
113
|
-
case "request-timeout":
|
|
114
|
-
case "slow-response":
|
|
115
|
-
return <Clock3 className="size-3.5" />;
|
|
116
|
-
case "tool-schema":
|
|
117
|
-
return <AlertTriangle className="size-3.5" />;
|
|
118
|
-
case "group-incomplete":
|
|
119
|
-
return <Bell className="size-3.5" />;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
function formatTimestamp(value: string): string {
|
|
124
|
-
const millis = Date.parse(value);
|
|
125
|
-
if (!Number.isFinite(millis)) return value;
|
|
126
|
-
return new Intl.DateTimeFormat(undefined, {
|
|
127
|
-
month: "short",
|
|
128
|
-
day: "2-digit",
|
|
129
|
-
hour: "2-digit",
|
|
130
|
-
minute: "2-digit",
|
|
131
|
-
hour12: false,
|
|
132
|
-
}).format(new Date(millis));
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
function formatCount(value: number): string {
|
|
136
|
-
return value.toLocaleString();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function providerModel(alert: Alert): string {
|
|
140
|
-
if (alert.provider !== null && alert.model !== null) return `${alert.provider} / ${alert.model}`;
|
|
141
|
-
if (alert.provider !== null) return alert.provider;
|
|
142
|
-
if (alert.model !== null) return alert.model;
|
|
143
|
-
return "Unknown target";
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function filtersFrom(severity: SeverityFilter, category: CategoryFilter): AlertListFilters {
|
|
147
|
-
const filters: AlertListFilters = { limit: 100 };
|
|
148
|
-
if (severity !== "all") filters.severity = severity;
|
|
149
|
-
if (category !== "all") filters.category = category;
|
|
150
|
-
return filters;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function selectedAlertFrom(alerts: readonly Alert[], selectedAlertId: string | null): Alert | null {
|
|
154
|
-
if (selectedAlertId !== null) {
|
|
155
|
-
const selected = alerts.find((alert) => alert.id === selectedAlertId);
|
|
156
|
-
if (selected !== undefined) return selected;
|
|
157
|
-
}
|
|
158
|
-
return alerts[0] ?? null;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function AlertSummaryPill({
|
|
162
|
-
label,
|
|
163
|
-
count,
|
|
164
|
-
tone,
|
|
165
|
-
}: {
|
|
166
|
-
label: string;
|
|
167
|
-
count: number;
|
|
168
|
-
tone: "critical" | "warning" | "notice" | "neutral";
|
|
169
|
-
}): JSX.Element {
|
|
170
|
-
const toneClass =
|
|
171
|
-
tone === "critical"
|
|
172
|
-
? "border-status-danger/30 bg-status-danger/10 text-status-danger"
|
|
173
|
-
: tone === "warning"
|
|
174
|
-
? "border-status-watch/30 bg-status-watch/10 text-status-watch"
|
|
175
|
-
: tone === "notice"
|
|
176
|
-
? "border-status-cool/30 bg-status-cool/10 text-status-cool"
|
|
177
|
-
: "border-border bg-muted/40 text-foreground";
|
|
178
|
-
|
|
179
|
-
return (
|
|
180
|
-
<div className={cn("rounded-md border px-3 py-2", toneClass)}>
|
|
181
|
-
<div className="text-[10px] font-semibold uppercase opacity-75">{label}</div>
|
|
182
|
-
<div className="mt-1 text-lg font-semibold leading-none">{formatCount(count)}</div>
|
|
183
|
-
</div>
|
|
184
|
-
);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function SeverityFilterButton({
|
|
188
|
-
value,
|
|
189
|
-
active,
|
|
190
|
-
label,
|
|
191
|
-
count,
|
|
192
|
-
onClick,
|
|
193
|
-
}: {
|
|
194
|
-
value: SeverityFilter;
|
|
195
|
-
active: boolean;
|
|
196
|
-
label: string;
|
|
197
|
-
count: number | null;
|
|
198
|
-
onClick: (value: SeverityFilter) => void;
|
|
199
|
-
}): JSX.Element {
|
|
200
|
-
return (
|
|
201
|
-
<Button
|
|
202
|
-
type="button"
|
|
203
|
-
variant={active ? "secondary" : "ghost"}
|
|
204
|
-
size="sm"
|
|
205
|
-
aria-pressed={active}
|
|
206
|
-
onClick={() => onClick(value)}
|
|
207
|
-
className="h-7 px-2"
|
|
208
|
-
>
|
|
209
|
-
{label}
|
|
210
|
-
{count !== null ? <Badge variant="outline">{formatCount(count)}</Badge> : null}
|
|
211
|
-
</Button>
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function CategoryFilterButton({
|
|
216
|
-
category,
|
|
217
|
-
active,
|
|
218
|
-
count,
|
|
219
|
-
onClick,
|
|
220
|
-
}: {
|
|
221
|
-
category: AlertCategory;
|
|
222
|
-
active: boolean;
|
|
223
|
-
count: number;
|
|
224
|
-
onClick: (category: CategoryFilter) => void;
|
|
225
|
-
}): JSX.Element {
|
|
226
|
-
return (
|
|
227
|
-
<Button
|
|
228
|
-
type="button"
|
|
229
|
-
variant={active ? "secondary" : "ghost"}
|
|
230
|
-
size="sm"
|
|
231
|
-
aria-pressed={active}
|
|
232
|
-
onClick={() => onClick(category)}
|
|
233
|
-
className="h-7 px-2"
|
|
234
|
-
>
|
|
235
|
-
{categoryIcon(category)}
|
|
236
|
-
{categoryLabel(category)}
|
|
237
|
-
<Badge variant="outline">{formatCount(count)}</Badge>
|
|
238
|
-
</Button>
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
function AlertList({
|
|
243
|
-
alerts,
|
|
244
|
-
selectedAlertId,
|
|
245
|
-
isLoading,
|
|
246
|
-
error,
|
|
247
|
-
onSelect,
|
|
248
|
-
}: {
|
|
249
|
-
alerts: Alert[];
|
|
250
|
-
selectedAlertId: string | null;
|
|
251
|
-
isLoading: boolean;
|
|
252
|
-
error: Error | undefined;
|
|
253
|
-
onSelect: (alertId: string) => void;
|
|
254
|
-
}): JSX.Element {
|
|
255
|
-
if (isLoading) {
|
|
256
|
-
return (
|
|
257
|
-
<div className="flex min-h-56 items-center justify-center rounded-md border border-dashed border-border text-xs text-muted-foreground">
|
|
258
|
-
<Loader2 className="mr-2 size-3.5 animate-spin" />
|
|
259
|
-
Loading alerts...
|
|
260
|
-
</div>
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (error !== undefined) {
|
|
265
|
-
return (
|
|
266
|
-
<div className="rounded-md border border-status-danger/30 bg-status-danger/10 px-3 py-2 text-xs text-status-danger">
|
|
267
|
-
{error.message}
|
|
268
|
-
</div>
|
|
269
|
-
);
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (alerts.length === 0) {
|
|
273
|
-
return (
|
|
274
|
-
<div className="flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground">
|
|
275
|
-
No alerts match the current filters.
|
|
276
|
-
</div>
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
return (
|
|
281
|
-
<div className="min-h-0 space-y-2 overflow-y-auto pr-1">
|
|
282
|
-
{alerts.map((alert) => {
|
|
283
|
-
const selected = alert.id === selectedAlertId;
|
|
284
|
-
return (
|
|
285
|
-
<button
|
|
286
|
-
type="button"
|
|
287
|
-
key={alert.id}
|
|
288
|
-
onClick={() => onSelect(alert.id)}
|
|
289
|
-
className={cn(
|
|
290
|
-
"w-full rounded-md border px-3 py-3 text-left transition-colors",
|
|
291
|
-
selected
|
|
292
|
-
? "border-primary/60 bg-primary/12"
|
|
293
|
-
: "border-border bg-background/70 hover:border-primary/30 hover:bg-muted/60",
|
|
294
|
-
)}
|
|
295
|
-
>
|
|
296
|
-
<div className="flex items-start justify-between gap-3">
|
|
297
|
-
<div className="min-w-0">
|
|
298
|
-
<div className="flex min-w-0 items-center gap-2">
|
|
299
|
-
<span className={cn("size-2 rounded-full", severityDot(alert.severity))} />
|
|
300
|
-
<span className={cn("text-xs font-semibold", severityText(alert.severity))}>
|
|
301
|
-
{severityLabel(alert.severity)}
|
|
302
|
-
</span>
|
|
303
|
-
<span className="truncate text-xs text-muted-foreground">
|
|
304
|
-
{categoryLabel(alert.category)}
|
|
305
|
-
</span>
|
|
306
|
-
</div>
|
|
307
|
-
<div className="mt-1 text-sm font-semibold leading-snug">{alert.title}</div>
|
|
308
|
-
<div className="mt-1 line-clamp-2 text-xs text-muted-foreground">
|
|
309
|
-
{alert.message}
|
|
310
|
-
</div>
|
|
311
|
-
</div>
|
|
312
|
-
{alert.count > 1 ? (
|
|
313
|
-
<Badge variant="outline" className="shrink-0">
|
|
314
|
-
x{formatCount(alert.count)}
|
|
315
|
-
</Badge>
|
|
316
|
-
) : null}
|
|
317
|
-
</div>
|
|
318
|
-
<div className="mt-2 flex min-w-0 items-start justify-between gap-2 text-[11px] text-muted-foreground">
|
|
319
|
-
<span className="min-w-0 leading-snug">{providerModel(alert)}</span>
|
|
320
|
-
<span className="shrink-0">{formatTimestamp(alert.lastSeenAt)}</span>
|
|
321
|
-
</div>
|
|
322
|
-
</button>
|
|
323
|
-
);
|
|
324
|
-
})}
|
|
325
|
-
</div>
|
|
326
|
-
);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
function AlertEvidenceLinks({
|
|
330
|
-
alert,
|
|
331
|
-
onNavigate,
|
|
332
|
-
}: {
|
|
333
|
-
alert: Alert;
|
|
334
|
-
onNavigate: () => void;
|
|
335
|
-
}): JSX.Element {
|
|
336
|
-
if (alert.evidence.length === 0) {
|
|
337
|
-
return <span className="text-xs text-muted-foreground">No linked evidence</span>;
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return (
|
|
341
|
-
<div className="flex flex-wrap gap-2">
|
|
342
|
-
{alert.evidence.map((link) => {
|
|
343
|
-
if (link.href === null) {
|
|
344
|
-
return (
|
|
345
|
-
<Badge key={`${link.kind}:${link.id}`} variant="outline">
|
|
346
|
-
{link.label}
|
|
347
|
-
</Badge>
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
return (
|
|
351
|
-
<Badge key={`${link.kind}:${link.id}`} variant="outline" asChild>
|
|
352
|
-
<a href={link.href} onClick={onNavigate}>
|
|
353
|
-
{link.label}
|
|
354
|
-
</a>
|
|
355
|
-
</Badge>
|
|
356
|
-
);
|
|
357
|
-
})}
|
|
358
|
-
</div>
|
|
359
|
-
);
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
function AlertDetails({
|
|
363
|
-
alert,
|
|
364
|
-
onNavigate,
|
|
365
|
-
}: {
|
|
366
|
-
alert: Alert | null;
|
|
367
|
-
onNavigate: () => void;
|
|
368
|
-
}): JSX.Element {
|
|
369
|
-
if (alert === null) {
|
|
370
|
-
return (
|
|
371
|
-
<div className="flex min-h-56 items-center justify-center rounded-md border border-dashed border-border px-4 text-center text-xs text-muted-foreground">
|
|
372
|
-
Select an alert to inspect its evidence.
|
|
373
|
-
</div>
|
|
374
|
-
);
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
return (
|
|
378
|
-
<div className="min-h-0 overflow-y-auto rounded-md border border-border bg-background/70">
|
|
379
|
-
<div className={cn("border-b px-4 py-3", severityAccent(alert.severity))}>
|
|
380
|
-
<div className="flex items-start justify-between gap-3">
|
|
381
|
-
<div className="min-w-0">
|
|
382
|
-
<div className="flex flex-wrap items-center gap-2">
|
|
383
|
-
<Badge variant="outline">{severityLabel(alert.severity)}</Badge>
|
|
384
|
-
<Badge variant="outline">{sourceLabel(alert.source)}</Badge>
|
|
385
|
-
<Badge variant="outline">{categoryLabel(alert.category)}</Badge>
|
|
386
|
-
</div>
|
|
387
|
-
<h3 className="mt-3 text-base font-semibold">{alert.title}</h3>
|
|
388
|
-
<p className="mt-1 text-sm opacity-85">{alert.message}</p>
|
|
389
|
-
</div>
|
|
390
|
-
{alert.count > 1 ? (
|
|
391
|
-
<Badge variant="outline" className="shrink-0">
|
|
392
|
-
{formatCount(alert.count)} hits
|
|
393
|
-
</Badge>
|
|
394
|
-
) : null}
|
|
395
|
-
</div>
|
|
396
|
-
</div>
|
|
397
|
-
|
|
398
|
-
<div className="space-y-4 p-4">
|
|
399
|
-
<div className="grid gap-2 text-xs sm:grid-cols-2">
|
|
400
|
-
<DetailRow label="Target" value={providerModel(alert)} />
|
|
401
|
-
<DetailRow label="Last seen" value={formatTimestamp(alert.lastSeenAt)} />
|
|
402
|
-
<DetailRow label="First seen" value={formatTimestamp(alert.firstSeenAt)} />
|
|
403
|
-
<DetailRow label="Protocol" value={alert.apiFormat ?? "n/a"} />
|
|
404
|
-
</div>
|
|
405
|
-
|
|
406
|
-
<div>
|
|
407
|
-
<div className="mb-2 text-xs font-semibold text-muted-foreground">Evidence</div>
|
|
408
|
-
<AlertEvidenceLinks alert={alert} onNavigate={onNavigate} />
|
|
409
|
-
</div>
|
|
410
|
-
|
|
411
|
-
<div className="grid gap-2 text-xs sm:grid-cols-2">
|
|
412
|
-
<DetailRow
|
|
413
|
-
label="Logs"
|
|
414
|
-
value={alert.logIds.length === 0 ? "n/a" : formatCount(alert.logIds.length)}
|
|
415
|
-
/>
|
|
416
|
-
<DetailRow
|
|
417
|
-
label="Sessions"
|
|
418
|
-
value={alert.sessionIds.length === 0 ? "n/a" : formatCount(alert.sessionIds.length)}
|
|
419
|
-
/>
|
|
420
|
-
<DetailRow
|
|
421
|
-
label="Runs"
|
|
422
|
-
value={alert.runIds.length === 0 ? "n/a" : formatCount(alert.runIds.length)}
|
|
423
|
-
/>
|
|
424
|
-
<DetailRow
|
|
425
|
-
label="Groups"
|
|
426
|
-
value={alert.groupIds.length === 0 ? "n/a" : formatCount(alert.groupIds.length)}
|
|
427
|
-
/>
|
|
428
|
-
</div>
|
|
429
|
-
</div>
|
|
430
|
-
</div>
|
|
431
|
-
);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
function DetailRow({ label, value }: { label: string; value: string }): JSX.Element {
|
|
435
|
-
return (
|
|
436
|
-
<div className="rounded-md border border-border bg-muted/30 px-3 py-2">
|
|
437
|
-
<div className="text-[10px] font-semibold uppercase text-muted-foreground">{label}</div>
|
|
438
|
-
<div className="mt-1 truncate font-mono text-[11px] text-foreground">{value}</div>
|
|
439
|
-
</div>
|
|
440
|
-
);
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
export function AlertsDialog(): JSX.Element {
|
|
444
|
-
const [open, setOpen] = useState(false);
|
|
445
|
-
const [severityFilter, setSeverityFilter] = useState<SeverityFilter>("all");
|
|
446
|
-
const [categoryFilter, setCategoryFilter] = useState<CategoryFilter>("all");
|
|
447
|
-
const [selectedAlertId, setSelectedAlertId] = useState<string | null>(null);
|
|
448
|
-
const { summary, isLoading: summaryLoading } = useAlertSummary();
|
|
449
|
-
const filters = useMemo(
|
|
450
|
-
() => filtersFrom(severityFilter, categoryFilter),
|
|
451
|
-
[categoryFilter, severityFilter],
|
|
452
|
-
);
|
|
453
|
-
const { alerts, total, isLoading, error, mutate } = useAlerts(filters, open);
|
|
454
|
-
const selectedAlert = useMemo(
|
|
455
|
-
() => selectedAlertFrom(alerts, selectedAlertId),
|
|
456
|
-
[alerts, selectedAlertId],
|
|
457
|
-
);
|
|
458
|
-
|
|
459
|
-
useEffect(() => {
|
|
460
|
-
if (!open) return;
|
|
461
|
-
const selectedExists =
|
|
462
|
-
selectedAlertId !== null && alerts.some((alert) => alert.id === selectedAlertId);
|
|
463
|
-
if (selectedExists) return;
|
|
464
|
-
setSelectedAlertId(alerts[0]?.id ?? null);
|
|
465
|
-
}, [alerts, open, selectedAlertId]);
|
|
466
|
-
|
|
467
|
-
const totalCount = summary?.total ?? 0;
|
|
468
|
-
const criticalCount = summary?.critical ?? 0;
|
|
469
|
-
const warningCount = summary?.warning ?? 0;
|
|
470
|
-
const noticeCount = summary?.notice ?? 0;
|
|
471
|
-
const triggerTone =
|
|
472
|
-
criticalCount > 0
|
|
473
|
-
? "bg-status-danger text-primary-foreground"
|
|
474
|
-
: warningCount > 0
|
|
475
|
-
? "bg-status-watch text-primary-foreground"
|
|
476
|
-
: "bg-status-cool text-primary-foreground";
|
|
477
|
-
|
|
478
|
-
return (
|
|
479
|
-
<Dialog open={open} onOpenChange={setOpen}>
|
|
480
|
-
<DialogTrigger asChild>
|
|
481
|
-
<Button
|
|
482
|
-
type="button"
|
|
483
|
-
variant="ghost"
|
|
484
|
-
size="icon"
|
|
485
|
-
className={INSPECTOR_ICON_TRIGGER_CLASS}
|
|
486
|
-
aria-label="Alerts"
|
|
487
|
-
title="Alerts"
|
|
488
|
-
>
|
|
489
|
-
<Siren className="size-4" />
|
|
490
|
-
{summaryLoading ? (
|
|
491
|
-
<Loader2 className="absolute -right-0.5 -top-0.5 size-3 animate-spin text-muted-foreground" />
|
|
492
|
-
) : totalCount > 0 ? (
|
|
493
|
-
<span
|
|
494
|
-
className={cn(
|
|
495
|
-
"absolute -right-1 -top-1 min-w-4 rounded-full px-1 text-[10px] font-semibold leading-4",
|
|
496
|
-
triggerTone,
|
|
497
|
-
)}
|
|
498
|
-
>
|
|
499
|
-
{formatCount(totalCount)}
|
|
500
|
-
</span>
|
|
501
|
-
) : null}
|
|
502
|
-
<span className="sr-only">Alerts</span>
|
|
503
|
-
</Button>
|
|
504
|
-
</DialogTrigger>
|
|
505
|
-
<DialogContent className="flex max-h-[86vh] max-w-6xl flex-col overflow-hidden">
|
|
506
|
-
<DialogHeader>
|
|
507
|
-
<DialogTitle className="flex items-center gap-2 pr-8">
|
|
508
|
-
<Siren className="size-5 text-status-danger" />
|
|
509
|
-
<span>Alerts</span>
|
|
510
|
-
<Badge variant="outline">{formatCount(totalCount)}</Badge>
|
|
511
|
-
</DialogTitle>
|
|
512
|
-
<DialogDescription className="sr-only">
|
|
513
|
-
Local alert board for captured Inspector evidence.
|
|
514
|
-
</DialogDescription>
|
|
515
|
-
</DialogHeader>
|
|
516
|
-
|
|
517
|
-
<div className="grid gap-2 sm:grid-cols-4">
|
|
518
|
-
<AlertSummaryPill label="Open" count={summary?.open ?? 0} tone="neutral" />
|
|
519
|
-
<AlertSummaryPill label="Critical" count={criticalCount} tone="critical" />
|
|
520
|
-
<AlertSummaryPill label="Warning" count={warningCount} tone="warning" />
|
|
521
|
-
<AlertSummaryPill label="Notice" count={noticeCount} tone="notice" />
|
|
522
|
-
</div>
|
|
523
|
-
|
|
524
|
-
<div className="flex min-h-0 flex-wrap items-center justify-between gap-2 border-y border-border py-3">
|
|
525
|
-
<div className="flex flex-wrap gap-1">
|
|
526
|
-
<SeverityFilterButton
|
|
527
|
-
value="all"
|
|
528
|
-
active={severityFilter === "all"}
|
|
529
|
-
label="All"
|
|
530
|
-
count={summary?.total ?? null}
|
|
531
|
-
onClick={setSeverityFilter}
|
|
532
|
-
/>
|
|
533
|
-
<SeverityFilterButton
|
|
534
|
-
value="critical"
|
|
535
|
-
active={severityFilter === "critical"}
|
|
536
|
-
label="Critical"
|
|
537
|
-
count={criticalCount}
|
|
538
|
-
onClick={setSeverityFilter}
|
|
539
|
-
/>
|
|
540
|
-
<SeverityFilterButton
|
|
541
|
-
value="warning"
|
|
542
|
-
active={severityFilter === "warning"}
|
|
543
|
-
label="Warning"
|
|
544
|
-
count={warningCount}
|
|
545
|
-
onClick={setSeverityFilter}
|
|
546
|
-
/>
|
|
547
|
-
<SeverityFilterButton
|
|
548
|
-
value="notice"
|
|
549
|
-
active={severityFilter === "notice"}
|
|
550
|
-
label="Notice"
|
|
551
|
-
count={noticeCount}
|
|
552
|
-
onClick={setSeverityFilter}
|
|
553
|
-
/>
|
|
554
|
-
</div>
|
|
555
|
-
<Button
|
|
556
|
-
type="button"
|
|
557
|
-
variant="outline"
|
|
558
|
-
size="sm"
|
|
559
|
-
className="h-7 shrink-0 px-2"
|
|
560
|
-
onClick={() => void mutate()}
|
|
561
|
-
>
|
|
562
|
-
<RefreshCw className="size-3.5" />
|
|
563
|
-
Refresh
|
|
564
|
-
</Button>
|
|
565
|
-
</div>
|
|
566
|
-
|
|
567
|
-
<div className="flex flex-wrap gap-1">
|
|
568
|
-
<Button
|
|
569
|
-
type="button"
|
|
570
|
-
variant={categoryFilter === "all" ? "secondary" : "ghost"}
|
|
571
|
-
size="sm"
|
|
572
|
-
aria-pressed={categoryFilter === "all"}
|
|
573
|
-
onClick={() => setCategoryFilter("all")}
|
|
574
|
-
className="h-7 px-2"
|
|
575
|
-
>
|
|
576
|
-
All categories
|
|
577
|
-
</Button>
|
|
578
|
-
{ALERT_CATEGORIES.map((category) => {
|
|
579
|
-
const categoryCount =
|
|
580
|
-
summary?.byCategory.find((item) => item.category === category)?.count ?? 0;
|
|
581
|
-
if (categoryCount === 0) return null;
|
|
582
|
-
return (
|
|
583
|
-
<CategoryFilterButton
|
|
584
|
-
key={category}
|
|
585
|
-
category={category}
|
|
586
|
-
active={categoryFilter === category}
|
|
587
|
-
count={categoryCount}
|
|
588
|
-
onClick={setCategoryFilter}
|
|
589
|
-
/>
|
|
590
|
-
);
|
|
591
|
-
})}
|
|
592
|
-
</div>
|
|
593
|
-
|
|
594
|
-
<div className="grid min-h-0 flex-1 gap-4 md:grid-cols-[360px_minmax(0,1fr)]">
|
|
595
|
-
<div className="flex min-h-0 flex-col">
|
|
596
|
-
<div className="mb-2 flex items-center justify-between text-xs text-muted-foreground">
|
|
597
|
-
<span>{formatCount(total)} matched</span>
|
|
598
|
-
<span>
|
|
599
|
-
{alerts.length < total ? `${formatCount(alerts.length)} shown` : "Latest"}
|
|
600
|
-
</span>
|
|
601
|
-
</div>
|
|
602
|
-
<AlertList
|
|
603
|
-
alerts={alerts}
|
|
604
|
-
selectedAlertId={selectedAlert?.id ?? null}
|
|
605
|
-
isLoading={isLoading}
|
|
606
|
-
error={error}
|
|
607
|
-
onSelect={setSelectedAlertId}
|
|
608
|
-
/>
|
|
609
|
-
</div>
|
|
610
|
-
<AlertDetails alert={selectedAlert} onNavigate={() => setOpen(false)} />
|
|
611
|
-
</div>
|
|
612
|
-
</DialogContent>
|
|
613
|
-
</Dialog>
|
|
614
|
-
);
|
|
615
|
-
}
|