@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
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Path-aligned JSON-tree diff helpers for the "compare two log requests" feature.
|
|
3
|
-
*
|
|
4
|
-
* Given two captured log Request payloads, we:
|
|
5
|
-
* 1. Normalize each payload (deep-clone, sort object keys, keep array order)
|
|
6
|
-
* so that non-semantic differences (key order, string whitespace) do not
|
|
7
|
-
* generate false positives.
|
|
8
|
-
* 2. Walk the two trees in lockstep, emitting a list of path-anchored
|
|
9
|
-
* `DiffOp`s. Equal subtrees collapse into a single op at the subtree
|
|
10
|
-
* root, so the renderer can choose to expand or hide them.
|
|
11
|
-
* 3. Emit ops in path-sorted order (depth-first, sibling order = object-key
|
|
12
|
-
* ascending then array-index ascending) so the renderer can lay them
|
|
13
|
-
* out linearly.
|
|
14
|
-
*
|
|
15
|
-
* No runtime dependencies. Mirrors the `cacheTrend.ts` pure-helper pattern.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
19
|
-
export type JsonValue = JsonPrimitive | JsonValue[] | { [key: string]: JsonValue };
|
|
20
|
-
|
|
21
|
-
export type JsonNode =
|
|
22
|
-
| { kind: "object"; value: Record<string, JsonNode> }
|
|
23
|
-
| { kind: "array"; value: JsonNode[] }
|
|
24
|
-
| { kind: "primitive"; value: JsonPrimitive };
|
|
25
|
-
|
|
26
|
-
export type DiffOp =
|
|
27
|
-
| { kind: "equal"; path: string; value: JsonNode }
|
|
28
|
-
| { kind: "added"; path: string; value: JsonNode }
|
|
29
|
-
| { kind: "removed"; path: string; value: JsonNode }
|
|
30
|
-
| {
|
|
31
|
-
kind: "changed";
|
|
32
|
-
path: string;
|
|
33
|
-
left: JsonNode;
|
|
34
|
-
right: JsonNode;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
/** A single segment of a JSON path: an object key or an array index. */
|
|
38
|
-
export type PathSegment = string | number;
|
|
39
|
-
|
|
40
|
-
const ROOT_PATH = "";
|
|
41
|
-
|
|
42
|
-
/** Render a path segment list as a human-readable string.
|
|
43
|
-
*
|
|
44
|
-
* - Root (empty list) → `""` (no label; the renderer hides the gutter)
|
|
45
|
-
* - Object key → `.foo`
|
|
46
|
-
* - Array index → `[3]`
|
|
47
|
-
* - Top-level object key → `messages` (no leading dot)
|
|
48
|
-
*
|
|
49
|
-
* Examples:
|
|
50
|
-
* [] → ""
|
|
51
|
-
* ["messages"] → "messages"
|
|
52
|
-
* ["messages", 3] → "messages[3]"
|
|
53
|
-
* ["messages", 3, "content"] → "messages[3].content"
|
|
54
|
-
* ["messages", 3, "content", 0] → "messages[3].content[0]"
|
|
55
|
-
*/
|
|
56
|
-
export function formatPath(segments: PathSegment[]): string {
|
|
57
|
-
if (segments.length === 0) return ROOT_PATH;
|
|
58
|
-
let out = "";
|
|
59
|
-
for (let i = 0; i < segments.length; i++) {
|
|
60
|
-
const seg = segments[i];
|
|
61
|
-
if (seg === undefined) continue;
|
|
62
|
-
if (typeof seg === "number") {
|
|
63
|
-
out += `[${seg}]`;
|
|
64
|
-
} else if (i === 0) {
|
|
65
|
-
out += seg;
|
|
66
|
-
} else {
|
|
67
|
-
out += `.${seg}`;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return out;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
|
74
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Normalize a captured Request body for comparison.
|
|
79
|
-
*
|
|
80
|
-
* Captured Request bodies are sometimes already-parsed objects and sometimes
|
|
81
|
-
* JSON-encoded strings (depending on which capture path produced the log).
|
|
82
|
-
* We:
|
|
83
|
-
* 1. Try `JSON.parse` if the input is a string.
|
|
84
|
-
* 2. Deep-walk the value, building a fresh `JsonNode` tree.
|
|
85
|
-
* 3. Sort object keys lexicographically (key order is not semantically
|
|
86
|
-
* meaningful for most LLM SDKs but varies between SDK versions, so we
|
|
87
|
-
* canonicalize it).
|
|
88
|
-
* 4. Keep array order (semantically meaningful: `messages[]` order is
|
|
89
|
-
* conversation order; reordering it would silently destroy the diff).
|
|
90
|
-
* 5. Leave primitives alone (no whitespace trim — those can be meaningful
|
|
91
|
-
* in user-message text).
|
|
92
|
-
*
|
|
93
|
-
* Idempotent at the data level: re-normalizing the same shape (in any key
|
|
94
|
-
* order) yields the same tree.
|
|
95
|
-
*/
|
|
96
|
-
export function normalizeRequest(raw: unknown): JsonNode {
|
|
97
|
-
if (typeof raw === "string") {
|
|
98
|
-
try {
|
|
99
|
-
return toNode(JSON.parse(raw));
|
|
100
|
-
} catch {
|
|
101
|
-
// Unparseable string: wrap as a primitive string node so the diff can
|
|
102
|
-
// still operate on it (changed vs. another string, or added/removed
|
|
103
|
-
// vs. an object).
|
|
104
|
-
return { kind: "primitive", value: raw };
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return toNode(raw);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function toNode(value: unknown): JsonNode {
|
|
111
|
-
if (value === null) return { kind: "primitive", value: null };
|
|
112
|
-
if (typeof value === "string") return { kind: "primitive", value };
|
|
113
|
-
if (typeof value === "number") return { kind: "primitive", value };
|
|
114
|
-
if (typeof value === "boolean") return { kind: "primitive", value };
|
|
115
|
-
if (Array.isArray(value)) {
|
|
116
|
-
return { kind: "array", value: value.map((v) => toNode(v)) };
|
|
117
|
-
}
|
|
118
|
-
if (isPlainObject(value)) {
|
|
119
|
-
const out: Record<string, JsonNode> = {};
|
|
120
|
-
for (const k of Object.keys(value).sort()) {
|
|
121
|
-
out[k] = toNode(value[k]);
|
|
122
|
-
}
|
|
123
|
-
return { kind: "object", value: out };
|
|
124
|
-
}
|
|
125
|
-
// Functions, symbols, bigints, undefined — treat as null in the diff model.
|
|
126
|
-
return { kind: "primitive", value: null };
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Compute the path-aligned diff of two normalized trees.
|
|
131
|
-
*
|
|
132
|
-
* Emits `DiffOp[]` in path-sorted order. For each path:
|
|
133
|
-
* - if both trees have the same value, emit a single `equal` op at the
|
|
134
|
-
* deepest common ancestor (so equal subtrees collapse into one op);
|
|
135
|
-
* - if only the right has it, emit `added`;
|
|
136
|
-
* - if only the left has it, emit `removed`;
|
|
137
|
-
* - if both have it but it differs, emit `changed` (and recurse into
|
|
138
|
-
* objects/arrays so the user sees *which* field changed).
|
|
139
|
-
*
|
|
140
|
-
* Pure: does not mutate `left` or `right`.
|
|
141
|
-
*/
|
|
142
|
-
export function diffTrees(left: JsonNode, right: JsonNode): DiffOp[] {
|
|
143
|
-
const ops: DiffOp[] = [];
|
|
144
|
-
walk([], left, right, ops);
|
|
145
|
-
return ops;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function walk(segments: PathSegment[], left: JsonNode, right: JsonNode, out: DiffOp[]): void {
|
|
149
|
-
const path = formatPath(segments);
|
|
150
|
-
|
|
151
|
-
if (nodeEqual(left, right)) {
|
|
152
|
-
out.push({ kind: "equal", path, value: left });
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Type mismatch or primitive change.
|
|
157
|
-
if (left.kind !== right.kind) {
|
|
158
|
-
out.push({ kind: "changed", path, left, right });
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (left.kind === "primitive" && right.kind === "primitive") {
|
|
163
|
-
out.push({ kind: "changed", path, left, right });
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
if (left.kind === "object" && right.kind === "object") {
|
|
168
|
-
const leftKeys = Object.keys(left.value);
|
|
169
|
-
const rightKeys = Object.keys(right.value);
|
|
170
|
-
const rightKeySet = new Set(rightKeys);
|
|
171
|
-
|
|
172
|
-
for (const k of leftKeys) {
|
|
173
|
-
const lChild = left.value[k];
|
|
174
|
-
if (lChild === undefined) continue;
|
|
175
|
-
if (!rightKeySet.has(k)) {
|
|
176
|
-
out.push({
|
|
177
|
-
kind: "removed",
|
|
178
|
-
path: formatPath([...segments, k]),
|
|
179
|
-
value: lChild,
|
|
180
|
-
});
|
|
181
|
-
} else {
|
|
182
|
-
const rChild = right.value[k];
|
|
183
|
-
if (rChild === undefined) continue;
|
|
184
|
-
walk([...segments, k], lChild, rChild, out);
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
for (const k of rightKeys) {
|
|
188
|
-
if (leftKeys.includes(k)) continue;
|
|
189
|
-
const rChild = right.value[k];
|
|
190
|
-
if (rChild === undefined) continue;
|
|
191
|
-
out.push({
|
|
192
|
-
kind: "added",
|
|
193
|
-
path: formatPath([...segments, k]),
|
|
194
|
-
value: rChild,
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
if (left.kind === "array" && right.kind === "array") {
|
|
201
|
-
const minLen = Math.min(left.value.length, right.value.length);
|
|
202
|
-
for (let i = 0; i < minLen; i++) {
|
|
203
|
-
const lChild = left.value[i];
|
|
204
|
-
const rChild = right.value[i];
|
|
205
|
-
if (lChild === undefined || rChild === undefined) continue;
|
|
206
|
-
walk([...segments, i], lChild, rChild, out);
|
|
207
|
-
}
|
|
208
|
-
for (let i = minLen; i < right.value.length; i++) {
|
|
209
|
-
const rChild = right.value[i];
|
|
210
|
-
if (rChild === undefined) continue;
|
|
211
|
-
out.push({
|
|
212
|
-
kind: "added",
|
|
213
|
-
path: formatPath([...segments, i]),
|
|
214
|
-
value: rChild,
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
for (let i = minLen; i < left.value.length; i++) {
|
|
218
|
-
const lChild = left.value[i];
|
|
219
|
-
if (lChild === undefined) continue;
|
|
220
|
-
out.push({
|
|
221
|
-
kind: "removed",
|
|
222
|
-
path: formatPath([...segments, i]),
|
|
223
|
-
value: lChild,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
function nodeEqual(a: JsonNode, b: JsonNode): boolean {
|
|
230
|
-
if (a.kind !== b.kind) return false;
|
|
231
|
-
if (a.kind === "primitive" && b.kind === "primitive") {
|
|
232
|
-
return a.value === b.value;
|
|
233
|
-
}
|
|
234
|
-
if (a.kind === "array" && b.kind === "array") {
|
|
235
|
-
if (a.value.length !== b.value.length) return false;
|
|
236
|
-
for (let i = 0; i < a.value.length; i++) {
|
|
237
|
-
const ai = a.value[i];
|
|
238
|
-
const bi = b.value[i];
|
|
239
|
-
if (ai === undefined || bi === undefined) return false;
|
|
240
|
-
if (!nodeEqual(ai, bi)) return false;
|
|
241
|
-
}
|
|
242
|
-
return true;
|
|
243
|
-
}
|
|
244
|
-
if (a.kind === "object" && b.kind === "object") {
|
|
245
|
-
const aKeys = Object.keys(a.value);
|
|
246
|
-
const bKeys = Object.keys(b.value);
|
|
247
|
-
if (aKeys.length !== bKeys.length) return false;
|
|
248
|
-
for (const k of aKeys) {
|
|
249
|
-
const av = a.value[k];
|
|
250
|
-
const bv = b.value[k];
|
|
251
|
-
if (av === undefined || bv === undefined) return false;
|
|
252
|
-
if (!nodeEqual(av, bv)) return false;
|
|
253
|
-
}
|
|
254
|
-
return true;
|
|
255
|
-
}
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/** Render a JsonNode to a compact human-readable preview. Used by the
|
|
260
|
-
* diff view's gutter or change rows where we want a one-line summary
|
|
261
|
-
* without pretty-printing the whole subtree. */
|
|
262
|
-
export function previewNode(node: JsonNode, maxLen = 80): string {
|
|
263
|
-
let s: string;
|
|
264
|
-
switch (node.kind) {
|
|
265
|
-
case "primitive":
|
|
266
|
-
s = node.value === null ? "null" : JSON.stringify(node.value);
|
|
267
|
-
break;
|
|
268
|
-
case "array":
|
|
269
|
-
s = `[… ${node.value.length} items]`;
|
|
270
|
-
break;
|
|
271
|
-
case "object":
|
|
272
|
-
s = `{… ${Object.keys(node.value).length} keys}`;
|
|
273
|
-
break;
|
|
274
|
-
}
|
|
275
|
-
if (s.length > maxLen) s = `${s.slice(0, maxLen - 1)}…`;
|
|
276
|
-
return s;
|
|
277
|
-
}
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { safeGetOwnProperty } from "../../lib/objectUtils";
|
|
2
|
-
|
|
3
|
-
export type RequestToolCategory = "file" | "shell" | "browser" | "web" | "mcp" | "code" | "other";
|
|
4
|
-
|
|
5
|
-
export type RequestToolDefinition = {
|
|
6
|
-
name: string;
|
|
7
|
-
description: string | null;
|
|
8
|
-
descriptionPreview: string | null;
|
|
9
|
-
category: RequestToolCategory;
|
|
10
|
-
parameterCount: number;
|
|
11
|
-
requiredParameters: string[];
|
|
12
|
-
schema: unknown | null;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export type RequestToolCategorySummary = {
|
|
16
|
-
category: RequestToolCategory;
|
|
17
|
-
count: number;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export type RequestToolsSummary = {
|
|
21
|
-
tools: RequestToolDefinition[];
|
|
22
|
-
toolChoiceLabel: string | null;
|
|
23
|
-
categories: RequestToolCategorySummary[];
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const CATEGORY_ORDER: RequestToolCategory[] = [
|
|
27
|
-
"file",
|
|
28
|
-
"shell",
|
|
29
|
-
"browser",
|
|
30
|
-
"web",
|
|
31
|
-
"mcp",
|
|
32
|
-
"code",
|
|
33
|
-
"other",
|
|
34
|
-
];
|
|
35
|
-
|
|
36
|
-
function firstTextSlice(value: string): string {
|
|
37
|
-
const normalized = value.replace(/\s+/g, " ").trim();
|
|
38
|
-
if (normalized.length <= 120) return normalized;
|
|
39
|
-
return `${normalized.slice(0, 119)}...`;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function previewDescription(description: string | null): string | null {
|
|
43
|
-
if (description === null) return null;
|
|
44
|
-
const normalized = description.replace(/\s+/g, " ").trim();
|
|
45
|
-
if (normalized.length === 0) return null;
|
|
46
|
-
const sentenceEnd = normalized.search(/[.!?。!?]/);
|
|
47
|
-
if (sentenceEnd >= 24) return firstTextSlice(normalized.slice(0, sentenceEnd + 1));
|
|
48
|
-
return firstTextSlice(normalized);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function lowerHaystack(name: string, description: string | null): string {
|
|
52
|
-
return `${name} ${description ?? ""}`.toLowerCase();
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function includesAny(value: string, needles: readonly string[]): boolean {
|
|
56
|
-
return needles.some((needle) => value.includes(needle));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function categorizeTool(name: string, description: string | null): RequestToolCategory {
|
|
60
|
-
const haystack = lowerHaystack(name, description);
|
|
61
|
-
if (
|
|
62
|
-
name.startsWith("mcp__") ||
|
|
63
|
-
name.startsWith("inspector_") ||
|
|
64
|
-
includesAny(haystack, [" mcp", "model context protocol"])
|
|
65
|
-
) {
|
|
66
|
-
return "mcp";
|
|
67
|
-
}
|
|
68
|
-
if (
|
|
69
|
-
includesAny(haystack, ["bash", "shell", "terminal", "command", "powershell", "exec", "process"])
|
|
70
|
-
) {
|
|
71
|
-
return "shell";
|
|
72
|
-
}
|
|
73
|
-
if (
|
|
74
|
-
includesAny(haystack, [
|
|
75
|
-
"browser",
|
|
76
|
-
"playwright",
|
|
77
|
-
"screenshot",
|
|
78
|
-
"click",
|
|
79
|
-
"navigate",
|
|
80
|
-
"page",
|
|
81
|
-
"tab",
|
|
82
|
-
])
|
|
83
|
-
) {
|
|
84
|
-
return "browser";
|
|
85
|
-
}
|
|
86
|
-
if (
|
|
87
|
-
includesAny(haystack, [
|
|
88
|
-
"read",
|
|
89
|
-
"write",
|
|
90
|
-
"edit",
|
|
91
|
-
"file",
|
|
92
|
-
"glob",
|
|
93
|
-
"grep",
|
|
94
|
-
"patch",
|
|
95
|
-
"filesystem",
|
|
96
|
-
"directory",
|
|
97
|
-
])
|
|
98
|
-
) {
|
|
99
|
-
return "file";
|
|
100
|
-
}
|
|
101
|
-
if (includesAny(haystack, ["web", "search", "http", "url", "fetch"])) {
|
|
102
|
-
return "web";
|
|
103
|
-
}
|
|
104
|
-
if (includesAny(haystack, ["code", "typescript", "javascript", "python", "repl"])) {
|
|
105
|
-
return "code";
|
|
106
|
-
}
|
|
107
|
-
return "other";
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function parameterNames(schema: unknown): string[] {
|
|
111
|
-
const properties = safeGetOwnProperty(schema, "properties");
|
|
112
|
-
if (properties === null || typeof properties !== "object" || Array.isArray(properties)) {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
return Object.keys(properties).sort((a, b) => a.localeCompare(b));
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function requiredParameterNames(schema: unknown): string[] {
|
|
119
|
-
const required = safeGetOwnProperty(schema, "required");
|
|
120
|
-
if (!Array.isArray(required)) return [];
|
|
121
|
-
const names: string[] = [];
|
|
122
|
-
for (const item of required) {
|
|
123
|
-
if (typeof item === "string" && item.length > 0) names.push(item);
|
|
124
|
-
}
|
|
125
|
-
return names.sort((a, b) => a.localeCompare(b));
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function parseAnthropicTool(tool: unknown): RequestToolDefinition | null {
|
|
129
|
-
const name = safeGetOwnProperty(tool, "name");
|
|
130
|
-
if (typeof name !== "string" || name.length === 0) return null;
|
|
131
|
-
const description = safeGetOwnProperty(tool, "description");
|
|
132
|
-
const schema = safeGetOwnProperty(tool, "input_schema") ?? null;
|
|
133
|
-
const normalizedDescription = typeof description === "string" ? description : null;
|
|
134
|
-
return {
|
|
135
|
-
name,
|
|
136
|
-
description: normalizedDescription,
|
|
137
|
-
descriptionPreview: previewDescription(normalizedDescription),
|
|
138
|
-
category: categorizeTool(name, normalizedDescription),
|
|
139
|
-
parameterCount: parameterNames(schema).length,
|
|
140
|
-
requiredParameters: requiredParameterNames(schema),
|
|
141
|
-
schema,
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function parseOpenAITool(tool: unknown): RequestToolDefinition | null {
|
|
146
|
-
const fn = safeGetOwnProperty(tool, "function");
|
|
147
|
-
const toolType = safeGetOwnProperty(tool, "type");
|
|
148
|
-
if (fn === undefined && typeof toolType !== "string") return null;
|
|
149
|
-
const name =
|
|
150
|
-
safeGetOwnProperty(fn, "name") ??
|
|
151
|
-
safeGetOwnProperty(tool, "name") ??
|
|
152
|
-
(typeof toolType === "string" ? toolType : undefined);
|
|
153
|
-
if (typeof name !== "string" || name.length === 0) return null;
|
|
154
|
-
const description =
|
|
155
|
-
safeGetOwnProperty(fn, "description") ?? safeGetOwnProperty(tool, "description");
|
|
156
|
-
const schema =
|
|
157
|
-
safeGetOwnProperty(fn, "parameters") ?? safeGetOwnProperty(tool, "parameters") ?? null;
|
|
158
|
-
const normalizedDescription = typeof description === "string" ? description : null;
|
|
159
|
-
return {
|
|
160
|
-
name,
|
|
161
|
-
description: normalizedDescription,
|
|
162
|
-
descriptionPreview: previewDescription(normalizedDescription),
|
|
163
|
-
category: categorizeTool(name, normalizedDescription),
|
|
164
|
-
parameterCount: parameterNames(schema).length,
|
|
165
|
-
requiredParameters: requiredParameterNames(schema),
|
|
166
|
-
schema,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function parseTool(tool: unknown): RequestToolDefinition | null {
|
|
171
|
-
const openAITool = parseOpenAITool(tool);
|
|
172
|
-
if (openAITool !== null) return openAITool;
|
|
173
|
-
return parseAnthropicTool(tool);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
function formatToolChoice(choice: unknown): string | null {
|
|
177
|
-
if (choice === undefined || choice === null) return null;
|
|
178
|
-
if (typeof choice === "string") return choice;
|
|
179
|
-
const type = safeGetOwnProperty(choice, "type");
|
|
180
|
-
const name = safeGetOwnProperty(choice, "name");
|
|
181
|
-
const fnName = safeGetOwnProperty(safeGetOwnProperty(choice, "function"), "name");
|
|
182
|
-
if (typeof type === "string" && typeof fnName === "string" && fnName.length > 0) {
|
|
183
|
-
return `${type}: ${fnName}`;
|
|
184
|
-
}
|
|
185
|
-
if (typeof type === "string" && typeof name === "string" && name.length > 0) {
|
|
186
|
-
return `${type}: ${name}`;
|
|
187
|
-
}
|
|
188
|
-
if (typeof type === "string") return type;
|
|
189
|
-
const encoded = JSON.stringify(choice);
|
|
190
|
-
return encoded === undefined ? null : firstTextSlice(encoded);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
function summarizeCategories(tools: RequestToolDefinition[]): RequestToolCategorySummary[] {
|
|
194
|
-
const counts = new Map<RequestToolCategory, number>();
|
|
195
|
-
for (const tool of tools) {
|
|
196
|
-
counts.set(tool.category, (counts.get(tool.category) ?? 0) + 1);
|
|
197
|
-
}
|
|
198
|
-
return CATEGORY_ORDER.flatMap((category) => {
|
|
199
|
-
const count = counts.get(category) ?? 0;
|
|
200
|
-
return count > 0 ? [{ category, count }] : [];
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export function parseRequestTools(parsed: unknown): RequestToolsSummary | null {
|
|
205
|
-
const rawTools = safeGetOwnProperty(parsed, "tools");
|
|
206
|
-
if (!Array.isArray(rawTools) || rawTools.length === 0) return null;
|
|
207
|
-
|
|
208
|
-
const tools: RequestToolDefinition[] = [];
|
|
209
|
-
for (const rawTool of rawTools) {
|
|
210
|
-
const tool = parseTool(rawTool);
|
|
211
|
-
if (tool !== null) tools.push(tool);
|
|
212
|
-
}
|
|
213
|
-
if (tools.length === 0) return null;
|
|
214
|
-
|
|
215
|
-
return {
|
|
216
|
-
tools,
|
|
217
|
-
toolChoiceLabel: formatToolChoice(safeGetOwnProperty(parsed, "tool_choice")),
|
|
218
|
-
categories: summarizeCategories(tools),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useRef, useState, type MouseEvent } from "react";
|
|
2
|
-
import { copyTextToClipboard } from "../../lib/clipboard";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Clipboard write with a 2s "Copied!" indicator. Returns null-safe
|
|
6
|
-
* callbacks so callers can pass `text === null` through unconditionally
|
|
7
|
-
* (the hook still runs; the click handler short-circuits).
|
|
8
|
-
*/
|
|
9
|
-
export function useCopyFeedback(text: string | null): {
|
|
10
|
-
copied: boolean;
|
|
11
|
-
copy: (event: MouseEvent) => void;
|
|
12
|
-
} {
|
|
13
|
-
const [copied, setCopied] = useState(false);
|
|
14
|
-
const timerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
15
|
-
|
|
16
|
-
useEffect(
|
|
17
|
-
() => () => {
|
|
18
|
-
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
19
|
-
},
|
|
20
|
-
[],
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const copy = useCallback(
|
|
24
|
-
(event: MouseEvent) => {
|
|
25
|
-
event.stopPropagation();
|
|
26
|
-
if (text === null) return;
|
|
27
|
-
void copyTextToClipboard(text).then((success) => {
|
|
28
|
-
if (!success) return;
|
|
29
|
-
setCopied(true);
|
|
30
|
-
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
31
|
-
timerRef.current = setTimeout(() => setCopied(false), 2000);
|
|
32
|
-
});
|
|
33
|
-
},
|
|
34
|
-
[text],
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return { copied, copy };
|
|
38
|
-
}
|