@tonyclaw/agent-inspector 3.1.32 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.output/backend/nitro.json +1 -1
- package/.output/cli.js +241 -120
- package/.output/server/_ssr/index.mjs +1 -1
- package/.output/server/_ssr/{router-oXUk3MBR.mjs → router-BBY_zWRK.mjs} +91 -3
- package/.output/server/index.mjs +1 -1
- package/.output/ui/assets/{CompareDrawer-BtfPSpkV.js → CompareDrawer-rtNElN-B.js} +1 -1
- package/.output/ui/assets/{InspectorPet-D9DPPQ3n.js → InspectorPet-QaAiuF3d.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-Buu8vkCK.js → ProxyViewerContainer-6twNZHwl.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-BER-QzpD.js → ReplayDialog-B7KlziO2.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-C8Zwxrr7.js → RequestAnatomy-2XVFBrW4.js} +1 -1
- package/.output/ui/assets/{ResponseView-DDpKdYk6.js → ResponseView-BULgzLVB.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-sMPGG7Sw.js → StreamingChunkSequence-DSkvkbns.js} +1 -1
- package/.output/ui/assets/{_sessionId-e4IheHnP.js → _sessionId-D2dmJi3G.js} +1 -1
- package/.output/ui/assets/{_sessionId-C5Uv72Fx.js → _sessionId-DcS0s1Mr.js} +1 -1
- package/.output/ui/assets/{index-B__qT0Yd.js → index-B0TN1KKO.js} +2 -2
- package/.output/ui/assets/{index-Be3bTCzi.js → index-Bva1zHEs.js} +1 -1
- package/.output/ui/assets/{index-C9q__p8J.js → index-BzBExOxu.js} +1 -1
- package/.output/ui/assets/{index-CtB0deSZ.js → index-k6sRQz55.js} +1 -1
- package/.output/ui/assets/{json-viewer-Db0AFp-7.js → json-viewer-CWM4tY-j.js} +1 -1
- package/.output/ui/assets/{jszip.min-DkY0Ym_q.js → jszip.min-BkWvRFlo.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/package.json +8 -13
- package/src/assets/IDE/claudecode-color.svg +0 -1
- package/src/assets/IDE/codex-color.svg +0 -1
- package/src/assets/IDE/opencode.svg +0 -1
- package/src/assets/IDE/xiaomimimo.svg +0 -1
- package/src/assets/favicon.svg +0 -21
- package/src/assets/logos/alibaba.svg +0 -1
- package/src/assets/logos/anthropic.svg +0 -1
- package/src/assets/logos/claude-code.svg +0 -4
- package/src/assets/logos/deepseek.svg +0 -1
- package/src/assets/logos/minimax.jpeg +0 -0
- package/src/assets/logos/openai.svg +0 -1
- package/src/assets/logos/opencode.svg +0 -4
- package/src/assets/logos/qwen.webp +0 -0
- package/src/assets/logos/zhipuai.svg +0 -219
- package/src/backend/router.tsx +0 -36
- package/src/backend/routes/$.ts +0 -26
- package/src/backend/routes/__root.ts +0 -4
- package/src/backend/routes/api/-instances.ts +0 -7
- package/src/backend/routes/api/alerts.summary.ts +0 -28
- package/src/backend/routes/api/alerts.ts +0 -70
- package/src/backend/routes/api/config.paths.ts +0 -14
- package/src/backend/routes/api/config.ts +0 -73
- package/src/backend/routes/api/ecosystem.packages.$packageId.help.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.install.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.runner-presets.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.$packageId.upgrade.ts +0 -11
- package/src/backend/routes/api/ecosystem.packages.ts +0 -21
- package/src/backend/routes/api/ecosystem.recipes.$recipeId.run.ts +0 -11
- package/src/backend/routes/api/ecosystem.tasks.$taskId.ts +0 -16
- package/src/backend/routes/api/ecosystem.tasks.ts +0 -12
- package/src/backend/routes/api/groups.$groupId.evidence.ts +0 -55
- package/src/backend/routes/api/groups.$groupId.sessions.ts +0 -50
- package/src/backend/routes/api/groups.$groupId.ts +0 -93
- package/src/backend/routes/api/groups.ts +0 -79
- package/src/backend/routes/api/health.ts +0 -22
- package/src/backend/routes/api/instances.$name.connection.ts +0 -12
- package/src/backend/routes/api/instances.$name.restart.ts +0 -23
- package/src/backend/routes/api/instances.$name.start.ts +0 -18
- package/src/backend/routes/api/instances.$name.stop.ts +0 -23
- package/src/backend/routes/api/instances.$name.ts +0 -12
- package/src/backend/routes/api/instances.ts +0 -16
- package/src/backend/routes/api/knowledge.candidates.$candidateId.promote.ts +0 -32
- package/src/backend/routes/api/knowledge.candidates.$candidateId.ts +0 -50
- package/src/backend/routes/api/knowledge.candidates.ts +0 -10
- package/src/backend/routes/api/knowledge.project-context.ts +0 -29
- package/src/backend/routes/api/knowledge.search.ts +0 -62
- package/src/backend/routes/api/knowledge.sessions.$sessionId.candidates.ts +0 -26
- package/src/backend/routes/api/logs.$id.body.ts +0 -58
- package/src/backend/routes/api/logs.$id.chunks.ts +0 -37
- package/src/backend/routes/api/logs.$id.replay.ts +0 -297
- package/src/backend/routes/api/logs.$id.ts +0 -23
- package/src/backend/routes/api/logs.import.ts +0 -39
- package/src/backend/routes/api/logs.stream.ts +0 -174
- package/src/backend/routes/api/logs.ts +0 -214
- package/src/backend/routes/api/mcp.ts +0 -25
- package/src/backend/routes/api/models.ts +0 -10
- package/src/backend/routes/api/pi-agent.ts +0 -29
- package/src/backend/routes/api/providers.$providerId.model-metadata.ts +0 -173
- package/src/backend/routes/api/providers.$providerId.test.log.ts +0 -342
- package/src/backend/routes/api/providers.$providerId.ts +0 -111
- package/src/backend/routes/api/providers.export.ts +0 -44
- package/src/backend/routes/api/providers.import.ts +0 -81
- package/src/backend/routes/api/providers.scan.ts +0 -28
- package/src/backend/routes/api/providers.ts +0 -102
- package/src/backend/routes/api/runs.$runId.evidence.ts +0 -55
- package/src/backend/routes/api/runs.$runId.ts +0 -50
- package/src/backend/routes/api/runs.ts +0 -62
- package/src/backend/routes/api/runtime.ts +0 -46
- package/src/backend/routes/api/sessions.ts +0 -51
- package/src/backend/routes/api/storage.ts +0 -56
- package/src/backend/routes/livez.ts +0 -13
- package/src/backend/routes/metrics.ts +0 -14
- package/src/backend/routes/proxy/$.ts +0 -15
- package/src/backend/routes/readyz.ts +0 -18
- package/src/backend/start.ts +0 -10
- package/src/cli/alias.ts +0 -431
- package/src/cli/detect-tools.ts +0 -123
- package/src/cli/doctor.ts +0 -836
- package/src/cli/instance.ts +0 -1071
- package/src/cli/instanceApi.ts +0 -213
- package/src/cli/instanceArgs.ts +0 -301
- package/src/cli/instanceControl.ts +0 -191
- package/src/cli/instanceModel.ts +0 -276
- package/src/cli/instanceRegistry.ts +0 -731
- package/src/cli/networkHints.ts +0 -170
- package/src/cli/onboard.ts +0 -1668
- package/src/cli/onboardTarget.ts +0 -228
- package/src/cli/rustBackendPackage.ts +0 -458
- package/src/cli/startupOutput.ts +0 -16
- package/src/cli/templates/codex-skill-onboard.ts +0 -320
- package/src/cli/templates/command-onboard.ts +0 -25
- package/src/cli/templates/skill-onboard.ts +0 -625
- package/src/cli.ts +0 -1397
- package/src/components/OnboardingBanner.tsx +0 -115
- package/src/components/ProxyViewer.tsx +0 -2259
- package/src/components/ProxyViewerContainer.tsx +0 -1076
- package/src/components/alerts/AlertsDialog.tsx +0 -615
- package/src/components/clients/ClientLogo.tsx +0 -175
- package/src/components/ecosystem/AgentLabDialog.tsx +0 -947
- package/src/components/errors/SafeErrorBoundary.tsx +0 -201
- package/src/components/groups/GroupsDialog.tsx +0 -1304
- package/src/components/inspector-pet/InspectorPet.tsx +0 -398
- package/src/components/inspector-pet/InspectorPetCrab3D.tsx +0 -455
- package/src/components/inspector-pet/inspectorPetLogic.ts +0 -272
- package/src/components/pi-agent/PiAgentPanel.tsx +0 -446
- package/src/components/pi-agent/piAgentChatLogic.ts +0 -273
- package/src/components/providers/ImportWizardDialog.tsx +0 -281
- package/src/components/providers/ProviderCard.tsx +0 -347
- package/src/components/providers/ProviderForm.tsx +0 -1183
- package/src/components/providers/ProviderLogo.tsx +0 -122
- package/src/components/providers/ProviderTestResultsView.tsx +0 -734
- package/src/components/providers/ProvidersPanel.tsx +0 -714
- package/src/components/providers/SettingsDialog.tsx +0 -1042
- package/src/components/providers/providerFormCapabilities.ts +0 -36
- package/src/components/proxy-viewer/AgentTraceSummary.tsx +0 -902
- package/src/components/proxy-viewer/AnswerMarkdown.tsx +0 -51
- package/src/components/proxy-viewer/ApplicationBar.tsx +0 -123
- package/src/components/proxy-viewer/CompareDrawer.tsx +0 -984
- package/src/components/proxy-viewer/ConversationGroup.tsx +0 -208
- package/src/components/proxy-viewer/ConversationGroupList.tsx +0 -652
- package/src/components/proxy-viewer/ConversationHeader.tsx +0 -429
- package/src/components/proxy-viewer/LiveConnectionStatus.tsx +0 -186
- package/src/components/proxy-viewer/LogEntry.tsx +0 -1419
- package/src/components/proxy-viewer/LogEntryHeader.tsx +0 -596
- package/src/components/proxy-viewer/ProviderLogoStack.tsx +0 -57
- package/src/components/proxy-viewer/RawExportWarning.tsx +0 -77
- package/src/components/proxy-viewer/ReplayDialog.tsx +0 -636
- package/src/components/proxy-viewer/RequestToolsPanel.tsx +0 -299
- package/src/components/proxy-viewer/ResponseView.tsx +0 -202
- package/src/components/proxy-viewer/SessionLoadProgressBar.tsx +0 -61
- package/src/components/proxy-viewer/StreamingChunkSequence.tsx +0 -265
- package/src/components/proxy-viewer/ThreadConnector.tsx +0 -165
- package/src/components/proxy-viewer/ToolTraceEvents.tsx +0 -64
- package/src/components/proxy-viewer/TurnGroup.tsx +0 -383
- package/src/components/proxy-viewer/TurnGroupList.tsx +0 -156
- package/src/components/proxy-viewer/accessibility.ts +0 -8
- package/src/components/proxy-viewer/anatomy/RequestAnatomy.tsx +0 -887
- package/src/components/proxy-viewer/anatomy/SegmentBar.tsx +0 -222
- package/src/components/proxy-viewer/anatomy/contextIntelligence.ts +0 -737
- package/src/components/proxy-viewer/anatomy/sessionContextSummary.ts +0 -268
- package/src/components/proxy-viewer/anatomy/tokenEstimate.ts +0 -53
- package/src/components/proxy-viewer/anatomy/types.ts +0 -41
- package/src/components/proxy-viewer/anatomy/useAnatomyJump.ts +0 -114
- package/src/components/proxy-viewer/bodyHydration.ts +0 -123
- package/src/components/proxy-viewer/cacheTrend.ts +0 -50
- package/src/components/proxy-viewer/diff/DiffView.tsx +0 -321
- package/src/components/proxy-viewer/diff/computeDiff.ts +0 -178
- package/src/components/proxy-viewer/diff/index.ts +0 -3
- package/src/components/proxy-viewer/formats/anthropic/ContentBlocks.tsx +0 -194
- package/src/components/proxy-viewer/formats/anthropic/ResponseView.tsx +0 -81
- package/src/components/proxy-viewer/formats/anthropic/thinkingExtract.ts +0 -21
- package/src/components/proxy-viewer/formats/index.tsx +0 -47
- package/src/components/proxy-viewer/formats/openai/ResponseView.tsx +0 -442
- package/src/components/proxy-viewer/index.ts +0 -9
- package/src/components/proxy-viewer/lazy.ts +0 -41
- package/src/components/proxy-viewer/liveConnectionState.ts +0 -158
- package/src/components/proxy-viewer/log-formats/anthropic.ts +0 -191
- package/src/components/proxy-viewer/log-formats/index.ts +0 -23
- package/src/components/proxy-viewer/log-formats/openai.ts +0 -256
- package/src/components/proxy-viewer/log-formats/types.ts +0 -40
- package/src/components/proxy-viewer/log-formats/unknown.ts +0 -18
- package/src/components/proxy-viewer/logEntryVisibility.ts +0 -73
- package/src/components/proxy-viewer/logFocus.ts +0 -54
- package/src/components/proxy-viewer/proxyViewerContainerLogic.ts +0 -124
- package/src/components/proxy-viewer/proxyViewerLogic.ts +0 -488
- package/src/components/proxy-viewer/replayComparison.ts +0 -131
- package/src/components/proxy-viewer/requestDiff.ts +0 -277
- package/src/components/proxy-viewer/requestTools.ts +0 -220
- package/src/components/proxy-viewer/useCopyFeedback.ts +0 -38
- package/src/components/proxy-viewer/useKeyboardNavigation.ts +0 -232
- package/src/components/proxy-viewer/viewerState.ts +0 -176
- package/src/components/ui/badge.tsx +0 -47
- package/src/components/ui/button.tsx +0 -47
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/confirm-dialog.tsx +0 -51
- package/src/components/ui/crab-logo.tsx +0 -45
- package/src/components/ui/crab-variants.tsx +0 -467
- package/src/components/ui/dialog.tsx +0 -130
- package/src/components/ui/icon-trigger.ts +0 -2
- package/src/components/ui/json-viewer-bulk.ts +0 -132
- package/src/components/ui/json-viewer.tsx +0 -508
- package/src/components/ui/scroll-area.tsx +0 -54
- package/src/components/ui/select.tsx +0 -178
- package/src/components/ui/separator.tsx +0 -28
- package/src/components/ui/tabs.tsx +0 -88
- package/src/components/ui/tooltip.tsx +0 -51
- package/src/components/ui/transient-toast.tsx +0 -105
- package/src/contracts/anthropic.ts +0 -230
- package/src/contracts/index.ts +0 -59
- package/src/contracts/json.ts +0 -37
- package/src/contracts/log.ts +0 -139
- package/src/contracts/openai.ts +0 -267
- package/src/index.css +0 -11
- package/src/knowledge/candidateStore.ts +0 -94
- package/src/knowledge/distiller.ts +0 -98
- package/src/knowledge/openclawClient.ts +0 -161
- package/src/knowledge/openclawGatewayClient.ts +0 -249
- package/src/knowledge/openclawMarkdown.ts +0 -146
- package/src/knowledge/redactor.ts +0 -80
- package/src/knowledge/types.ts +0 -83
- package/src/lib/alertContract.ts +0 -76
- package/src/lib/apiClient.ts +0 -166
- package/src/lib/apiFormat.ts +0 -29
- package/src/lib/backendImplementation.ts +0 -16
- package/src/lib/basePath.ts +0 -107
- package/src/lib/browserRuntimeContract.ts +0 -124
- package/src/lib/browserRuntimeResolver.ts +0 -333
- package/src/lib/chunkLoadRecovery.ts +0 -83
- package/src/lib/claudeCodeStrip.ts +0 -98
- package/src/lib/clipboard.ts +0 -67
- package/src/lib/codingAgentEndpoints.ts +0 -54
- package/src/lib/ecosystemContract.ts +0 -130
- package/src/lib/export-logs.ts +0 -287
- package/src/lib/groupContract.ts +0 -166
- package/src/lib/instanceContract.ts +0 -239
- package/src/lib/jsonFile.ts +0 -46
- package/src/lib/logImportContract.ts +0 -12
- package/src/lib/managedInstance.ts +0 -112
- package/src/lib/mask.ts +0 -4
- package/src/lib/objectUtils.ts +0 -22
- package/src/lib/piAgentContract.ts +0 -102
- package/src/lib/providerContract.ts +0 -125
- package/src/lib/providerImportContract.ts +0 -27
- package/src/lib/providerModelMetadata.ts +0 -458
- package/src/lib/providerTestContract.ts +0 -170
- package/src/lib/providerTestPrompt.ts +0 -100
- package/src/lib/publicBasePathContext.ts +0 -137
- package/src/lib/resourceLimits.ts +0 -345
- package/src/lib/runContract.ts +0 -164
- package/src/lib/runtimeConfig.ts +0 -43
- package/src/lib/safeDiagnostic.ts +0 -38
- package/src/lib/safeFetch.ts +0 -508
- package/src/lib/serverPort.ts +0 -47
- package/src/lib/sessionInfoContract.ts +0 -78
- package/src/lib/sessionUrl.ts +0 -46
- package/src/lib/ssrfGuard.ts +0 -133
- package/src/lib/stopReason.ts +0 -130
- package/src/lib/themeMode.ts +0 -41
- package/src/lib/timeDisplay.ts +0 -22
- package/src/lib/toolTrace.ts +0 -290
- package/src/lib/uiScale.ts +0 -117
- package/src/lib/unknown.ts +0 -27
- package/src/lib/upstreamUrl.ts +0 -150
- package/src/lib/useAlerts.ts +0 -82
- package/src/lib/useGroupEvidence.ts +0 -37
- package/src/lib/useGroups.ts +0 -32
- package/src/lib/useOnboarding.ts +0 -93
- package/src/lib/useProviders.ts +0 -30
- package/src/lib/useStripConfig.ts +0 -154
- package/src/lib/useThemeMode.ts +0 -40
- package/src/lib/useUiScale.ts +0 -52
- package/src/lib/utils.ts +0 -78
- package/src/mcp/currentContext.ts +0 -65
- package/src/mcp/instanceHandlers.ts +0 -151
- package/src/mcp/loopback.ts +0 -88
- package/src/mcp/mode.ts +0 -75
- package/src/mcp/previewExtractor.ts +0 -233
- package/src/mcp/server.ts +0 -2274
- package/src/mcp/toolHandlers.ts +0 -1533
- package/src/proxy/alerts.ts +0 -664
- package/src/proxy/chunkStorage.ts +0 -123
- package/src/proxy/config.ts +0 -218
- package/src/proxy/constants.ts +0 -66
- package/src/proxy/dataDir.ts +0 -147
- package/src/proxy/ecosystemExecutionConfirmation.ts +0 -114
- package/src/proxy/ecosystemExecutionRoute.ts +0 -116
- package/src/proxy/ecosystemRegistry.ts +0 -296
- package/src/proxy/ecosystemTasks.ts +0 -415
- package/src/proxy/evidenceAnalysis.ts +0 -526
- package/src/proxy/evidenceExporter.ts +0 -235
- package/src/proxy/formats/anthropic/anthropicProvider.ts +0 -75
- package/src/proxy/formats/anthropic/handler.ts +0 -75
- package/src/proxy/formats/anthropic/index.ts +0 -13
- package/src/proxy/formats/anthropic/register.ts +0 -4
- package/src/proxy/formats/anthropic/schemas.ts +0 -6
- package/src/proxy/formats/anthropic/stream.ts +0 -205
- package/src/proxy/formats/handler.ts +0 -46
- package/src/proxy/formats/index.ts +0 -13
- package/src/proxy/formats/jsonSchema.ts +0 -2
- package/src/proxy/formats/openai/alibabaProvider.ts +0 -34
- package/src/proxy/formats/openai/codexMetadata.ts +0 -61
- package/src/proxy/formats/openai/handler.ts +0 -133
- package/src/proxy/formats/openai/index.ts +0 -33
- package/src/proxy/formats/openai/provider.ts +0 -50
- package/src/proxy/formats/openai/register.ts +0 -4
- package/src/proxy/formats/openai/schemas.ts +0 -25
- package/src/proxy/formats/openai/stream.ts +0 -600
- package/src/proxy/formats/openai/zhipuProvider.ts +0 -31
- package/src/proxy/formats/providerAdapter.ts +0 -50
- package/src/proxy/formats/providerRegistry.ts +0 -51
- package/src/proxy/formats/providers/index.ts +0 -3
- package/src/proxy/formats/registry.ts +0 -65
- package/src/proxy/groupEvidenceExporter.ts +0 -371
- package/src/proxy/groupStore.ts +0 -336
- package/src/proxy/handler.ts +0 -729
- package/src/proxy/identityProxy.ts +0 -1842
- package/src/proxy/jsonlRecovery.ts +0 -554
- package/src/proxy/logBodyChunks.ts +0 -91
- package/src/proxy/logFinalizer.ts +0 -777
- package/src/proxy/logFinalizer.worker.ts +0 -24
- package/src/proxy/logImportUpload.ts +0 -128
- package/src/proxy/logImporter.ts +0 -813
- package/src/proxy/logIndex.ts +0 -663
- package/src/proxy/logSearch.ts +0 -122
- package/src/proxy/logger.ts +0 -537
- package/src/proxy/openaiOrphanToolStrip.ts +0 -142
- package/src/proxy/platformCommands.ts +0 -253
- package/src/proxy/privateDataPath.ts +0 -419
- package/src/proxy/providerImporters.ts +0 -578
- package/src/proxy/providerScanStore.ts +0 -87
- package/src/proxy/providerSecretStore.ts +0 -216
- package/src/proxy/providers.ts +0 -998
- package/src/proxy/rawStreamCapture.ts +0 -342
- package/src/proxy/runFailures.ts +0 -94
- package/src/proxy/runStore.ts +0 -214
- package/src/proxy/runtimeAdmission.ts +0 -55
- package/src/proxy/runtimeHealth.ts +0 -221
- package/src/proxy/runtimeMetrics.ts +0 -149
- package/src/proxy/runtimeShutdown.ts +0 -157
- package/src/proxy/schemas.ts +0 -112
- package/src/proxy/sessionArchive.ts +0 -479
- package/src/proxy/sessionInfo.ts +0 -266
- package/src/proxy/sessionProcess.ts +0 -194
- package/src/proxy/sessionRuntime.ts +0 -121
- package/src/proxy/sessionSupervisor.ts +0 -305
- package/src/proxy/sessionWorkerEntry.ts +0 -26
- package/src/proxy/shutdownCoordinator.ts +0 -90
- package/src/proxy/socketTracker.ts +0 -639
- package/src/proxy/sqliteLogIndex.ts +0 -733
- package/src/proxy/storageLifecycle.ts +0 -432
- package/src/proxy/store.ts +0 -1773
- package/src/proxy/streamTiming.ts +0 -31
- package/src/proxy/toolSchemaWarnings.ts +0 -529
- package/src/proxy/uiAssetServer.ts +0 -106
- package/src/proxy/upstream.ts +0 -127
- package/src/services/alerts.ts +0 -12
- package/src/services/groups.ts +0 -119
- package/src/services/piAgent.ts +0 -421
- package/src/services/piAgentRetrieval.ts +0 -1180
- package/src/services/result.ts +0 -17
- package/src/services/runs.ts +0 -76
- package/src/ui/bootstrap.ts +0 -167
- package/src/ui/index.html +0 -38
- package/src/ui/logsStreamClient.ts +0 -20
- package/src/ui/main.tsx +0 -13
- package/src/ui/public/runtime-config.js +0 -2
- package/src/ui/router.tsx +0 -13
- package/src/ui/routes/__root.tsx +0 -69
- package/src/ui/routes/index.tsx +0 -35
- package/src/ui/routes/session/$sessionId.tsx +0 -50
- package/src/ui/runtimeDiscovery.ts +0 -50
|
@@ -1,342 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { basename } from "node:path";
|
|
3
|
-
import { getProvider, getModelUsageName } from "../../../proxy/providers";
|
|
4
|
-
import { addTestLogEntry } from "../../../proxy/store";
|
|
5
|
-
import { getConfig } from "../../../proxy/config";
|
|
6
|
-
import { buildProviderTestSessionId } from "../../../proxy/sessionSupervisor";
|
|
7
|
-
import { buildProviderTestRequestBody } from "../../../lib/providerTestPrompt";
|
|
8
|
-
import {
|
|
9
|
-
ProviderTestResultsSchema,
|
|
10
|
-
type ProviderModelTestResults,
|
|
11
|
-
type ProviderTestResult as TestResult,
|
|
12
|
-
type ProviderTestState,
|
|
13
|
-
} from "../../../lib/providerTestContract";
|
|
14
|
-
import { computeTokensPerSecond, firstChunkMsFromChunks } from "../../../proxy/streamTiming";
|
|
15
|
-
|
|
16
|
-
function hasSuccessField(result: ProviderTestState): result is TestResult {
|
|
17
|
-
return Object.prototype.hasOwnProperty.call(result, "success");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function getResultResponseStatus(result: TestResult): number {
|
|
21
|
-
if (result.debug?.responseStatus !== undefined) {
|
|
22
|
-
return result.debug.responseStatus;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return result.success ? 200 : 500;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function getResultResponseText(result: TestResult): string {
|
|
29
|
-
return result.rawResponse ?? result.debug?.responseBody ?? JSON.stringify(result);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function getResultHeaders(result: TestResult): Record<string, string> {
|
|
33
|
-
return result.requestHeaders ?? result.debug?.requestHeaders ?? {};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function getResultTotalStreamMs(result: TestResult): number | null {
|
|
37
|
-
return result.totalStreamMs ?? (result.streaming === true ? (result.latencyMs ?? null) : null);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function getResultFirstChunkMs(result: TestResult): number | null {
|
|
41
|
-
return result.firstChunkMs ?? firstChunkMsFromChunks(result.streamingChunks?.chunks);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getResultTokensPerSecond(result: TestResult): number | null {
|
|
45
|
-
return (
|
|
46
|
-
result.tokensPerSecond ??
|
|
47
|
-
computeTokensPerSecond({
|
|
48
|
-
outputTokens: result.outputTokens,
|
|
49
|
-
firstChunkMs: getResultFirstChunkMs(result),
|
|
50
|
-
totalStreamMs: getResultTotalStreamMs(result),
|
|
51
|
-
})
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function providerTestClientFields(providerName: string): {
|
|
56
|
-
userAgent: string;
|
|
57
|
-
origin: null;
|
|
58
|
-
isTest: true;
|
|
59
|
-
providerName: string;
|
|
60
|
-
clientPid: number;
|
|
61
|
-
clientCwd: string;
|
|
62
|
-
clientProjectFolder: string;
|
|
63
|
-
} {
|
|
64
|
-
const cwd = process.cwd();
|
|
65
|
-
return {
|
|
66
|
-
userAgent: "Agent Inspector Provider Test",
|
|
67
|
-
origin: null,
|
|
68
|
-
isTest: true,
|
|
69
|
-
providerName,
|
|
70
|
-
clientPid: process.pid,
|
|
71
|
-
clientCwd: cwd,
|
|
72
|
-
clientProjectFolder: basename(cwd),
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function logModelResults(
|
|
77
|
-
displayName: string,
|
|
78
|
-
providerName: string,
|
|
79
|
-
providerSessionId: string,
|
|
80
|
-
anthropicUrl: string | undefined,
|
|
81
|
-
openaiChatUrl: string | undefined,
|
|
82
|
-
openaiResponsesUrl: string | undefined,
|
|
83
|
-
modelResults: ProviderModelTestResults,
|
|
84
|
-
captureFullDetails: boolean,
|
|
85
|
-
): Promise<void> {
|
|
86
|
-
const usageModel = getModelUsageName(displayName, providerName);
|
|
87
|
-
|
|
88
|
-
if (anthropicUrl !== undefined) {
|
|
89
|
-
const nsResult = modelResults.anthropic.nonStreaming;
|
|
90
|
-
const sResult = modelResults.anthropic.streaming;
|
|
91
|
-
if (hasSuccessField(nsResult) && hasSuccessField(sResult)) {
|
|
92
|
-
const nonStreamingResult = nsResult;
|
|
93
|
-
const streamingResult = sResult;
|
|
94
|
-
|
|
95
|
-
const requestBody = JSON.stringify(buildProviderTestRequestBody(usageModel, "non-streaming"));
|
|
96
|
-
|
|
97
|
-
await addTestLogEntry({
|
|
98
|
-
timestamp: new Date().toISOString(),
|
|
99
|
-
method: "POST",
|
|
100
|
-
path: "/v1/messages",
|
|
101
|
-
model: nonStreamingResult.model ?? displayName,
|
|
102
|
-
sessionId: providerSessionId,
|
|
103
|
-
rawRequestBody: requestBody,
|
|
104
|
-
responseStatus: getResultResponseStatus(nonStreamingResult),
|
|
105
|
-
responseText: getResultResponseText(nonStreamingResult),
|
|
106
|
-
inputTokens: nonStreamingResult.inputTokens ?? null,
|
|
107
|
-
outputTokens: nonStreamingResult.outputTokens ?? null,
|
|
108
|
-
cacheCreationInputTokens: nonStreamingResult.cacheCreationInputTokens ?? null,
|
|
109
|
-
cacheReadInputTokens: nonStreamingResult.cacheReadInputTokens ?? null,
|
|
110
|
-
elapsedMs: nonStreamingResult.latencyMs ?? 0,
|
|
111
|
-
firstChunkMs: null,
|
|
112
|
-
totalStreamMs: null,
|
|
113
|
-
tokensPerSecond: null,
|
|
114
|
-
streaming: false,
|
|
115
|
-
apiFormat: "anthropic",
|
|
116
|
-
...providerTestClientFields(providerName),
|
|
117
|
-
headers: captureFullDetails ? getResultHeaders(nonStreamingResult) : undefined,
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
const streamingRequestBody = JSON.stringify(
|
|
121
|
-
buildProviderTestRequestBody(usageModel, "streaming"),
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
await addTestLogEntry({
|
|
125
|
-
timestamp: new Date().toISOString(),
|
|
126
|
-
method: "POST",
|
|
127
|
-
path: "/v1/messages",
|
|
128
|
-
model: streamingResult.model ?? displayName,
|
|
129
|
-
sessionId: providerSessionId,
|
|
130
|
-
rawRequestBody: streamingRequestBody,
|
|
131
|
-
responseStatus: getResultResponseStatus(streamingResult),
|
|
132
|
-
responseText: getResultResponseText(streamingResult),
|
|
133
|
-
inputTokens: streamingResult.inputTokens ?? null,
|
|
134
|
-
outputTokens: streamingResult.outputTokens ?? null,
|
|
135
|
-
cacheCreationInputTokens: streamingResult.cacheCreationInputTokens ?? null,
|
|
136
|
-
cacheReadInputTokens: streamingResult.cacheReadInputTokens ?? null,
|
|
137
|
-
elapsedMs: getResultTotalStreamMs(streamingResult) ?? 0,
|
|
138
|
-
firstChunkMs: getResultFirstChunkMs(streamingResult),
|
|
139
|
-
totalStreamMs: getResultTotalStreamMs(streamingResult),
|
|
140
|
-
tokensPerSecond: getResultTokensPerSecond(streamingResult),
|
|
141
|
-
streaming: true,
|
|
142
|
-
streamingChunks: captureFullDetails ? streamingResult.streamingChunks : undefined,
|
|
143
|
-
apiFormat: "anthropic",
|
|
144
|
-
...providerTestClientFields(providerName),
|
|
145
|
-
headers: captureFullDetails ? getResultHeaders(streamingResult) : undefined,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
if (openaiChatUrl !== undefined) {
|
|
151
|
-
const nsResult = modelResults.openaiChat.nonStreaming;
|
|
152
|
-
const sResult = modelResults.openaiChat.streaming;
|
|
153
|
-
if (hasSuccessField(nsResult) && hasSuccessField(sResult)) {
|
|
154
|
-
const nonStreamingResult = nsResult;
|
|
155
|
-
const streamingResult = sResult;
|
|
156
|
-
|
|
157
|
-
const requestBody = JSON.stringify(buildProviderTestRequestBody(usageModel, "non-streaming"));
|
|
158
|
-
|
|
159
|
-
await addTestLogEntry({
|
|
160
|
-
timestamp: new Date().toISOString(),
|
|
161
|
-
method: "POST",
|
|
162
|
-
path: "/v1/chat/completions",
|
|
163
|
-
model: nonStreamingResult.model ?? displayName,
|
|
164
|
-
sessionId: providerSessionId,
|
|
165
|
-
rawRequestBody: requestBody,
|
|
166
|
-
responseStatus: getResultResponseStatus(nonStreamingResult),
|
|
167
|
-
responseText: getResultResponseText(nonStreamingResult),
|
|
168
|
-
inputTokens: nonStreamingResult.inputTokens ?? null,
|
|
169
|
-
outputTokens: nonStreamingResult.outputTokens ?? null,
|
|
170
|
-
cacheCreationInputTokens: null,
|
|
171
|
-
cacheReadInputTokens: null,
|
|
172
|
-
elapsedMs: nonStreamingResult.latencyMs ?? 0,
|
|
173
|
-
firstChunkMs: null,
|
|
174
|
-
totalStreamMs: null,
|
|
175
|
-
tokensPerSecond: null,
|
|
176
|
-
streaming: false,
|
|
177
|
-
apiFormat: "openai",
|
|
178
|
-
...providerTestClientFields(providerName),
|
|
179
|
-
headers: captureFullDetails ? getResultHeaders(nonStreamingResult) : undefined,
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
const streamingRequestBody = JSON.stringify(
|
|
183
|
-
buildProviderTestRequestBody(usageModel, "streaming"),
|
|
184
|
-
);
|
|
185
|
-
|
|
186
|
-
await addTestLogEntry({
|
|
187
|
-
timestamp: new Date().toISOString(),
|
|
188
|
-
method: "POST",
|
|
189
|
-
path: "/v1/chat/completions",
|
|
190
|
-
model: streamingResult.model ?? displayName,
|
|
191
|
-
sessionId: providerSessionId,
|
|
192
|
-
rawRequestBody: streamingRequestBody,
|
|
193
|
-
responseStatus: getResultResponseStatus(streamingResult),
|
|
194
|
-
responseText: getResultResponseText(streamingResult),
|
|
195
|
-
inputTokens: streamingResult.inputTokens ?? null,
|
|
196
|
-
outputTokens: streamingResult.outputTokens ?? null,
|
|
197
|
-
cacheCreationInputTokens: null,
|
|
198
|
-
cacheReadInputTokens: null,
|
|
199
|
-
elapsedMs: getResultTotalStreamMs(streamingResult) ?? 0,
|
|
200
|
-
firstChunkMs: getResultFirstChunkMs(streamingResult),
|
|
201
|
-
totalStreamMs: getResultTotalStreamMs(streamingResult),
|
|
202
|
-
tokensPerSecond: getResultTokensPerSecond(streamingResult),
|
|
203
|
-
streaming: true,
|
|
204
|
-
streamingChunks: captureFullDetails ? streamingResult.streamingChunks : undefined,
|
|
205
|
-
apiFormat: "openai",
|
|
206
|
-
...providerTestClientFields(providerName),
|
|
207
|
-
headers: captureFullDetails ? getResultHeaders(streamingResult) : undefined,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if (openaiResponsesUrl !== undefined) {
|
|
213
|
-
const nsResult = modelResults.openaiResponses.nonStreaming;
|
|
214
|
-
const sResult = modelResults.openaiResponses.streaming;
|
|
215
|
-
if (hasSuccessField(nsResult) && hasSuccessField(sResult)) {
|
|
216
|
-
const nonStreamingResult = nsResult;
|
|
217
|
-
const streamingResult = sResult;
|
|
218
|
-
|
|
219
|
-
const requestBody = JSON.stringify(
|
|
220
|
-
buildProviderTestRequestBody(usageModel, "non-streaming", "responses"),
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
await addTestLogEntry({
|
|
224
|
-
timestamp: new Date().toISOString(),
|
|
225
|
-
method: "POST",
|
|
226
|
-
path: "/v1/responses",
|
|
227
|
-
model: nonStreamingResult.model ?? displayName,
|
|
228
|
-
sessionId: providerSessionId,
|
|
229
|
-
rawRequestBody: requestBody,
|
|
230
|
-
responseStatus: getResultResponseStatus(nonStreamingResult),
|
|
231
|
-
responseText: getResultResponseText(nonStreamingResult),
|
|
232
|
-
inputTokens: nonStreamingResult.inputTokens ?? null,
|
|
233
|
-
outputTokens: nonStreamingResult.outputTokens ?? null,
|
|
234
|
-
cacheCreationInputTokens: null,
|
|
235
|
-
cacheReadInputTokens: nonStreamingResult.cacheReadInputTokens ?? null,
|
|
236
|
-
elapsedMs: nonStreamingResult.latencyMs ?? 0,
|
|
237
|
-
firstChunkMs: null,
|
|
238
|
-
totalStreamMs: null,
|
|
239
|
-
tokensPerSecond: null,
|
|
240
|
-
streaming: false,
|
|
241
|
-
apiFormat: "openai",
|
|
242
|
-
...providerTestClientFields(providerName),
|
|
243
|
-
headers: captureFullDetails ? getResultHeaders(nonStreamingResult) : undefined,
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
const streamingRequestBody = JSON.stringify(
|
|
247
|
-
buildProviderTestRequestBody(usageModel, "streaming", "responses"),
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
await addTestLogEntry({
|
|
251
|
-
timestamp: new Date().toISOString(),
|
|
252
|
-
method: "POST",
|
|
253
|
-
path: "/v1/responses",
|
|
254
|
-
model: streamingResult.model ?? displayName,
|
|
255
|
-
sessionId: providerSessionId,
|
|
256
|
-
rawRequestBody: streamingRequestBody,
|
|
257
|
-
responseStatus: getResultResponseStatus(streamingResult),
|
|
258
|
-
responseText: getResultResponseText(streamingResult),
|
|
259
|
-
inputTokens: streamingResult.inputTokens ?? null,
|
|
260
|
-
outputTokens: streamingResult.outputTokens ?? null,
|
|
261
|
-
cacheCreationInputTokens: null,
|
|
262
|
-
cacheReadInputTokens: streamingResult.cacheReadInputTokens ?? null,
|
|
263
|
-
elapsedMs: getResultTotalStreamMs(streamingResult) ?? 0,
|
|
264
|
-
firstChunkMs: getResultFirstChunkMs(streamingResult),
|
|
265
|
-
totalStreamMs: getResultTotalStreamMs(streamingResult),
|
|
266
|
-
tokensPerSecond: getResultTokensPerSecond(streamingResult),
|
|
267
|
-
streaming: true,
|
|
268
|
-
streamingChunks: captureFullDetails ? streamingResult.streamingChunks : undefined,
|
|
269
|
-
apiFormat: "openai",
|
|
270
|
-
...providerTestClientFields(providerName),
|
|
271
|
-
headers: captureFullDetails ? getResultHeaders(streamingResult) : undefined,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export const Route = createFileRoute("/api/providers/$providerId/test/log")({
|
|
278
|
-
server: {
|
|
279
|
-
handlers: {
|
|
280
|
-
POST: async ({ params, request }: { params: { providerId: string }; request: Request }) => {
|
|
281
|
-
const provider = getProvider(params.providerId);
|
|
282
|
-
if (!provider) {
|
|
283
|
-
return Response.json({ error: "Provider not found" }, { status: 404 });
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
let body: unknown;
|
|
287
|
-
try {
|
|
288
|
-
body = await request.json();
|
|
289
|
-
} catch {
|
|
290
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
const parsed = ProviderTestResultsSchema.safeParse(body);
|
|
294
|
-
if (!parsed.success) {
|
|
295
|
-
return Response.json(
|
|
296
|
-
{ error: `Invalid test results: ${parsed.error.message}` },
|
|
297
|
-
{ status: 400 },
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
const results = parsed.data;
|
|
302
|
-
const providerSessionId = buildProviderTestSessionId(params.providerId);
|
|
303
|
-
const captureFullDetails = getConfig().captureMode === "full";
|
|
304
|
-
const anthropicUrl =
|
|
305
|
-
provider.anthropicBaseUrl !== undefined && provider.anthropicBaseUrl.length > 0
|
|
306
|
-
? provider.anthropicBaseUrl
|
|
307
|
-
: undefined;
|
|
308
|
-
const openaiChatUrl =
|
|
309
|
-
provider.openaiBaseUrl !== undefined && provider.openaiBaseUrl.length > 0
|
|
310
|
-
? provider.openaiBaseUrl
|
|
311
|
-
: undefined;
|
|
312
|
-
const openaiResponsesUrl =
|
|
313
|
-
provider.openaiResponsesBaseUrl !== undefined &&
|
|
314
|
-
provider.openaiResponsesBaseUrl.length > 0
|
|
315
|
-
? provider.openaiResponsesBaseUrl
|
|
316
|
-
: undefined;
|
|
317
|
-
|
|
318
|
-
const entries: Promise<void>[] = [];
|
|
319
|
-
if (results.models !== undefined) {
|
|
320
|
-
for (const [modelName, modelResult] of Object.entries(results.models)) {
|
|
321
|
-
entries.push(
|
|
322
|
-
logModelResults(
|
|
323
|
-
modelName,
|
|
324
|
-
provider.name,
|
|
325
|
-
providerSessionId,
|
|
326
|
-
anthropicUrl,
|
|
327
|
-
openaiChatUrl,
|
|
328
|
-
openaiResponsesUrl,
|
|
329
|
-
modelResult,
|
|
330
|
-
captureFullDetails,
|
|
331
|
-
),
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
await Promise.all(entries);
|
|
337
|
-
|
|
338
|
-
return Response.json({ logged: entries.length });
|
|
339
|
-
},
|
|
340
|
-
},
|
|
341
|
-
},
|
|
342
|
-
});
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
getProviders,
|
|
5
|
-
updateProvider,
|
|
6
|
-
deleteProvider,
|
|
7
|
-
redactProvider,
|
|
8
|
-
} from "../../../proxy/providers";
|
|
9
|
-
import {
|
|
10
|
-
getProviderModelLimitViolation,
|
|
11
|
-
ProviderModelMetadataListSchema,
|
|
12
|
-
ProviderModelNameSchema,
|
|
13
|
-
ProviderModelsSchema,
|
|
14
|
-
} from "../../../lib/providerContract";
|
|
15
|
-
import { evaluateUpstreamUrl } from "../../../lib/ssrfGuard";
|
|
16
|
-
import { resourceLimitResponse } from "../../../lib/resourceLimits";
|
|
17
|
-
|
|
18
|
-
const ALLOW_LOOPBACK = process.env["AGENT_INSPECTOR_ALLOW_LOOPBACK"] === "1";
|
|
19
|
-
|
|
20
|
-
const ProviderUpdateSchema = z.object({
|
|
21
|
-
name: z.string().min(1, "Name is required").optional(),
|
|
22
|
-
apiKey: z.string().min(1, "API key is required").optional(),
|
|
23
|
-
format: z.enum(["anthropic", "openai"]).optional(),
|
|
24
|
-
baseUrl: z.string().min(1, "Base URL is required").optional(),
|
|
25
|
-
model: ProviderModelNameSchema.optional(),
|
|
26
|
-
models: ProviderModelsSchema.optional(),
|
|
27
|
-
authHeader: z.enum(["bearer", "x-api-key"]).optional(),
|
|
28
|
-
anthropicBaseUrl: z.string().optional(),
|
|
29
|
-
openaiBaseUrl: z.string().optional(),
|
|
30
|
-
openaiResponsesBaseUrl: z.string().optional(),
|
|
31
|
-
apiDocsUrl: z.string().optional(),
|
|
32
|
-
modelMetadataUrl: z.string().optional(),
|
|
33
|
-
modelMetadata: ProviderModelMetadataListSchema.optional(),
|
|
34
|
-
source: z.enum(["company", "personal"]).optional(),
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export const Route = createFileRoute("/api/providers/$providerId")({
|
|
38
|
-
server: {
|
|
39
|
-
handlers: {
|
|
40
|
-
GET: ({ params }: { params: { providerId: string } }) => {
|
|
41
|
-
const providers = getProviders();
|
|
42
|
-
const provider = providers.find((p) => p.id === params.providerId);
|
|
43
|
-
if (!provider) {
|
|
44
|
-
return Response.json({ error: "Provider not found" }, { status: 404 });
|
|
45
|
-
}
|
|
46
|
-
return Response.json(redactProvider(provider));
|
|
47
|
-
},
|
|
48
|
-
PUT: async ({ params, request }: { params: { providerId: string }; request: Request }) => {
|
|
49
|
-
let body: unknown;
|
|
50
|
-
try {
|
|
51
|
-
body = await request.json();
|
|
52
|
-
} catch {
|
|
53
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const violation = getProviderModelLimitViolation(body);
|
|
57
|
-
if (violation !== null) {
|
|
58
|
-
return resourceLimitResponse({
|
|
59
|
-
error: `Provider model collections may contain at most ${String(violation.limit)} entries.`,
|
|
60
|
-
code: "provider-model-limit-exceeded",
|
|
61
|
-
status: 413,
|
|
62
|
-
resource: violation.resource,
|
|
63
|
-
limit: violation.limit,
|
|
64
|
-
retryable: false,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const parsed = ProviderUpdateSchema.safeParse(body);
|
|
69
|
-
if (!parsed.success) {
|
|
70
|
-
return Response.json({ error: parsed.error.message }, { status: 400 });
|
|
71
|
-
}
|
|
72
|
-
for (const candidate of [
|
|
73
|
-
parsed.data.baseUrl,
|
|
74
|
-
parsed.data.anthropicBaseUrl,
|
|
75
|
-
parsed.data.openaiBaseUrl,
|
|
76
|
-
parsed.data.openaiResponsesBaseUrl,
|
|
77
|
-
]) {
|
|
78
|
-
if (candidate === undefined || candidate === "") continue;
|
|
79
|
-
const decision = evaluateUpstreamUrl(candidate, { allowLoopback: ALLOW_LOOPBACK });
|
|
80
|
-
if (!decision.allow) {
|
|
81
|
-
return Response.json({ error: decision.reason }, { status: 400 });
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const providerExists = getProviders().some((provider) => provider.id === params.providerId);
|
|
85
|
-
const updated = updateProvider(params.providerId, parsed.data);
|
|
86
|
-
if (!updated) {
|
|
87
|
-
return providerExists
|
|
88
|
-
? Response.json(
|
|
89
|
-
{ error: "Secure provider storage is unavailable; provider was not updated" },
|
|
90
|
-
{ status: 503 },
|
|
91
|
-
)
|
|
92
|
-
: Response.json({ error: "Provider not found" }, { status: 404 });
|
|
93
|
-
}
|
|
94
|
-
return Response.json(redactProvider(updated));
|
|
95
|
-
},
|
|
96
|
-
DELETE: ({ params }: { params: { providerId: string } }) => {
|
|
97
|
-
const providerExists = getProviders().some((provider) => provider.id === params.providerId);
|
|
98
|
-
const deleted = deleteProvider(params.providerId);
|
|
99
|
-
if (!deleted) {
|
|
100
|
-
return providerExists
|
|
101
|
-
? Response.json(
|
|
102
|
-
{ error: "Secure provider storage is unavailable; provider was not deleted" },
|
|
103
|
-
{ status: 503 },
|
|
104
|
-
)
|
|
105
|
-
: Response.json({ error: "Provider not found" }, { status: 404 });
|
|
106
|
-
}
|
|
107
|
-
return Response.json({ success: true });
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { exportProviders, exportProvidersWithKeys } from "../../../proxy/providers";
|
|
4
|
-
|
|
5
|
-
const SecretExportRequestSchema = z.object({
|
|
6
|
-
confirmation: z.literal("EXPORT_PROVIDER_KEYS"),
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
function exportResponse(json: string, filename: string): Response {
|
|
10
|
-
return new Response(json, {
|
|
11
|
-
headers: {
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
"Content-Disposition": `attachment; filename="${filename}"`,
|
|
14
|
-
"Cache-Control": "no-store",
|
|
15
|
-
},
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const Route = createFileRoute("/api/providers/export")({
|
|
20
|
-
server: {
|
|
21
|
-
handlers: {
|
|
22
|
-
GET: () => {
|
|
23
|
-
return exportResponse(
|
|
24
|
-
exportProviders(),
|
|
25
|
-
`agent-inspector-providers-safe-${Date.now()}.json`,
|
|
26
|
-
);
|
|
27
|
-
},
|
|
28
|
-
POST: async ({ request }: { request: Request }) => {
|
|
29
|
-
const body: unknown = await request.json().catch(() => null);
|
|
30
|
-
const parsed = SecretExportRequestSchema.safeParse(body);
|
|
31
|
-
if (!parsed.success) {
|
|
32
|
-
return Response.json(
|
|
33
|
-
{ error: "Plaintext key export requires explicit confirmation" },
|
|
34
|
-
{ status: 400, headers: { "Cache-Control": "no-store" } },
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
return exportResponse(
|
|
38
|
-
exportProvidersWithKeys(),
|
|
39
|
-
`agent-inspector-providers-sensitive-${Date.now()}.json`,
|
|
40
|
-
);
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { randomUUID } from "node:crypto";
|
|
4
|
-
import { ProviderScanImportRequestSchema } from "../../../lib/providerImportContract";
|
|
5
|
-
import { consumeProviderScan } from "../../../proxy/providerScanStore";
|
|
6
|
-
import { importProviders } from "../../../proxy/providers";
|
|
7
|
-
|
|
8
|
-
const ProviderFileImportSchema = z.union([z.string(), z.object({ providers: z.unknown() })]);
|
|
9
|
-
|
|
10
|
-
export const Route = createFileRoute("/api/providers/import")({
|
|
11
|
-
server: {
|
|
12
|
-
handlers: {
|
|
13
|
-
POST: async ({ request }: { request: Request }) => {
|
|
14
|
-
try {
|
|
15
|
-
const rawBody = await request.text();
|
|
16
|
-
let jsonContent: string;
|
|
17
|
-
try {
|
|
18
|
-
const parsedBody: unknown = JSON.parse(rawBody);
|
|
19
|
-
const scanRequest = ProviderScanImportRequestSchema.safeParse(parsedBody);
|
|
20
|
-
if (scanRequest.success) {
|
|
21
|
-
const selected = consumeProviderScan(
|
|
22
|
-
scanRequest.data.scanId,
|
|
23
|
-
scanRequest.data.selectionIds,
|
|
24
|
-
);
|
|
25
|
-
if (selected === null) {
|
|
26
|
-
return Response.json(
|
|
27
|
-
{ error: "Provider scan expired or selection is invalid" },
|
|
28
|
-
{ status: 410, headers: { "cache-control": "no-store" } },
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
const now = new Date().toISOString();
|
|
32
|
-
jsonContent = JSON.stringify({
|
|
33
|
-
providers: selected.map((provider) => ({
|
|
34
|
-
id: randomUUID(),
|
|
35
|
-
name: provider.name,
|
|
36
|
-
apiKey: provider.apiKey,
|
|
37
|
-
format: provider.format,
|
|
38
|
-
anthropicBaseUrl: provider.anthropicBaseUrl,
|
|
39
|
-
openaiBaseUrl: provider.openaiBaseUrl,
|
|
40
|
-
openaiResponsesBaseUrl: provider.openaiResponsesBaseUrl,
|
|
41
|
-
models: provider.models,
|
|
42
|
-
createdAt: now,
|
|
43
|
-
updatedAt: now,
|
|
44
|
-
})),
|
|
45
|
-
});
|
|
46
|
-
} else {
|
|
47
|
-
const fileImport = ProviderFileImportSchema.safeParse(parsedBody);
|
|
48
|
-
jsonContent = fileImport.success
|
|
49
|
-
? typeof fileImport.data === "string"
|
|
50
|
-
? fileImport.data
|
|
51
|
-
: JSON.stringify(fileImport.data)
|
|
52
|
-
: rawBody;
|
|
53
|
-
}
|
|
54
|
-
} catch {
|
|
55
|
-
jsonContent = rawBody;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (jsonContent.trim() === "") {
|
|
59
|
-
return Response.json({ error: "No JSON content provided" }, { status: 400 });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const result = importProviders(jsonContent);
|
|
63
|
-
|
|
64
|
-
return Response.json({
|
|
65
|
-
success: result.imported > 0,
|
|
66
|
-
imported: result.imported,
|
|
67
|
-
errors: result.errors,
|
|
68
|
-
message:
|
|
69
|
-
result.imported > 0
|
|
70
|
-
? `Successfully imported ${result.imported} provider(s)`
|
|
71
|
-
: result.errors.length > 0
|
|
72
|
-
? `Import completed with ${result.errors.length} error(s)`
|
|
73
|
-
: "No providers imported",
|
|
74
|
-
});
|
|
75
|
-
} catch {
|
|
76
|
-
return Response.json({ error: "Provider import failed" }, { status: 400 });
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
});
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { scanExternalProviders } from "../../../proxy/providerImporters";
|
|
3
|
-
import { createProviderScan } from "../../../proxy/providerScanStore";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/api/providers/scan")({
|
|
6
|
-
server: {
|
|
7
|
-
handlers: {
|
|
8
|
-
POST: () => {
|
|
9
|
-
try {
|
|
10
|
-
const result = scanExternalProviders();
|
|
11
|
-
const scan = createProviderScan(result.providers);
|
|
12
|
-
return Response.json(
|
|
13
|
-
{
|
|
14
|
-
scanId: scan.scanId,
|
|
15
|
-
providers: scan.providers,
|
|
16
|
-
warnings: result.warnings,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
headers: { "cache-control": "no-store" },
|
|
20
|
-
},
|
|
21
|
-
);
|
|
22
|
-
} catch {
|
|
23
|
-
return Response.json({ error: "Provider scan failed" }, { status: 500 });
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
});
|