@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,488 +0,0 @@
|
|
|
1
|
-
import type { CapturedLog } from "../../contracts";
|
|
2
|
-
import type { ExportMode } from "../../lib/export-logs";
|
|
3
|
-
import type { CaptureMode, TimeDisplayFormat } from "../../lib/runtimeConfig";
|
|
4
|
-
import { extractStopReason, type StopReason } from "../../lib/stopReason";
|
|
5
|
-
import { formatTimestampRange } from "../../lib/timeDisplay";
|
|
6
|
-
import { formatTokens } from "../../lib/utils";
|
|
7
|
-
import { buildTurnGroups } from "./viewerState";
|
|
8
|
-
|
|
9
|
-
export type ExportActionVisibility = {
|
|
10
|
-
redacted: boolean;
|
|
11
|
-
raw: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export type SessionContextScope = {
|
|
15
|
-
label: string;
|
|
16
|
-
logs: CapturedLog[];
|
|
17
|
-
showBackLink: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type SessionSlateStatus = "rolling" | "clear" | "watch" | "failed";
|
|
21
|
-
export type SessionSlateMetricTone = "neutral" | "cool" | "watch" | "danger";
|
|
22
|
-
|
|
23
|
-
export type ConversationLogs = {
|
|
24
|
-
logs: CapturedLog[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type HomeConnectionEndpoints = {
|
|
28
|
-
proxy: string;
|
|
29
|
-
mcp: string;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export const COPYABLE_COMMAND_CONTAINER_CLASS_NAME =
|
|
33
|
-
"flex w-full min-w-0 items-center gap-2 rounded-md border border-border/70 bg-muted/35 px-3 py-2 sm:w-auto sm:max-w-full";
|
|
34
|
-
export const COPYABLE_COMMAND_TEXT_CLASS_NAME =
|
|
35
|
-
"m-0 min-w-0 flex-1 overflow-x-auto font-mono text-xs text-foreground sm:text-sm";
|
|
36
|
-
|
|
37
|
-
export function buildHomeConnectionCommands(endpoints: HomeConnectionEndpoints): readonly string[] {
|
|
38
|
-
return [`PROXY_BASE_URL=${endpoints.proxy}`, `MCP_URL=${endpoints.mcp}`];
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export type SessionSlateStats = {
|
|
42
|
-
status: SessionSlateStatus;
|
|
43
|
-
statusLabel: string;
|
|
44
|
-
modelLabel: string;
|
|
45
|
-
providerLabel: string;
|
|
46
|
-
requests: number;
|
|
47
|
-
turns: number;
|
|
48
|
-
failures: number;
|
|
49
|
-
pending: number;
|
|
50
|
-
slow: number;
|
|
51
|
-
lengthStops: number;
|
|
52
|
-
timeRange: string | null;
|
|
53
|
-
tokenLabel: string;
|
|
54
|
-
finishLabel: string;
|
|
55
|
-
finishDetail: string;
|
|
56
|
-
finishTone: SessionSlateMetricTone;
|
|
57
|
-
outcomeLabel: string;
|
|
58
|
-
outcomeDetail: string;
|
|
59
|
-
outcomeTone: SessionSlateMetricTone;
|
|
60
|
-
slowestLabel: string;
|
|
61
|
-
slowestDetail: string;
|
|
62
|
-
heaviestDetail: string;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
type PaginationStatusControls = {
|
|
66
|
-
isLoading: boolean;
|
|
67
|
-
total: number | null;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
type FinishSummary = {
|
|
71
|
-
label: string;
|
|
72
|
-
detail: string;
|
|
73
|
-
tone: SessionSlateMetricTone;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
type SessionOutcomeSummary = {
|
|
77
|
-
label: string;
|
|
78
|
-
detail: string;
|
|
79
|
-
tone: SessionSlateMetricTone;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
type FailureSummary = {
|
|
83
|
-
logNumber: number;
|
|
84
|
-
status: number | null;
|
|
85
|
-
error: string | null;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export function shouldShowRawExport(captureMode: CaptureMode): boolean {
|
|
89
|
-
return captureMode === "full";
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function exportRequiresConfirmation(mode: ExportMode): boolean {
|
|
93
|
-
return mode === "raw";
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export function getExportActionVisibility(
|
|
97
|
-
captureMode: CaptureMode,
|
|
98
|
-
logCount: number,
|
|
99
|
-
): ExportActionVisibility {
|
|
100
|
-
const hasLogs = logCount > 0;
|
|
101
|
-
return {
|
|
102
|
-
redacted: hasLogs,
|
|
103
|
-
raw: hasLogs && shouldShowRawExport(captureMode),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function formatTimeRange(logs: CapturedLog[], timeDisplayFormat: TimeDisplayFormat): string | null {
|
|
108
|
-
const first = logs[0];
|
|
109
|
-
const last = logs[logs.length - 1];
|
|
110
|
-
if (first === undefined || last === undefined) return null;
|
|
111
|
-
return formatTimestampRange(first.timestamp, last.timestamp, timeDisplayFormat);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function hasLogFailure(log: CapturedLog): boolean {
|
|
115
|
-
if (log.error !== null && log.error !== undefined && log.error.length > 0) return true;
|
|
116
|
-
return log.responseStatus !== null && log.responseStatus >= 400;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function getModelLabel(logs: readonly CapturedLog[]): string {
|
|
120
|
-
const models = new Set<string>();
|
|
121
|
-
for (const log of logs) {
|
|
122
|
-
if (log.model !== null && log.model.length > 0) {
|
|
123
|
-
models.add(log.model);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
const sorted = [...models].sort();
|
|
127
|
-
if (sorted.length === 0) return "Model unknown";
|
|
128
|
-
if (sorted.length === 1) return sorted[0] ?? "Model unknown";
|
|
129
|
-
return `${sorted.length} models`;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function getProviderLabel(logs: readonly CapturedLog[]): string {
|
|
133
|
-
const providers = new Set<string>();
|
|
134
|
-
for (const log of logs) {
|
|
135
|
-
if (
|
|
136
|
-
log.providerName !== null &&
|
|
137
|
-
log.providerName !== undefined &&
|
|
138
|
-
log.providerName.length > 0
|
|
139
|
-
) {
|
|
140
|
-
providers.add(log.providerName);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
const sorted = [...providers].sort();
|
|
144
|
-
if (sorted.length === 0) return "Provider unknown";
|
|
145
|
-
if (sorted.length === 1) return sorted[0] ?? "Provider unknown";
|
|
146
|
-
return `${sorted.length} providers`;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
function formatElapsedMs(ms: number): string {
|
|
150
|
-
if (ms < 1000) return `${ms}ms`;
|
|
151
|
-
if (ms < 60_000) {
|
|
152
|
-
const seconds = ms / 1000;
|
|
153
|
-
return `${seconds < 10 ? seconds.toFixed(1) : seconds.toFixed(0)}s`;
|
|
154
|
-
}
|
|
155
|
-
const totalSeconds = Math.round(ms / 1000);
|
|
156
|
-
const minutes = Math.floor(totalSeconds / 60);
|
|
157
|
-
const seconds = totalSeconds % 60;
|
|
158
|
-
return `${minutes}m ${seconds}s`;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function formatTokenPair(inputTokens: number, outputTokens: number): string {
|
|
162
|
-
return `${formatTokens(inputTokens)} in / ${formatTokens(outputTokens)} out`;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
function countSessionTurns(
|
|
166
|
-
logs: CapturedLog[],
|
|
167
|
-
conversationGroups: readonly ConversationLogs[],
|
|
168
|
-
): number {
|
|
169
|
-
if (logs.length === 0) return 0;
|
|
170
|
-
if (conversationGroups.length === 0) return buildTurnGroups(logs).length;
|
|
171
|
-
|
|
172
|
-
let turns = 0;
|
|
173
|
-
for (const group of conversationGroups) {
|
|
174
|
-
turns += buildTurnGroups(group.logs).length;
|
|
175
|
-
}
|
|
176
|
-
return turns;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function summarizeFinishReason({
|
|
180
|
-
stopReason,
|
|
181
|
-
pending,
|
|
182
|
-
lastFailureLogNumber,
|
|
183
|
-
}: {
|
|
184
|
-
stopReason: StopReason;
|
|
185
|
-
pending: number;
|
|
186
|
-
lastFailureLogNumber: number | null;
|
|
187
|
-
}): FinishSummary {
|
|
188
|
-
if (pending > 0) {
|
|
189
|
-
return {
|
|
190
|
-
label: "In flight",
|
|
191
|
-
detail: `${pending} request${pending === 1 ? "" : "s"} pending`,
|
|
192
|
-
tone: "cool",
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
if (lastFailureLogNumber !== null && stopReason === null) {
|
|
197
|
-
return {
|
|
198
|
-
label: "Error",
|
|
199
|
-
detail: `Last failed request #${lastFailureLogNumber}`,
|
|
200
|
-
tone: "danger",
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
switch (stopReason) {
|
|
205
|
-
case "end_turn":
|
|
206
|
-
return { label: "End turn", detail: "Assistant completed the turn", tone: "neutral" };
|
|
207
|
-
case "stop":
|
|
208
|
-
return { label: "Stop", detail: "Model reached a stop condition", tone: "neutral" };
|
|
209
|
-
case "length":
|
|
210
|
-
return { label: "Output limit", detail: "Turn ended at max output tokens", tone: "watch" };
|
|
211
|
-
case "tool_use":
|
|
212
|
-
return { label: "Tool call", detail: "Assistant requested a tool", tone: "cool" };
|
|
213
|
-
case null:
|
|
214
|
-
return { label: "Unknown", detail: "No finish reason captured", tone: "neutral" };
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function isClientAbortError(error: string | null): boolean {
|
|
219
|
-
if (error === null) return false;
|
|
220
|
-
const lower = error.toLowerCase();
|
|
221
|
-
return (
|
|
222
|
-
lower.includes("abort") ||
|
|
223
|
-
lower.includes("cancel") ||
|
|
224
|
-
lower.includes("client disconnected") ||
|
|
225
|
-
lower.includes("stream disconnected") ||
|
|
226
|
-
lower.includes("connection closed")
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function summarizeSessionOutcome({
|
|
231
|
-
pending,
|
|
232
|
-
failures,
|
|
233
|
-
lengthStops,
|
|
234
|
-
stopReason,
|
|
235
|
-
lastFailure,
|
|
236
|
-
}: {
|
|
237
|
-
pending: number;
|
|
238
|
-
failures: number;
|
|
239
|
-
lengthStops: number;
|
|
240
|
-
stopReason: StopReason;
|
|
241
|
-
lastFailure: FailureSummary | null;
|
|
242
|
-
}): SessionOutcomeSummary {
|
|
243
|
-
if (
|
|
244
|
-
lastFailure !== null &&
|
|
245
|
-
(lastFailure.status === 499 || isClientAbortError(lastFailure.error))
|
|
246
|
-
) {
|
|
247
|
-
return {
|
|
248
|
-
label: "Client aborted",
|
|
249
|
-
detail: `Request #${lastFailure.logNumber} ended before completion`,
|
|
250
|
-
tone: "watch",
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
if (pending > 0) {
|
|
255
|
-
return {
|
|
256
|
-
label: "In flight",
|
|
257
|
-
detail: `${pending} request${pending === 1 ? "" : "s"} still running`,
|
|
258
|
-
tone: "cool",
|
|
259
|
-
};
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
if (lastFailure !== null && lastFailure.status !== null && lastFailure.status >= 500) {
|
|
263
|
-
return {
|
|
264
|
-
label: "Provider error",
|
|
265
|
-
detail: `Request #${lastFailure.logNumber} returned HTTP ${lastFailure.status}`,
|
|
266
|
-
tone: "danger",
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
if (failures > 0 && lastFailure !== null) {
|
|
271
|
-
return {
|
|
272
|
-
label: "Failed",
|
|
273
|
-
detail: `Request #${lastFailure.logNumber} needs attention`,
|
|
274
|
-
tone: "danger",
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
if (lengthStops > 0 || stopReason === "length") {
|
|
279
|
-
return {
|
|
280
|
-
label: "Output limited",
|
|
281
|
-
detail: "Model stopped at the output token limit",
|
|
282
|
-
tone: "watch",
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
switch (stopReason) {
|
|
287
|
-
case "end_turn":
|
|
288
|
-
case "stop":
|
|
289
|
-
return { label: "Completed", detail: "Assistant completed normally", tone: "neutral" };
|
|
290
|
-
case "tool_use":
|
|
291
|
-
return { label: "Tool requested", detail: "Assistant handed off to a tool", tone: "cool" };
|
|
292
|
-
case null:
|
|
293
|
-
return { label: "Unknown", detail: "No terminal signal captured", tone: "neutral" };
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
export function buildSessionSlateStats({
|
|
298
|
-
logs,
|
|
299
|
-
conversationGroups,
|
|
300
|
-
isLoading,
|
|
301
|
-
timeDisplayFormat,
|
|
302
|
-
slowResponseThresholdSeconds,
|
|
303
|
-
}: {
|
|
304
|
-
logs: CapturedLog[];
|
|
305
|
-
conversationGroups: readonly ConversationLogs[];
|
|
306
|
-
isLoading: boolean;
|
|
307
|
-
timeDisplayFormat: TimeDisplayFormat;
|
|
308
|
-
slowResponseThresholdSeconds: number;
|
|
309
|
-
}): SessionSlateStats {
|
|
310
|
-
let failures = 0;
|
|
311
|
-
let pending = 0;
|
|
312
|
-
let slow = 0;
|
|
313
|
-
let lengthStops = 0;
|
|
314
|
-
let totalIn = 0;
|
|
315
|
-
let totalOut = 0;
|
|
316
|
-
let terminalStopReason: StopReason = null;
|
|
317
|
-
let lastFailureLogNumber: number | null = null;
|
|
318
|
-
let lastFailure: FailureSummary | null = null;
|
|
319
|
-
let slowestMs: number | null = null;
|
|
320
|
-
let slowestLogNumber: number | null = null;
|
|
321
|
-
let heaviestTokens = 0;
|
|
322
|
-
let heaviestInputTokens = 0;
|
|
323
|
-
let heaviestOutputTokens = 0;
|
|
324
|
-
let heaviestLogNumber: number | null = null;
|
|
325
|
-
const slowThresholdMs = slowResponseThresholdSeconds * 1000;
|
|
326
|
-
|
|
327
|
-
for (let index = 0; index < logs.length; index += 1) {
|
|
328
|
-
const log = logs[index];
|
|
329
|
-
if (log === undefined) continue;
|
|
330
|
-
const logNumber = index + 1;
|
|
331
|
-
const stopReason = extractStopReason(log);
|
|
332
|
-
if (stopReason !== null) terminalStopReason = stopReason;
|
|
333
|
-
if (stopReason === "length") lengthStops += 1;
|
|
334
|
-
|
|
335
|
-
if (hasLogFailure(log)) {
|
|
336
|
-
failures += 1;
|
|
337
|
-
lastFailureLogNumber = logNumber;
|
|
338
|
-
lastFailure = {
|
|
339
|
-
logNumber,
|
|
340
|
-
status: log.responseStatus,
|
|
341
|
-
error: log.error ?? null,
|
|
342
|
-
};
|
|
343
|
-
}
|
|
344
|
-
if (log.responseStatus === null) pending += 1;
|
|
345
|
-
if (
|
|
346
|
-
slowResponseThresholdSeconds > 0 &&
|
|
347
|
-
log.elapsedMs !== null &&
|
|
348
|
-
log.elapsedMs >= slowThresholdMs
|
|
349
|
-
) {
|
|
350
|
-
slow += 1;
|
|
351
|
-
}
|
|
352
|
-
if (log.inputTokens !== null) totalIn += log.inputTokens;
|
|
353
|
-
if (log.outputTokens !== null) totalOut += log.outputTokens;
|
|
354
|
-
if (log.elapsedMs !== null && (slowestMs === null || log.elapsedMs > slowestMs)) {
|
|
355
|
-
slowestMs = log.elapsedMs;
|
|
356
|
-
slowestLogNumber = logNumber;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
const inputTokens = log.inputTokens ?? 0;
|
|
360
|
-
const outputTokens = log.outputTokens ?? 0;
|
|
361
|
-
const requestTokens = inputTokens + outputTokens;
|
|
362
|
-
if (requestTokens > heaviestTokens) {
|
|
363
|
-
heaviestTokens = requestTokens;
|
|
364
|
-
heaviestInputTokens = inputTokens;
|
|
365
|
-
heaviestOutputTokens = outputTokens;
|
|
366
|
-
heaviestLogNumber = logNumber;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
const status: SessionSlateStatus =
|
|
371
|
-
isLoading || (pending > 0 && failures === 0)
|
|
372
|
-
? "rolling"
|
|
373
|
-
: failures > 0
|
|
374
|
-
? "failed"
|
|
375
|
-
: slow > 0 || lengthStops > 0
|
|
376
|
-
? "watch"
|
|
377
|
-
: "clear";
|
|
378
|
-
const statusLabel =
|
|
379
|
-
status === "rolling"
|
|
380
|
-
? "Rolling"
|
|
381
|
-
: status === "failed"
|
|
382
|
-
? "Failure"
|
|
383
|
-
: status === "watch"
|
|
384
|
-
? "Watch"
|
|
385
|
-
: "Clear";
|
|
386
|
-
const finish = summarizeFinishReason({
|
|
387
|
-
stopReason: terminalStopReason,
|
|
388
|
-
pending,
|
|
389
|
-
lastFailureLogNumber,
|
|
390
|
-
});
|
|
391
|
-
const outcome = summarizeSessionOutcome({
|
|
392
|
-
pending,
|
|
393
|
-
failures,
|
|
394
|
-
lengthStops,
|
|
395
|
-
stopReason: terminalStopReason,
|
|
396
|
-
lastFailure,
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
return {
|
|
400
|
-
status,
|
|
401
|
-
statusLabel,
|
|
402
|
-
modelLabel: getModelLabel(logs),
|
|
403
|
-
providerLabel: getProviderLabel(logs),
|
|
404
|
-
requests: logs.length,
|
|
405
|
-
turns: countSessionTurns(logs, conversationGroups),
|
|
406
|
-
failures,
|
|
407
|
-
pending,
|
|
408
|
-
slow,
|
|
409
|
-
lengthStops,
|
|
410
|
-
timeRange: formatTimeRange(logs, timeDisplayFormat),
|
|
411
|
-
tokenLabel: `${formatTokens(totalIn)} in / ${formatTokens(totalOut)} out`,
|
|
412
|
-
finishLabel: finish.label,
|
|
413
|
-
finishDetail: finish.detail,
|
|
414
|
-
finishTone: finish.tone,
|
|
415
|
-
outcomeLabel: outcome.label,
|
|
416
|
-
outcomeDetail: outcome.detail,
|
|
417
|
-
outcomeTone: outcome.tone,
|
|
418
|
-
slowestLabel: slowestMs === null ? "n/a" : formatElapsedMs(slowestMs),
|
|
419
|
-
slowestDetail: slowestLogNumber === null ? "Latency pending" : `Request #${slowestLogNumber}`,
|
|
420
|
-
heaviestDetail:
|
|
421
|
-
heaviestLogNumber === null
|
|
422
|
-
? "Tokens pending"
|
|
423
|
-
: `#${heaviestLogNumber} ${formatTokenPair(heaviestInputTokens, heaviestOutputTokens)}`,
|
|
424
|
-
};
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
export function resolveSessionContextScope({
|
|
428
|
-
pinnedSessionId,
|
|
429
|
-
selectedSession,
|
|
430
|
-
sessions,
|
|
431
|
-
logs,
|
|
432
|
-
}: {
|
|
433
|
-
pinnedSessionId: string | undefined;
|
|
434
|
-
selectedSession: string;
|
|
435
|
-
sessions: readonly string[];
|
|
436
|
-
logs: readonly CapturedLog[];
|
|
437
|
-
}): SessionContextScope | null {
|
|
438
|
-
if (pinnedSessionId !== undefined) {
|
|
439
|
-
const scopedLogs = logs.filter((log) => log.sessionId === pinnedSessionId);
|
|
440
|
-
if (scopedLogs.length === 0) return null;
|
|
441
|
-
return { label: pinnedSessionId, logs: scopedLogs, showBackLink: true };
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
if (selectedSession !== "__all__") {
|
|
445
|
-
const scopedLogs = logs.filter((log) => log.sessionId === selectedSession);
|
|
446
|
-
if (scopedLogs.length === 0) return null;
|
|
447
|
-
return { label: selectedSession, logs: scopedLogs, showBackLink: true };
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
const singleSessionId = sessions.length === 1 ? (sessions[0] ?? null) : null;
|
|
451
|
-
if (singleSessionId !== null) {
|
|
452
|
-
const allVisibleLogsBelongToSession = logs.every((log) => log.sessionId === singleSessionId);
|
|
453
|
-
if (allVisibleLogsBelongToSession) {
|
|
454
|
-
return { label: singleSessionId, logs: [...logs], showBackLink: false };
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
|
|
458
|
-
const allVisibleLogsAreSessionless =
|
|
459
|
-
sessions.length === 0 && logs.length > 0 && logs.every((log) => log.sessionId === null);
|
|
460
|
-
if (allVisibleLogsAreSessionless) {
|
|
461
|
-
return { label: "Visible requests", logs: [...logs], showBackLink: false };
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
return null;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
export function formatPaginationStatus({
|
|
468
|
-
logs,
|
|
469
|
-
pagination,
|
|
470
|
-
}: {
|
|
471
|
-
logs: readonly CapturedLog[];
|
|
472
|
-
pagination: PaginationStatusControls;
|
|
473
|
-
}): string {
|
|
474
|
-
if (pagination.isLoading && logs.length === 0) return "Loading logs...";
|
|
475
|
-
if (logs.length === 0) return "No logs on this page";
|
|
476
|
-
|
|
477
|
-
const first = logs[0];
|
|
478
|
-
const last = logs[logs.length - 1];
|
|
479
|
-
const range =
|
|
480
|
-
first === undefined || last === undefined ? "Current page" : `#${first.id}-#${last.id}`;
|
|
481
|
-
if (pagination.total === null) {
|
|
482
|
-
return `Showing ${logs.length} logs (${range})`;
|
|
483
|
-
}
|
|
484
|
-
if (pagination.total <= logs.length) {
|
|
485
|
-
return `Showing all ${pagination.total} logs`;
|
|
486
|
-
}
|
|
487
|
-
return `Showing ${logs.length} of ${pagination.total} logs (${range})`;
|
|
488
|
-
}
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
export type ReplayMetricValue = number | boolean | null;
|
|
2
|
-
|
|
3
|
-
export type ReplayMetrics = {
|
|
4
|
-
status: number | null;
|
|
5
|
-
elapsedMs: number | null;
|
|
6
|
-
inputTokens: number | null;
|
|
7
|
-
outputTokens: number | null;
|
|
8
|
-
responseBytes: number | null;
|
|
9
|
-
streaming: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type ReplayMetricComparison = {
|
|
13
|
-
id: "status" | "elapsed" | "input" | "output" | "bytes" | "streaming";
|
|
14
|
-
label: string;
|
|
15
|
-
original: ReplayMetricValue;
|
|
16
|
-
replay: ReplayMetricValue;
|
|
17
|
-
delta: number | null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
type JsonObject = Record<string, unknown>;
|
|
21
|
-
|
|
22
|
-
function isJsonObject(value: unknown): value is JsonObject {
|
|
23
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function byteLength(value: string | null | undefined): number | null {
|
|
27
|
-
if (value === null || value === undefined) return null;
|
|
28
|
-
return new TextEncoder().encode(value).length;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function readRequestModel(body: string): string | null {
|
|
32
|
-
try {
|
|
33
|
-
const parsed: unknown = JSON.parse(body);
|
|
34
|
-
if (!isJsonObject(parsed)) return null;
|
|
35
|
-
const model = parsed["model"];
|
|
36
|
-
return typeof model === "string" && model.length > 0 ? model : null;
|
|
37
|
-
} catch {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function replaceRequestModel(
|
|
43
|
-
body: string,
|
|
44
|
-
model: string,
|
|
45
|
-
): { body: string; error: string | null } {
|
|
46
|
-
try {
|
|
47
|
-
const parsed: unknown = JSON.parse(body);
|
|
48
|
-
if (!isJsonObject(parsed)) {
|
|
49
|
-
return { body, error: "Request body must be a JSON object." };
|
|
50
|
-
}
|
|
51
|
-
return {
|
|
52
|
-
body: JSON.stringify({ ...parsed, model }, null, 2),
|
|
53
|
-
error: null,
|
|
54
|
-
};
|
|
55
|
-
} catch {
|
|
56
|
-
return { body, error: "Request body must be valid JSON before changing the replay model." };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function buildReplayMetrics(input: {
|
|
61
|
-
status: number | null | undefined;
|
|
62
|
-
elapsedMs: number | null | undefined;
|
|
63
|
-
inputTokens: number | null | undefined;
|
|
64
|
-
outputTokens: number | null | undefined;
|
|
65
|
-
responseText: string | null | undefined;
|
|
66
|
-
streaming: boolean | null | undefined;
|
|
67
|
-
}): ReplayMetrics {
|
|
68
|
-
return {
|
|
69
|
-
status: input.status ?? null,
|
|
70
|
-
elapsedMs: input.elapsedMs ?? null,
|
|
71
|
-
inputTokens: input.inputTokens ?? null,
|
|
72
|
-
outputTokens: input.outputTokens ?? null,
|
|
73
|
-
responseBytes: byteLength(input.responseText),
|
|
74
|
-
streaming: input.streaming === true,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function numericDelta(original: number | null, replay: number | null): number | null {
|
|
79
|
-
if (original === null || replay === null) return null;
|
|
80
|
-
return replay - original;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function buildReplayComparisons(
|
|
84
|
-
original: ReplayMetrics,
|
|
85
|
-
replay: ReplayMetrics,
|
|
86
|
-
): ReplayMetricComparison[] {
|
|
87
|
-
return [
|
|
88
|
-
{
|
|
89
|
-
id: "status",
|
|
90
|
-
label: "Status",
|
|
91
|
-
original: original.status,
|
|
92
|
-
replay: replay.status,
|
|
93
|
-
delta: numericDelta(original.status, replay.status),
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
id: "elapsed",
|
|
97
|
-
label: "Elapsed",
|
|
98
|
-
original: original.elapsedMs,
|
|
99
|
-
replay: replay.elapsedMs,
|
|
100
|
-
delta: numericDelta(original.elapsedMs, replay.elapsedMs),
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
id: "input",
|
|
104
|
-
label: "Input",
|
|
105
|
-
original: original.inputTokens,
|
|
106
|
-
replay: replay.inputTokens,
|
|
107
|
-
delta: numericDelta(original.inputTokens, replay.inputTokens),
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
id: "output",
|
|
111
|
-
label: "Output",
|
|
112
|
-
original: original.outputTokens,
|
|
113
|
-
replay: replay.outputTokens,
|
|
114
|
-
delta: numericDelta(original.outputTokens, replay.outputTokens),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: "bytes",
|
|
118
|
-
label: "Bytes",
|
|
119
|
-
original: original.responseBytes,
|
|
120
|
-
replay: replay.responseBytes,
|
|
121
|
-
delta: numericDelta(original.responseBytes, replay.responseBytes),
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
id: "streaming",
|
|
125
|
-
label: "Stream",
|
|
126
|
-
original: original.streaming,
|
|
127
|
-
replay: replay.streaming,
|
|
128
|
-
delta: null,
|
|
129
|
-
},
|
|
130
|
-
];
|
|
131
|
-
}
|