@tonyclaw/agent-inspector 4.0.1 → 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 +192 -109
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-CTHqmroT.mjs → router-BBY_zWRK.mjs} +91 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-L3n4J-Or.js → CompareDrawer-rtNElN-B.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D5o_3OZS.js → InspectorPet-QaAiuF3d.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Ocagx75S.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-Bk7x1h-y.js → ReplayDialog-B7KlziO2.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-U4lzL7Sc.js → RequestAnatomy-2XVFBrW4.js} +1 -1
- package/.output/ui/assets/{ResponseView-LOWfvBLK.js → ResponseView-BULgzLVB.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-DPfsrrXQ.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
- package/.output/ui/assets/{_sessionId-OdX2Jvt1.js → _sessionId-D2dmJi3G.js} +1 -1
- package/.output/ui/assets/{_sessionId-0MlWS-CO.js → _sessionId-DcS0s1Mr.js} +1 -1
- package/.output/ui/assets/{index-Du4qNOOt.js → index-B0TN1KKO.js} +2 -2
- package/.output/ui/assets/{index-gvFj_9K6.js → index-Bva1zHEs.js} +1 -1
- package/.output/ui/assets/{index-Ea-c8hPg.js → index-BzBExOxu.js} +1 -1
- package/.output/ui/assets/{index-zVVS53Hd.js → index-k6sRQz55.js} +1 -1
- package/.output/ui/assets/{json-viewer-C1WAMzg3.js → json-viewer-CWM4tY-j.js} +1 -1
- package/.output/ui/assets/{jszip.min-B8AKu2zm.js → jszip.min-BkWvRFlo.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
package/src/lib/uiScale.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
export type UiScalePreference = "auto" | "100" | "125" | "150";
|
|
2
|
-
|
|
3
|
-
export type UiScaleEnvironment = {
|
|
4
|
-
viewportWidth: number;
|
|
5
|
-
screenWidth: number;
|
|
6
|
-
devicePixelRatio: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const UI_SCALE_STORAGE_KEY = "agent-inspector.uiScale";
|
|
10
|
-
export const UI_SCALE_AUTO_MAX_DPR = 1.25;
|
|
11
|
-
export const UI_SCALE_AUTO_MEDIUM_WIDTH = 2200;
|
|
12
|
-
export const UI_SCALE_AUTO_LARGE_WIDTH = 3000;
|
|
13
|
-
export const UI_SCALE_MINIMUM_COMPACT_FONT_SIZE = 12;
|
|
14
|
-
|
|
15
|
-
function positiveFinite(value: number, fallback: number): number {
|
|
16
|
-
return Number.isFinite(value) && value > 0 ? value : fallback;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function normalizeUiScalePreference(value: string | null): UiScalePreference {
|
|
20
|
-
switch (value) {
|
|
21
|
-
case "auto":
|
|
22
|
-
return "auto";
|
|
23
|
-
case "100":
|
|
24
|
-
return "100";
|
|
25
|
-
case "125":
|
|
26
|
-
return "125";
|
|
27
|
-
case "150":
|
|
28
|
-
return "150";
|
|
29
|
-
case null:
|
|
30
|
-
return "auto";
|
|
31
|
-
default:
|
|
32
|
-
return "auto";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function resolveUiScale(
|
|
37
|
-
preference: UiScalePreference,
|
|
38
|
-
environment: UiScaleEnvironment,
|
|
39
|
-
): number {
|
|
40
|
-
switch (preference) {
|
|
41
|
-
case "100":
|
|
42
|
-
return 1;
|
|
43
|
-
case "125":
|
|
44
|
-
return 1.25;
|
|
45
|
-
case "150":
|
|
46
|
-
return 1.5;
|
|
47
|
-
case "auto": {
|
|
48
|
-
const viewportWidth = positiveFinite(environment.viewportWidth, 1280);
|
|
49
|
-
const screenWidth = positiveFinite(environment.screenWidth, viewportWidth);
|
|
50
|
-
const devicePixelRatio = positiveFinite(environment.devicePixelRatio, 1);
|
|
51
|
-
const availableWidth = Math.min(viewportWidth, screenWidth);
|
|
52
|
-
|
|
53
|
-
// High-DPI laptops already receive operating-system scaling. Auto only
|
|
54
|
-
// enlarges spacious low-DPI desktop layouts, where dense telemetry is
|
|
55
|
-
// otherwise physically small.
|
|
56
|
-
if (devicePixelRatio > UI_SCALE_AUTO_MAX_DPR) return 1;
|
|
57
|
-
if (availableWidth >= UI_SCALE_AUTO_LARGE_WIDTH) return 1.25;
|
|
58
|
-
if (availableWidth >= UI_SCALE_AUTO_MEDIUM_WIDTH) return 1.125;
|
|
59
|
-
return 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function formatUiScale(scale: number): string {
|
|
65
|
-
return `${Math.round(scale * 100)}%`;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export function resolveCompactFontSize(baseSize: number, scale: number): number {
|
|
69
|
-
return Math.max(UI_SCALE_MINIMUM_COMPACT_FONT_SIZE, baseSize * scale);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function readUiScaleEnvironment(): UiScaleEnvironment {
|
|
73
|
-
if (typeof window === "undefined") {
|
|
74
|
-
return { viewportWidth: 1280, screenWidth: 1280, devicePixelRatio: 1 };
|
|
75
|
-
}
|
|
76
|
-
const screenWidth =
|
|
77
|
-
typeof window.screen === "undefined" ? window.innerWidth : window.screen.availWidth;
|
|
78
|
-
return {
|
|
79
|
-
viewportWidth: window.innerWidth,
|
|
80
|
-
screenWidth,
|
|
81
|
-
devicePixelRatio: window.devicePixelRatio,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
export function applyUiScalePreference(preference: UiScalePreference): number {
|
|
86
|
-
const scale = resolveUiScale(preference, readUiScaleEnvironment());
|
|
87
|
-
if (typeof document === "undefined") return scale;
|
|
88
|
-
|
|
89
|
-
const root = document.documentElement;
|
|
90
|
-
root.dataset.uiScale = preference;
|
|
91
|
-
root.dataset.uiScaleResolved = String(Math.round(scale * 100));
|
|
92
|
-
root.style.setProperty("--inspector-ui-scale", String(scale));
|
|
93
|
-
root.style.setProperty("--inspector-root-font-size", `${String(16 * scale)}px`);
|
|
94
|
-
root.style.setProperty("--inspector-font-9", `${String(resolveCompactFontSize(9, scale))}px`);
|
|
95
|
-
root.style.setProperty("--inspector-font-10", `${String(resolveCompactFontSize(10, scale))}px`);
|
|
96
|
-
root.style.setProperty("--inspector-font-11", `${String(resolveCompactFontSize(11, scale))}px`);
|
|
97
|
-
root.style.setProperty("--inspector-font-13", `${String(13 * scale)}px`);
|
|
98
|
-
return scale;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export function readStoredUiScalePreference(): UiScalePreference {
|
|
102
|
-
if (typeof window === "undefined") return "auto";
|
|
103
|
-
try {
|
|
104
|
-
return normalizeUiScalePreference(window.localStorage.getItem(UI_SCALE_STORAGE_KEY));
|
|
105
|
-
} catch {
|
|
106
|
-
return "auto";
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function persistUiScalePreference(preference: UiScalePreference): void {
|
|
111
|
-
if (typeof window === "undefined") return;
|
|
112
|
-
try {
|
|
113
|
-
window.localStorage.setItem(UI_SCALE_STORAGE_KEY, preference);
|
|
114
|
-
} catch {
|
|
115
|
-
// Local storage can be unavailable in hardened browser contexts.
|
|
116
|
-
}
|
|
117
|
-
}
|
package/src/lib/unknown.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared helpers for traversing values of type `unknown` without resorting to
|
|
3
|
-
* type assertions. The project's ESLint rules forbid `as` casts and non-null
|
|
4
|
-
* assertions, so every safe property read goes through these helpers.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/** True if `value` is a non-array, non-null object. */
|
|
8
|
-
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
9
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Safely read an own property of `value`, returning `undefined` for any
|
|
14
|
-
* non-object input (including arrays, null, primitives). Uses
|
|
15
|
-
* `getOwnPropertyDescriptor` so that `__proto__` keys cannot be reached.
|
|
16
|
-
*/
|
|
17
|
-
export function readProperty(value: unknown, name: string): unknown {
|
|
18
|
-
if (!isRecord(value)) return undefined;
|
|
19
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, name);
|
|
20
|
-
return descriptor === undefined ? undefined : descriptor.value;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/** Byte length of a UTF-8 string, or `null` if the string is null. */
|
|
24
|
-
export function textByteLength(value: string | null): number | null {
|
|
25
|
-
if (value === null) return null;
|
|
26
|
-
return new TextEncoder().encode(value).byteLength;
|
|
27
|
-
}
|
package/src/lib/upstreamUrl.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
export const PATH_V1_CHAT_COMPLETIONS = "/v1/chat/completions";
|
|
2
|
-
export const PATH_V1_RESPONSES = "/v1/responses";
|
|
3
|
-
export const PATH_V1_MESSAGES = "/v1/messages";
|
|
4
|
-
|
|
5
|
-
export type UpstreamUrlDiagnostic = {
|
|
6
|
-
severity: "info" | "warning";
|
|
7
|
-
message: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export type UpstreamUrlPreviewOptions = {
|
|
11
|
-
providerName?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type UpstreamUrlPreview = {
|
|
15
|
-
finalUrl: string;
|
|
16
|
-
diagnostics: UpstreamUrlDiagnostic[];
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function buildUpstreamUrl(upstreamBase: string, normalizedPath: string): string {
|
|
20
|
-
const base = upstreamBase.endsWith("/") ? upstreamBase.slice(0, -1) : upstreamBase;
|
|
21
|
-
const endpointPath = endpointPathFor(normalizedPath);
|
|
22
|
-
const queryIndex = normalizedPath.indexOf("?");
|
|
23
|
-
const search = queryIndex >= 0 ? normalizedPath.slice(queryIndex) : "";
|
|
24
|
-
|
|
25
|
-
// Some providers expose a format-specific URL as the exact endpoint rather
|
|
26
|
-
// than a base URL. Keep existing configs with exact endpoints compatible.
|
|
27
|
-
if (endpointPath !== "" && base.endsWith(endpointPath)) {
|
|
28
|
-
return base + search;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (isZhipuVersionedOpenAIBase(base) && isVersionedChatCompletionsPath(normalizedPath)) {
|
|
32
|
-
return base + normalizedPath.slice(3);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Many OpenAI-compatible base URLs already include /v1. Avoid producing /v1/v1.
|
|
36
|
-
if (base.endsWith("/v1") && normalizedPath.startsWith("/v1/")) {
|
|
37
|
-
return base + normalizedPath.slice(3);
|
|
38
|
-
}
|
|
39
|
-
return base + normalizedPath;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function previewUpstreamUrl(
|
|
43
|
-
upstreamBase: string,
|
|
44
|
-
normalizedPath: string,
|
|
45
|
-
options: UpstreamUrlPreviewOptions = {},
|
|
46
|
-
): UpstreamUrlPreview {
|
|
47
|
-
const base = upstreamBase.trim().replace(/\/+$/, "");
|
|
48
|
-
const endpointPath = endpointPathFor(normalizedPath);
|
|
49
|
-
const finalUrl = buildUpstreamUrl(base, normalizedPath);
|
|
50
|
-
const diagnostics: UpstreamUrlDiagnostic[] = [];
|
|
51
|
-
const exactEndpoint = endpointPath !== "" && base.endsWith(endpointPath);
|
|
52
|
-
|
|
53
|
-
if (exactEndpoint) {
|
|
54
|
-
diagnostics.push({
|
|
55
|
-
severity: "info",
|
|
56
|
-
message: "This already includes the exact endpoint; no duplicate suffix will be appended.",
|
|
57
|
-
});
|
|
58
|
-
} else if (isZhipuVersionedOpenAIBase(base) && isVersionedChatCompletionsPath(normalizedPath)) {
|
|
59
|
-
diagnostics.push({
|
|
60
|
-
severity: "info",
|
|
61
|
-
message: "Zhipu bases already include the API version; only /chat/completions is appended.",
|
|
62
|
-
});
|
|
63
|
-
} else if (base.endsWith("/v1") && normalizedPath.startsWith("/v1/")) {
|
|
64
|
-
diagnostics.push({
|
|
65
|
-
severity: "info",
|
|
66
|
-
message: "Base URL already ends with /v1; the suffix will not repeat /v1.",
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (isResponsesPath(endpointPath) && baseEndsWithChatEndpoint(base)) {
|
|
71
|
-
diagnostics.push({
|
|
72
|
-
severity: "warning",
|
|
73
|
-
message: "This looks like a Chat Completions endpoint, so Responses would append after it.",
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if (isChatCompletionsPath(endpointPath) && baseEndsWithResponsesEndpoint(base)) {
|
|
78
|
-
diagnostics.push({
|
|
79
|
-
severity: "warning",
|
|
80
|
-
message: "This looks like a Responses endpoint, so Chat Completions would append after it.",
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (isResponsesPath(endpointPath) && isLikelyDeepSeekBase(base, options.providerName)) {
|
|
85
|
-
diagnostics.push({
|
|
86
|
-
severity: "warning",
|
|
87
|
-
message: "DeepSeek's official API does not currently expose OpenAI Responses.",
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return { finalUrl, diagnostics };
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function endpointPathFor(normalizedPath: string): string {
|
|
95
|
-
return normalizedPath.split("?")[0] ?? normalizedPath;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function isVersionedChatCompletionsPath(normalizedPath: string): boolean {
|
|
99
|
-
return (
|
|
100
|
-
normalizedPath === PATH_V1_CHAT_COMPLETIONS ||
|
|
101
|
-
normalizedPath.startsWith(`${PATH_V1_CHAT_COMPLETIONS}?`) ||
|
|
102
|
-
normalizedPath.startsWith(`${PATH_V1_CHAT_COMPLETIONS}/`)
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function isChatCompletionsPath(endpointPath: string): boolean {
|
|
107
|
-
return (
|
|
108
|
-
endpointPath === PATH_V1_CHAT_COMPLETIONS ||
|
|
109
|
-
endpointPath.startsWith(`${PATH_V1_CHAT_COMPLETIONS}/`)
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
function isResponsesPath(endpointPath: string): boolean {
|
|
114
|
-
return endpointPath === PATH_V1_RESPONSES || endpointPath.startsWith(`${PATH_V1_RESPONSES}/`);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function baseEndsWithChatEndpoint(base: string): boolean {
|
|
118
|
-
const normalized = base.toLowerCase();
|
|
119
|
-
return normalized.endsWith("/chat/completions");
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function baseEndsWithResponsesEndpoint(base: string): boolean {
|
|
123
|
-
const normalized = base.toLowerCase();
|
|
124
|
-
return normalized.endsWith("/responses");
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function isLikelyDeepSeekBase(base: string, providerName: string | undefined): boolean {
|
|
128
|
-
const provider = providerName?.toLowerCase();
|
|
129
|
-
if (provider !== undefined && provider.includes("deepseek")) return true;
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
const parsed = new URL(base);
|
|
133
|
-
return parsed.hostname.toLowerCase().includes("deepseek");
|
|
134
|
-
} catch {
|
|
135
|
-
return base.toLowerCase().includes("deepseek");
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function isZhipuVersionedOpenAIBase(base: string): boolean {
|
|
140
|
-
try {
|
|
141
|
-
const parsed = new URL(base);
|
|
142
|
-
const path = parsed.pathname.replace(/\/+$/, "");
|
|
143
|
-
return (
|
|
144
|
-
parsed.hostname === "open.bigmodel.cn" &&
|
|
145
|
-
(path === "/api/paas/v4" || path === "/api/coding/paas/v4")
|
|
146
|
-
);
|
|
147
|
-
} catch {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
}
|
package/src/lib/useAlerts.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
|
-
import {
|
|
3
|
-
AlertListResponseSchema,
|
|
4
|
-
AlertSummarySchema,
|
|
5
|
-
type AlertCategory,
|
|
6
|
-
type AlertListResponse,
|
|
7
|
-
type AlertSeverity,
|
|
8
|
-
type AlertSource,
|
|
9
|
-
type AlertSummary,
|
|
10
|
-
} from "./alertContract";
|
|
11
|
-
import { fetchJsonWithTimeout } from "./apiClient";
|
|
12
|
-
|
|
13
|
-
const ALERT_SUMMARY_FETCH_TIMEOUT_MS = 8_000;
|
|
14
|
-
const ALERT_LIST_FETCH_TIMEOUT_MS = 10_000;
|
|
15
|
-
|
|
16
|
-
export type AlertListFilters = {
|
|
17
|
-
severity?: AlertSeverity;
|
|
18
|
-
category?: AlertCategory;
|
|
19
|
-
source?: AlertSource;
|
|
20
|
-
limit?: number;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
type UseAlertsResult = {
|
|
24
|
-
alerts: AlertListResponse["alerts"];
|
|
25
|
-
total: number;
|
|
26
|
-
summary: AlertSummary | null;
|
|
27
|
-
isLoading: boolean;
|
|
28
|
-
error: Error | undefined;
|
|
29
|
-
mutate: SWRResponse<AlertListResponse, Error>["mutate"];
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
type UseAlertSummaryResult = {
|
|
33
|
-
summary: AlertSummary | null;
|
|
34
|
-
isLoading: boolean;
|
|
35
|
-
error: Error | undefined;
|
|
36
|
-
mutate: SWRResponse<AlertSummary, Error>["mutate"];
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function alertsPath(filters: AlertListFilters): string {
|
|
40
|
-
const params = new URLSearchParams();
|
|
41
|
-
if (filters.severity !== undefined) params.set("severity", filters.severity);
|
|
42
|
-
if (filters.category !== undefined) params.set("category", filters.category);
|
|
43
|
-
if (filters.source !== undefined) params.set("source", filters.source);
|
|
44
|
-
if (filters.limit !== undefined) params.set("limit", String(filters.limit));
|
|
45
|
-
const query = params.toString();
|
|
46
|
-
return query.length > 0 ? `/api/alerts?${query}` : "/api/alerts";
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export function useAlerts(filters: AlertListFilters, enabled: boolean): UseAlertsResult {
|
|
50
|
-
const response: SWRResponse<AlertListResponse, Error> = useSWR<AlertListResponse, Error>(
|
|
51
|
-
enabled ? alertsPath(filters) : null,
|
|
52
|
-
(url: string) =>
|
|
53
|
-
fetchJsonWithTimeout(url, AlertListResponseSchema, ALERT_LIST_FETCH_TIMEOUT_MS),
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
alerts: response.data?.alerts ?? [],
|
|
58
|
-
total: response.data?.total ?? 0,
|
|
59
|
-
summary: response.data?.summary ?? null,
|
|
60
|
-
isLoading: response.isLoading,
|
|
61
|
-
error: response.error,
|
|
62
|
-
mutate: response.mutate,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function useAlertSummary(): UseAlertSummaryResult {
|
|
67
|
-
const response: SWRResponse<AlertSummary, Error> = useSWR<AlertSummary, Error>(
|
|
68
|
-
"/api/alerts/summary",
|
|
69
|
-
(url: string) => fetchJsonWithTimeout(url, AlertSummarySchema, ALERT_SUMMARY_FETCH_TIMEOUT_MS),
|
|
70
|
-
{
|
|
71
|
-
refreshInterval: 5_000,
|
|
72
|
-
revalidateOnFocus: true,
|
|
73
|
-
},
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return {
|
|
77
|
-
summary: response.data ?? null,
|
|
78
|
-
isLoading: response.isLoading,
|
|
79
|
-
error: response.error,
|
|
80
|
-
mutate: response.mutate,
|
|
81
|
-
};
|
|
82
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
|
-
import {
|
|
3
|
-
GroupEvidenceReadResponseSchema,
|
|
4
|
-
type GroupEvidenceReadResponse,
|
|
5
|
-
type InspectorGroup,
|
|
6
|
-
} from "./groupContract";
|
|
7
|
-
import { fetchJsonWithTimeout } from "./apiClient";
|
|
8
|
-
|
|
9
|
-
const GROUP_EVIDENCE_FETCH_TIMEOUT_MS = 12_000;
|
|
10
|
-
|
|
11
|
-
type UseGroupEvidenceResult = {
|
|
12
|
-
evidenceResponse: GroupEvidenceReadResponse | null;
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
error: Error | undefined;
|
|
15
|
-
mutate: SWRResponse<GroupEvidenceReadResponse, Error>["mutate"];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
function evidenceKey(group: InspectorGroup | null): string | null {
|
|
19
|
-
if (group === null || group.evidence === null) return null;
|
|
20
|
-
return `/api/groups/${encodeURIComponent(group.id)}/evidence`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function useGroupEvidence(group: InspectorGroup | null): UseGroupEvidenceResult {
|
|
24
|
-
const response: SWRResponse<GroupEvidenceReadResponse, Error> = useSWR<
|
|
25
|
-
GroupEvidenceReadResponse,
|
|
26
|
-
Error
|
|
27
|
-
>(evidenceKey(group), (url: string) =>
|
|
28
|
-
fetchJsonWithTimeout(url, GroupEvidenceReadResponseSchema, GROUP_EVIDENCE_FETCH_TIMEOUT_MS),
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
evidenceResponse: response.data ?? null,
|
|
33
|
-
isLoading: response.isLoading,
|
|
34
|
-
error: response.error,
|
|
35
|
-
mutate: response.mutate,
|
|
36
|
-
};
|
|
37
|
-
}
|
package/src/lib/useGroups.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
|
-
import {
|
|
3
|
-
InspectorGroupsListResponseSchema,
|
|
4
|
-
type InspectorGroup,
|
|
5
|
-
type InspectorGroupsListResponse,
|
|
6
|
-
} from "./groupContract";
|
|
7
|
-
import { fetchJsonWithTimeout } from "./apiClient";
|
|
8
|
-
|
|
9
|
-
const GROUPS_FETCH_TIMEOUT_MS = 8_000;
|
|
10
|
-
|
|
11
|
-
type UseGroupsResult = {
|
|
12
|
-
groups: InspectorGroup[];
|
|
13
|
-
isLoading: boolean;
|
|
14
|
-
error: Error | undefined;
|
|
15
|
-
mutate: SWRResponse<InspectorGroupsListResponse, Error>["mutate"];
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function useGroups(): UseGroupsResult {
|
|
19
|
-
const response: SWRResponse<InspectorGroupsListResponse, Error> = useSWR<
|
|
20
|
-
InspectorGroupsListResponse,
|
|
21
|
-
Error
|
|
22
|
-
>("/api/groups", (url: string) =>
|
|
23
|
-
fetchJsonWithTimeout(url, InspectorGroupsListResponseSchema, GROUPS_FETCH_TIMEOUT_MS),
|
|
24
|
-
);
|
|
25
|
-
|
|
26
|
-
return {
|
|
27
|
-
groups: response.data?.groups ?? [],
|
|
28
|
-
isLoading: response.isLoading,
|
|
29
|
-
error: response.error,
|
|
30
|
-
mutate: response.mutate,
|
|
31
|
-
};
|
|
32
|
-
}
|
package/src/lib/useOnboarding.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse, useSWRConfig } from "swr";
|
|
2
|
-
import { fetchJson } from "./apiClient";
|
|
3
|
-
import {
|
|
4
|
-
DEFAULT_CAPTURE_MODE,
|
|
5
|
-
DEFAULT_PROVIDER_TEST_TIMEOUT_SECONDS,
|
|
6
|
-
DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS,
|
|
7
|
-
DEFAULT_TIME_DISPLAY_FORMAT,
|
|
8
|
-
RuntimeConfigSchema,
|
|
9
|
-
type CaptureMode,
|
|
10
|
-
type RuntimeConfig,
|
|
11
|
-
} from "./runtimeConfig";
|
|
12
|
-
|
|
13
|
-
export const ONBOARDING_SWR_KEY = "/api/config";
|
|
14
|
-
|
|
15
|
-
type RuntimeConfigPatch = Partial<Omit<RuntimeConfig, "captureMode">>;
|
|
16
|
-
|
|
17
|
-
async function fetcher(url: string): Promise<RuntimeConfig> {
|
|
18
|
-
return fetchJson(
|
|
19
|
-
url,
|
|
20
|
-
RuntimeConfigSchema,
|
|
21
|
-
undefined,
|
|
22
|
-
(response) => `Failed to fetch ${url}: ${response.status}`,
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
async function patchRuntimeConfig(patch: RuntimeConfigPatch): Promise<RuntimeConfig> {
|
|
27
|
-
return fetchJson(
|
|
28
|
-
ONBOARDING_SWR_KEY,
|
|
29
|
-
RuntimeConfigSchema,
|
|
30
|
-
{
|
|
31
|
-
method: "PATCH",
|
|
32
|
-
headers: { "content-type": "application/json" },
|
|
33
|
-
body: JSON.stringify(patch),
|
|
34
|
-
},
|
|
35
|
-
(response) => `PATCH failed with status ${response.status}`,
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type UseOnboarding = {
|
|
40
|
-
hasSeenOnboarding: boolean;
|
|
41
|
-
captureMode: CaptureMode;
|
|
42
|
-
isLoading: boolean;
|
|
43
|
-
markSeen: () => Promise<void>;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Hook for the first-launch onboarding banner. The server's
|
|
48
|
-
* `hasSeenOnboarding` flag is the source of truth — set to `true` on
|
|
49
|
-
* dismissal and persisted in the server config file so it survives
|
|
50
|
-
* across browser sessions.
|
|
51
|
-
*
|
|
52
|
-
* `hasSeenOnboarding` defaults to `false` until the SWR fetch resolves,
|
|
53
|
-
* which means the banner shows briefly on first load. That is
|
|
54
|
-
* acceptable: the fetch is local and resolves within milliseconds.
|
|
55
|
-
*/
|
|
56
|
-
export function useOnboarding(): UseOnboarding {
|
|
57
|
-
const response: SWRResponse<RuntimeConfig, Error> = useSWR<RuntimeConfig, Error>(
|
|
58
|
-
ONBOARDING_SWR_KEY,
|
|
59
|
-
fetcher,
|
|
60
|
-
{
|
|
61
|
-
revalidateOnFocus: false,
|
|
62
|
-
revalidateIfStale: false,
|
|
63
|
-
},
|
|
64
|
-
);
|
|
65
|
-
const { mutate: globalMutate } = useSWRConfig();
|
|
66
|
-
|
|
67
|
-
const hasSeenOnboarding = response.data?.hasSeenOnboarding ?? false;
|
|
68
|
-
const captureMode = response.data?.captureMode ?? DEFAULT_CAPTURE_MODE;
|
|
69
|
-
|
|
70
|
-
const markSeen = async (): Promise<void> => {
|
|
71
|
-
await globalMutate(ONBOARDING_SWR_KEY, patchRuntimeConfig({ hasSeenOnboarding: true }), {
|
|
72
|
-
optimisticData: {
|
|
73
|
-
stripClaudeCodeBillingHeader: response.data?.stripClaudeCodeBillingHeader ?? false,
|
|
74
|
-
hasSeenOnboarding: true,
|
|
75
|
-
slowResponseThresholdSeconds:
|
|
76
|
-
response.data?.slowResponseThresholdSeconds ?? DEFAULT_SLOW_RESPONSE_THRESHOLD_SECONDS,
|
|
77
|
-
providerTestTimeoutSeconds:
|
|
78
|
-
response.data?.providerTestTimeoutSeconds ?? DEFAULT_PROVIDER_TEST_TIMEOUT_SECONDS,
|
|
79
|
-
timeDisplayFormat: response.data?.timeDisplayFormat ?? DEFAULT_TIME_DISPLAY_FORMAT,
|
|
80
|
-
captureMode,
|
|
81
|
-
},
|
|
82
|
-
rollbackOnError: true,
|
|
83
|
-
revalidate: false,
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return {
|
|
88
|
-
hasSeenOnboarding,
|
|
89
|
-
captureMode,
|
|
90
|
-
isLoading: response.isLoading,
|
|
91
|
-
markSeen,
|
|
92
|
-
};
|
|
93
|
-
}
|
package/src/lib/useProviders.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import useSWR, { type SWRResponse } from "swr";
|
|
2
|
-
import { fetchJson } from "./apiClient";
|
|
3
|
-
import { RedactedProviderDtoSchema, type RedactedProviderDto } from "./providerContract";
|
|
4
|
-
|
|
5
|
-
async function fetcher(url: string): Promise<RedactedProviderDto[]> {
|
|
6
|
-
return fetchJson(
|
|
7
|
-
url,
|
|
8
|
-
RedactedProviderDtoSchema.array(),
|
|
9
|
-
undefined,
|
|
10
|
-
(response) => `Failed to fetch ${url}: ${response.status}`,
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function useProviders() {
|
|
15
|
-
const response: SWRResponse<RedactedProviderDto[], Error> = useSWR<RedactedProviderDto[], Error>(
|
|
16
|
-
"/api/providers",
|
|
17
|
-
fetcher,
|
|
18
|
-
{
|
|
19
|
-
revalidateOnFocus: false,
|
|
20
|
-
revalidateIfStale: false,
|
|
21
|
-
},
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
providers: response.data ?? [],
|
|
26
|
-
isLoading: response.isLoading,
|
|
27
|
-
isError: response.error,
|
|
28
|
-
mutate: response.mutate,
|
|
29
|
-
};
|
|
30
|
-
}
|