@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,239 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { BackendImplementationSchema } from "./backendImplementation";
|
|
3
|
-
import { normalizePublicBasePath } from "./basePath";
|
|
4
|
-
|
|
5
|
-
export const INSTANCE_API_SCHEMA_VERSION = 1;
|
|
6
|
-
|
|
7
|
-
function isCanonicalPublicBasePath(value: string): boolean {
|
|
8
|
-
const normalized = normalizePublicBasePath(value);
|
|
9
|
-
return normalized !== null && (normalized.length === 0 ? "/" : normalized) === value;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const InstanceStateSchema = z.enum(["running", "stopped", "conflict"]);
|
|
13
|
-
export const InstanceStateReasonSchema = z.enum(["identity_mismatch", "port_conflict"]);
|
|
14
|
-
|
|
15
|
-
export const InstanceUrlsSchema = z
|
|
16
|
-
.object({
|
|
17
|
-
ui: z.url(),
|
|
18
|
-
api: z.url(),
|
|
19
|
-
health: z.url(),
|
|
20
|
-
proxy: z.url(),
|
|
21
|
-
openai: z.url(),
|
|
22
|
-
mcp: z.url(),
|
|
23
|
-
})
|
|
24
|
-
.strict();
|
|
25
|
-
|
|
26
|
-
export const InstanceStatusOutputSchema = z
|
|
27
|
-
.object({
|
|
28
|
-
schemaVersion: z.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
29
|
-
name: z.string().min(1),
|
|
30
|
-
instanceId: z.string().min(1),
|
|
31
|
-
state: InstanceStateSchema,
|
|
32
|
-
stateReason: InstanceStateReasonSchema.nullable(),
|
|
33
|
-
checkedAt: z.iso.datetime(),
|
|
34
|
-
createdAt: z.iso.datetime(),
|
|
35
|
-
updatedAt: z.iso.datetime(),
|
|
36
|
-
launch: z
|
|
37
|
-
.object({
|
|
38
|
-
launchId: z.string().min(1),
|
|
39
|
-
startedAt: z.iso.datetime(),
|
|
40
|
-
})
|
|
41
|
-
.strict(),
|
|
42
|
-
host: z.string().min(1),
|
|
43
|
-
publicPort: z.number().int().min(1).max(65_535),
|
|
44
|
-
upstreamPort: z.number().int().min(1).max(65_535),
|
|
45
|
-
basePath: z.string().refine(isCanonicalPublicBasePath, "Invalid public Base Path"),
|
|
46
|
-
captureMode: z.enum(["simple", "full"]),
|
|
47
|
-
backend: BackendImplementationSchema.default("typescript"),
|
|
48
|
-
uiEnabled: z.boolean(),
|
|
49
|
-
dataDir: z.string().min(1),
|
|
50
|
-
supervisorPid: z.number().int().positive().nullable(),
|
|
51
|
-
urls: InstanceUrlsSchema,
|
|
52
|
-
})
|
|
53
|
-
.strict();
|
|
54
|
-
|
|
55
|
-
export const InstanceConnectionSurfacesSchema = z
|
|
56
|
-
.object({
|
|
57
|
-
ui: z
|
|
58
|
-
.object({
|
|
59
|
-
enabled: z.boolean(),
|
|
60
|
-
baseUrl: z.url().nullable(),
|
|
61
|
-
})
|
|
62
|
-
.strict(),
|
|
63
|
-
control: z.object({ baseUrl: z.url() }).strict(),
|
|
64
|
-
agent: z.object({ baseUrl: z.url() }).strict(),
|
|
65
|
-
})
|
|
66
|
-
.strict();
|
|
67
|
-
|
|
68
|
-
export const InstanceConnectionOutputSchema = z
|
|
69
|
-
.object({
|
|
70
|
-
schemaVersion: z.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
71
|
-
uiEnabled: z.boolean(),
|
|
72
|
-
instance: InstanceStatusOutputSchema,
|
|
73
|
-
surfaces: InstanceConnectionSurfacesSchema,
|
|
74
|
-
/** @deprecated Use surfaces.control.baseUrl or surfaces.agent.baseUrl. */
|
|
75
|
-
baseUrl: z.url(),
|
|
76
|
-
endpoints: InstanceUrlsSchema,
|
|
77
|
-
environment: z
|
|
78
|
-
.object({
|
|
79
|
-
ANTHROPIC_BASE_URL: z.url(),
|
|
80
|
-
LLM_BASE_URL: z.url(),
|
|
81
|
-
OPENAI_BASE_URL: z.url(),
|
|
82
|
-
AGENT_INSPECTOR_MCP_URL: z.url(),
|
|
83
|
-
})
|
|
84
|
-
.strict(),
|
|
85
|
-
mcp: z
|
|
86
|
-
.object({
|
|
87
|
-
serverName: z.string().min(1),
|
|
88
|
-
transport: z.literal("streamable-http"),
|
|
89
|
-
url: z.url(),
|
|
90
|
-
})
|
|
91
|
-
.strict(),
|
|
92
|
-
codex: z
|
|
93
|
-
.object({
|
|
94
|
-
providerName: z.string().min(1),
|
|
95
|
-
baseUrl: z.url(),
|
|
96
|
-
wireApi: z.literal("responses"),
|
|
97
|
-
})
|
|
98
|
-
.strict(),
|
|
99
|
-
})
|
|
100
|
-
.strict();
|
|
101
|
-
|
|
102
|
-
export const InstanceStartRequestSchema = z
|
|
103
|
-
.object({
|
|
104
|
-
port: z.number().int().min(1).max(65_535).optional(),
|
|
105
|
-
basePath: z
|
|
106
|
-
.string()
|
|
107
|
-
.min(1)
|
|
108
|
-
.max(2_048)
|
|
109
|
-
.refine(
|
|
110
|
-
(value) => normalizePublicBasePath(value) !== null,
|
|
111
|
-
"Base Path must use URL-safe path segments without traversal, encoded separators, or markup characters",
|
|
112
|
-
)
|
|
113
|
-
.optional(),
|
|
114
|
-
host: z
|
|
115
|
-
.string()
|
|
116
|
-
.min(1)
|
|
117
|
-
.max(253)
|
|
118
|
-
.refine(
|
|
119
|
-
(value) =>
|
|
120
|
-
value.trim() === value &&
|
|
121
|
-
!value.includes("://") &&
|
|
122
|
-
!value.includes("/") &&
|
|
123
|
-
!value.includes("\\") &&
|
|
124
|
-
!/\s/u.test(value),
|
|
125
|
-
"Host must be a hostname or IP address without protocol, path, or whitespace",
|
|
126
|
-
)
|
|
127
|
-
.optional(),
|
|
128
|
-
captureMode: z.enum(["simple", "full"]).optional(),
|
|
129
|
-
backend: BackendImplementationSchema.optional(),
|
|
130
|
-
uiEnabled: z.boolean().optional(),
|
|
131
|
-
dataDir: z.string().trim().min(1).max(32_767).optional(),
|
|
132
|
-
})
|
|
133
|
-
.strict();
|
|
134
|
-
|
|
135
|
-
export const InstanceEmptyRequestSchema = z.object({}).strict();
|
|
136
|
-
|
|
137
|
-
export const InstanceOperationSchema = z.enum(["start", "stop", "restart"]);
|
|
138
|
-
export const InstanceOperationOutcomeSchema = z.enum([
|
|
139
|
-
"created",
|
|
140
|
-
"started",
|
|
141
|
-
"already_running",
|
|
142
|
-
"stopped",
|
|
143
|
-
"already_stopped",
|
|
144
|
-
"restarted",
|
|
145
|
-
]);
|
|
146
|
-
|
|
147
|
-
export const InstanceOperationOutputSchema = z
|
|
148
|
-
.object({
|
|
149
|
-
schemaVersion: z.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
150
|
-
operation: InstanceOperationSchema,
|
|
151
|
-
outcome: InstanceOperationOutcomeSchema,
|
|
152
|
-
instance: InstanceStatusOutputSchema,
|
|
153
|
-
})
|
|
154
|
-
.strict();
|
|
155
|
-
|
|
156
|
-
export const InstanceListOutputSchema = z
|
|
157
|
-
.object({
|
|
158
|
-
schemaVersion: z.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
159
|
-
instances: z.array(InstanceStatusOutputSchema),
|
|
160
|
-
})
|
|
161
|
-
.strict();
|
|
162
|
-
|
|
163
|
-
export const InstancePublicErrorCodeSchema = z.enum([
|
|
164
|
-
"argument_invalid",
|
|
165
|
-
"config_mismatch",
|
|
166
|
-
"data_dir_conflict",
|
|
167
|
-
"data_dir_invalid",
|
|
168
|
-
"identity_mismatch",
|
|
169
|
-
"instance_not_found",
|
|
170
|
-
"launch_failed",
|
|
171
|
-
"launch_unavailable",
|
|
172
|
-
"lock_not_owned",
|
|
173
|
-
"lock_timeout",
|
|
174
|
-
"name_invalid",
|
|
175
|
-
"port_conflict",
|
|
176
|
-
"port_exhausted",
|
|
177
|
-
"port_invalid",
|
|
178
|
-
"record_invalid",
|
|
179
|
-
"registry_io",
|
|
180
|
-
"restart_failed_degraded",
|
|
181
|
-
"restart_failed_rolled_back",
|
|
182
|
-
"self_lifecycle_unsupported",
|
|
183
|
-
"shutdown_failed",
|
|
184
|
-
]);
|
|
185
|
-
|
|
186
|
-
export const InstancePublicErrorSchema = z
|
|
187
|
-
.object({
|
|
188
|
-
code: InstancePublicErrorCodeSchema,
|
|
189
|
-
message: z.string().min(1),
|
|
190
|
-
retryable: z.boolean(),
|
|
191
|
-
})
|
|
192
|
-
.strict();
|
|
193
|
-
|
|
194
|
-
export const InstanceErrorOutputSchema = z
|
|
195
|
-
.object({
|
|
196
|
-
schemaVersion: z.literal(INSTANCE_API_SCHEMA_VERSION),
|
|
197
|
-
error: InstancePublicErrorSchema,
|
|
198
|
-
})
|
|
199
|
-
.strict();
|
|
200
|
-
|
|
201
|
-
export type InstanceStatusOutput = z.infer<typeof InstanceStatusOutputSchema>;
|
|
202
|
-
export type InstanceConnectionOutput = z.infer<typeof InstanceConnectionOutputSchema>;
|
|
203
|
-
export type InstanceStartRequest = z.infer<typeof InstanceStartRequestSchema>;
|
|
204
|
-
export type InstanceOperationOutcome = z.infer<typeof InstanceOperationOutcomeSchema>;
|
|
205
|
-
export type InstanceOperationOutput = z.infer<typeof InstanceOperationOutputSchema>;
|
|
206
|
-
export type InstancePublicErrorCode = z.infer<typeof InstancePublicErrorCodeSchema>;
|
|
207
|
-
export type InstancePublicError = z.infer<typeof InstancePublicErrorSchema>;
|
|
208
|
-
export type InstanceErrorOutput = z.infer<typeof InstanceErrorOutputSchema>;
|
|
209
|
-
|
|
210
|
-
export function isRetryableInstanceError(code: InstancePublicErrorCode): boolean {
|
|
211
|
-
switch (code) {
|
|
212
|
-
case "launch_failed":
|
|
213
|
-
case "launch_unavailable":
|
|
214
|
-
case "lock_timeout":
|
|
215
|
-
case "port_exhausted":
|
|
216
|
-
case "registry_io":
|
|
217
|
-
case "restart_failed_degraded":
|
|
218
|
-
case "restart_failed_rolled_back":
|
|
219
|
-
case "shutdown_failed":
|
|
220
|
-
return true;
|
|
221
|
-
case "argument_invalid":
|
|
222
|
-
case "config_mismatch":
|
|
223
|
-
case "data_dir_conflict":
|
|
224
|
-
case "data_dir_invalid":
|
|
225
|
-
case "identity_mismatch":
|
|
226
|
-
case "instance_not_found":
|
|
227
|
-
case "lock_not_owned":
|
|
228
|
-
case "name_invalid":
|
|
229
|
-
case "port_conflict":
|
|
230
|
-
case "port_invalid":
|
|
231
|
-
case "record_invalid":
|
|
232
|
-
case "self_lifecycle_unsupported":
|
|
233
|
-
return false;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
export function instanceErrorOutput(error: InstancePublicError): InstanceErrorOutput {
|
|
238
|
-
return { schemaVersion: INSTANCE_API_SCHEMA_VERSION, error };
|
|
239
|
-
}
|
package/src/lib/jsonFile.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { readProperty } from "./unknown";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Reads a UTF-8 JSON file from disk and validates it against a Zod schema in
|
|
7
|
-
* one call. Used by config/secret/evidence files that store small records
|
|
8
|
-
* atomically rewritten on update — *not* for streaming log files (those go
|
|
9
|
-
* through line-by-line parsing in store.ts).
|
|
10
|
-
*
|
|
11
|
-
* On any failure returns `{ ok: false, reason }` rather than throwing. The
|
|
12
|
-
* caller decides between returning a fallback, logging, or surfacing an
|
|
13
|
-
* error response. To log on failure, wrap the call site with the project's
|
|
14
|
-
* `logger.warn` (the helper stays a pure parser to avoid a `lib → proxy`
|
|
15
|
-
* dependency direction).
|
|
16
|
-
*/
|
|
17
|
-
export type ReadJsonFileFailureReason = "missing" | "io-error" | "parse-error" | "schema-mismatch";
|
|
18
|
-
|
|
19
|
-
export type ReadJsonFileResult<T> =
|
|
20
|
-
| { ok: true; data: T }
|
|
21
|
-
| { ok: false; reason: ReadJsonFileFailureReason };
|
|
22
|
-
|
|
23
|
-
export function readJsonFile<T>(path: string, schema: z.ZodType<T>): ReadJsonFileResult<T> {
|
|
24
|
-
let raw: string;
|
|
25
|
-
try {
|
|
26
|
-
raw = readFileSync(path, "utf8");
|
|
27
|
-
} catch (error) {
|
|
28
|
-
if (isEnoent(error)) return { ok: false, reason: "missing" };
|
|
29
|
-
return { ok: false, reason: "io-error" };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
let parsed: unknown;
|
|
33
|
-
try {
|
|
34
|
-
parsed = JSON.parse(raw);
|
|
35
|
-
} catch {
|
|
36
|
-
return { ok: false, reason: "parse-error" };
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const result = schema.safeParse(parsed);
|
|
40
|
-
if (!result.success) return { ok: false, reason: "schema-mismatch" };
|
|
41
|
-
return { ok: true, data: result.data };
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isEnoent(error: unknown): boolean {
|
|
45
|
-
return readProperty(error, "code") === "ENOENT";
|
|
46
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { CapturedLogSchema } from "../contracts";
|
|
3
|
-
|
|
4
|
-
export const ImportLogsResponseSchema = z.object({
|
|
5
|
-
sessionId: z.string(),
|
|
6
|
-
imported: z.number().int().nonnegative(),
|
|
7
|
-
skipped: z.number().int().nonnegative(),
|
|
8
|
-
warnings: z.array(z.string()),
|
|
9
|
-
logs: z.array(CapturedLogSchema),
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export type ImportLogsResponse = z.infer<typeof ImportLogsResponseSchema>;
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
export const MANAGED_INSTANCE_CONTROL_PATH = "/.agent-inspector/instance";
|
|
2
|
-
export const MANAGED_INSTANCE_SHUTDOWN_PATH = `${MANAGED_INSTANCE_CONTROL_PATH}/shutdown`;
|
|
3
|
-
export const MANAGED_INSTANCE_TOKEN_HEADER = "x-agent-inspector-instance-token";
|
|
4
|
-
export const MANAGED_INSTANCE_SHUTDOWN_MESSAGE_TYPE = "agent-inspector:managed-shutdown";
|
|
5
|
-
export const AGENT_INSPECTOR_CLI_ENTRY_ENV = "AGENT_INSPECTOR_CLI_ENTRY";
|
|
6
|
-
|
|
7
|
-
export const MANAGED_INSTANCE_ENV = {
|
|
8
|
-
backend: "AGENT_INSPECTOR_INSTANCE_BACKEND",
|
|
9
|
-
name: "AGENT_INSPECTOR_INSTANCE_NAME",
|
|
10
|
-
instanceId: "AGENT_INSPECTOR_INSTANCE_ID",
|
|
11
|
-
launchId: "AGENT_INSPECTOR_INSTANCE_LAUNCH_ID",
|
|
12
|
-
controlToken: "AGENT_INSPECTOR_INSTANCE_CONTROL_TOKEN",
|
|
13
|
-
startedAt: "AGENT_INSPECTOR_INSTANCE_STARTED_AT",
|
|
14
|
-
upstreamPort: "AGENT_INSPECTOR_UPSTREAM_PORT",
|
|
15
|
-
} as const;
|
|
16
|
-
|
|
17
|
-
type ManagedInstanceEnv = Readonly<Record<string, string | undefined>>;
|
|
18
|
-
|
|
19
|
-
export type ManagedInstanceLaunch = {
|
|
20
|
-
backend: BackendImplementation;
|
|
21
|
-
name: string;
|
|
22
|
-
instanceId: string;
|
|
23
|
-
launchId: string;
|
|
24
|
-
controlToken: string;
|
|
25
|
-
startedAt: string;
|
|
26
|
-
upstreamPort: number;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export type ManagedInstanceLaunchResult =
|
|
30
|
-
| { kind: "unmanaged" }
|
|
31
|
-
| { kind: "invalid"; message: string }
|
|
32
|
-
| { kind: "managed"; launch: ManagedInstanceLaunch };
|
|
33
|
-
|
|
34
|
-
export type ManagedInstanceShutdownMessage = {
|
|
35
|
-
type: typeof MANAGED_INSTANCE_SHUTDOWN_MESSAGE_TYPE;
|
|
36
|
-
controlToken: string;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
function nonEmpty(value: string | undefined): string | null {
|
|
40
|
-
const trimmed = value?.trim();
|
|
41
|
-
return trimmed === undefined || trimmed.length === 0 ? null : trimmed;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
45
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function readManagedInstanceLaunch(
|
|
49
|
-
env: ManagedInstanceEnv = process.env,
|
|
50
|
-
): ManagedInstanceLaunchResult {
|
|
51
|
-
const values = [
|
|
52
|
-
env[MANAGED_INSTANCE_ENV.backend],
|
|
53
|
-
env[MANAGED_INSTANCE_ENV.name],
|
|
54
|
-
env[MANAGED_INSTANCE_ENV.instanceId],
|
|
55
|
-
env[MANAGED_INSTANCE_ENV.launchId],
|
|
56
|
-
env[MANAGED_INSTANCE_ENV.controlToken],
|
|
57
|
-
env[MANAGED_INSTANCE_ENV.startedAt],
|
|
58
|
-
env[MANAGED_INSTANCE_ENV.upstreamPort],
|
|
59
|
-
];
|
|
60
|
-
if (values.every((value) => value === undefined || value.trim().length === 0)) {
|
|
61
|
-
return { kind: "unmanaged" };
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const name = nonEmpty(env[MANAGED_INSTANCE_ENV.name]);
|
|
65
|
-
const backend = parseBackendImplementation(
|
|
66
|
-
nonEmpty(env[MANAGED_INSTANCE_ENV.backend]) ?? undefined,
|
|
67
|
-
);
|
|
68
|
-
const instanceId = nonEmpty(env[MANAGED_INSTANCE_ENV.instanceId]);
|
|
69
|
-
const launchId = nonEmpty(env[MANAGED_INSTANCE_ENV.launchId]);
|
|
70
|
-
const controlToken = nonEmpty(env[MANAGED_INSTANCE_ENV.controlToken]);
|
|
71
|
-
const startedAt = nonEmpty(env[MANAGED_INSTANCE_ENV.startedAt]);
|
|
72
|
-
const upstreamPort = Number(env[MANAGED_INSTANCE_ENV.upstreamPort]);
|
|
73
|
-
if (
|
|
74
|
-
name === null ||
|
|
75
|
-
backend === null ||
|
|
76
|
-
instanceId === null ||
|
|
77
|
-
launchId === null ||
|
|
78
|
-
controlToken === null ||
|
|
79
|
-
controlToken.length < 32 ||
|
|
80
|
-
startedAt === null ||
|
|
81
|
-
!Number.isFinite(Date.parse(startedAt)) ||
|
|
82
|
-
!Number.isInteger(upstreamPort) ||
|
|
83
|
-
upstreamPort < 1 ||
|
|
84
|
-
upstreamPort > 65_535
|
|
85
|
-
) {
|
|
86
|
-
return {
|
|
87
|
-
kind: "invalid",
|
|
88
|
-
message: "Managed instance launch environment is incomplete or invalid.",
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
return {
|
|
92
|
-
kind: "managed",
|
|
93
|
-
launch: { backend, name, instanceId, launchId, controlToken, startedAt, upstreamPort },
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export function managedInstanceShutdownMessage(
|
|
98
|
-
controlToken: string,
|
|
99
|
-
): ManagedInstanceShutdownMessage {
|
|
100
|
-
return { type: MANAGED_INSTANCE_SHUTDOWN_MESSAGE_TYPE, controlToken };
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function parseManagedInstanceShutdownMessage(
|
|
104
|
-
value: unknown,
|
|
105
|
-
): ManagedInstanceShutdownMessage | null {
|
|
106
|
-
if (!isRecord(value)) return null;
|
|
107
|
-
return value["type"] === MANAGED_INSTANCE_SHUTDOWN_MESSAGE_TYPE &&
|
|
108
|
-
typeof value["controlToken"] === "string"
|
|
109
|
-
? { type: MANAGED_INSTANCE_SHUTDOWN_MESSAGE_TYPE, controlToken: value["controlToken"] }
|
|
110
|
-
: null;
|
|
111
|
-
}
|
|
112
|
-
import { parseBackendImplementation, type BackendImplementation } from "./backendImplementation";
|
package/src/lib/mask.ts
DELETED
package/src/lib/objectUtils.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic object utilities shared across API format modules.
|
|
3
|
-
* Only truly format-agnostic helpers belong here; Anthropic/OpenAI-specific
|
|
4
|
-
* checks stay in their respective API format modules.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Returns true if `val` is a plain object (not null, not an array).
|
|
9
|
-
*/
|
|
10
|
-
export function isPlainRecord(val: unknown): val is Record<string, unknown> {
|
|
11
|
-
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Safe property access via Object.getOwnPropertyDescriptor.
|
|
16
|
-
* Returns `undefined` when obj is not an object or the property does not exist.
|
|
17
|
-
*/
|
|
18
|
-
export function safeGetOwnProperty(obj: unknown, key: string): unknown {
|
|
19
|
-
if (obj === null || typeof obj !== "object" || Array.isArray(obj)) return undefined;
|
|
20
|
-
const desc = Object.getOwnPropertyDescriptor(obj, key);
|
|
21
|
-
return desc?.value;
|
|
22
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { LogIdSchema } from "../contracts";
|
|
3
|
-
|
|
4
|
-
export const PiAgentHistoryMessageSchema = z.object({
|
|
5
|
-
role: z.enum(["user", "assistant"]),
|
|
6
|
-
content: z.string().trim().min(1).max(4_000),
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export const PiAgentEvidenceSourceSchema = z.enum([
|
|
10
|
-
"log",
|
|
11
|
-
"knowledge",
|
|
12
|
-
"alert",
|
|
13
|
-
"run",
|
|
14
|
-
"group",
|
|
15
|
-
"provider",
|
|
16
|
-
]);
|
|
17
|
-
|
|
18
|
-
export const PiAgentCountEntrySchema = z.object({
|
|
19
|
-
value: z.string(),
|
|
20
|
-
count: z.number().int().nonnegative(),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const PiAgentSummarySchema = z.object({
|
|
24
|
-
matchedLogs: z.number().int().nonnegative(),
|
|
25
|
-
knowledgeMatched: z.number().int().nonnegative(),
|
|
26
|
-
failures: z.number().int().nonnegative(),
|
|
27
|
-
pending: z.number().int().nonnegative(),
|
|
28
|
-
sessions: z.number().int().nonnegative(),
|
|
29
|
-
models: z.array(PiAgentCountEntrySchema),
|
|
30
|
-
providers: z.array(PiAgentCountEntrySchema),
|
|
31
|
-
latency: z.object({
|
|
32
|
-
count: z.number().int().nonnegative(),
|
|
33
|
-
minMs: z.number().nullable(),
|
|
34
|
-
maxMs: z.number().nullable(),
|
|
35
|
-
averageMs: z.number().nullable(),
|
|
36
|
-
}),
|
|
37
|
-
tokens: z.object({
|
|
38
|
-
input: z.number().int().nonnegative(),
|
|
39
|
-
output: z.number().int().nonnegative(),
|
|
40
|
-
total: z.number().int().nonnegative(),
|
|
41
|
-
}),
|
|
42
|
-
sourceCounts: z.record(PiAgentEvidenceSourceSchema, z.number().int().nonnegative()),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const PiAgentQueryStatsSchema = z.object({
|
|
46
|
-
scannedLogs: z.number().int().nonnegative(),
|
|
47
|
-
hydratedLogs: z.number().int().nonnegative(),
|
|
48
|
-
matchedLogs: z.number().int().nonnegative(),
|
|
49
|
-
scannedKnowledge: z.number().int().nonnegative(),
|
|
50
|
-
matchedKnowledge: z.number().int().nonnegative(),
|
|
51
|
-
returnedEvidence: z.number().int().nonnegative(),
|
|
52
|
-
truncated: z.boolean(),
|
|
53
|
-
durationMs: z.number().nonnegative(),
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export const PiAgentEvidenceSchema = z.object({
|
|
57
|
-
source: PiAgentEvidenceSourceSchema,
|
|
58
|
-
id: z.string(),
|
|
59
|
-
logId: LogIdSchema.optional(),
|
|
60
|
-
knowledgeId: z.string().optional(),
|
|
61
|
-
logIds: z.array(LogIdSchema).optional(),
|
|
62
|
-
timestamp: z.string().optional(),
|
|
63
|
-
sessionId: z.string().optional(),
|
|
64
|
-
model: z.string().optional(),
|
|
65
|
-
providerName: z.string().optional(),
|
|
66
|
-
path: z.string().optional(),
|
|
67
|
-
status: z.union([z.number(), z.string()]).nullable().optional(),
|
|
68
|
-
elapsedMs: z.number().optional(),
|
|
69
|
-
inputTokens: z.number().int().nonnegative().optional(),
|
|
70
|
-
outputTokens: z.number().int().nonnegative().optional(),
|
|
71
|
-
score: z.number(),
|
|
72
|
-
matchedFields: z.array(z.string()),
|
|
73
|
-
excerpt: z.string(),
|
|
74
|
-
entityType: z.string().optional(),
|
|
75
|
-
title: z.string().optional(),
|
|
76
|
-
knowledgeType: z.string().optional(),
|
|
77
|
-
tags: z.array(z.string()).optional(),
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
export const PiAgentRequestSchema = z.object({
|
|
81
|
-
question: z.string().trim().min(1).max(4_000),
|
|
82
|
-
sessionId: z.string().trim().min(1).optional(),
|
|
83
|
-
providerId: z.string().trim().min(1).optional(),
|
|
84
|
-
model: z.string().trim().min(1).optional(),
|
|
85
|
-
logLimit: z.number().int().min(1).max(80).optional(),
|
|
86
|
-
history: z.array(PiAgentHistoryMessageSchema).max(12).optional(),
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
export const PiAgentResponseSchema = z.object({
|
|
90
|
-
answer: z.string(),
|
|
91
|
-
providerId: z.string(),
|
|
92
|
-
providerName: z.string(),
|
|
93
|
-
model: z.string(),
|
|
94
|
-
protocol: z.enum(["openaiResponses", "openaiChat", "anthropic"]),
|
|
95
|
-
logCount: z.number().int().nonnegative(),
|
|
96
|
-
evidence: z.array(PiAgentEvidenceSchema).optional(),
|
|
97
|
-
summary: PiAgentSummarySchema.optional(),
|
|
98
|
-
queryStats: PiAgentQueryStatsSchema.optional(),
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export type PiAgentRequest = z.infer<typeof PiAgentRequestSchema>;
|
|
102
|
-
export type PiAgentResponse = z.infer<typeof PiAgentResponseSchema>;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
MAX_PROVIDER_MODEL_METADATA,
|
|
4
|
-
MAX_PROVIDER_MODEL_NAME_CHARS,
|
|
5
|
-
MAX_PROVIDER_MODELS,
|
|
6
|
-
} from "./resourceLimits";
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Validates that a string is a well-formed http(s) URL. Rejects non-HTTP
|
|
10
|
-
* schemes (file:, ftp:, etc.) that could be used for SSRF. Local/private
|
|
11
|
-
* addresses are allowed because this tool legitimately proxies to local LLM
|
|
12
|
-
* servers (Ollama, LM Studio, etc.).
|
|
13
|
-
*/
|
|
14
|
-
function httpUrl(): z.ZodString {
|
|
15
|
-
return z.string().refine((val) => {
|
|
16
|
-
// Treat empty strings as "unset" so legacy/in-flight providers that
|
|
17
|
-
// store empty placeholders instead of null can still round-trip.
|
|
18
|
-
if (val.length === 0) return true;
|
|
19
|
-
try {
|
|
20
|
-
const parsed = new URL(val);
|
|
21
|
-
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
22
|
-
} catch {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
}, "Must be a valid http(s) URL");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const ProviderModelNameSchema = z.string().max(MAX_PROVIDER_MODEL_NAME_CHARS);
|
|
29
|
-
export const ProviderModelsSchema = z.array(ProviderModelNameSchema).max(MAX_PROVIDER_MODELS);
|
|
30
|
-
|
|
31
|
-
export const ProviderModelMetadataSchema = z.object({
|
|
32
|
-
model: ProviderModelNameSchema.min(1),
|
|
33
|
-
contextWindow: z.number().int().positive().optional(),
|
|
34
|
-
outputLimit: z.number().int().positive().optional(),
|
|
35
|
-
source: z.enum(["manual", "registry"]).optional(),
|
|
36
|
-
sourceUrl: z.string().optional(),
|
|
37
|
-
updatedAt: z.string().optional(),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
export const ProviderModelMetadataListSchema = z
|
|
41
|
-
.array(ProviderModelMetadataSchema)
|
|
42
|
-
.max(MAX_PROVIDER_MODEL_METADATA);
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Persisted provider shape shared by the server store and browser API clients.
|
|
46
|
-
*
|
|
47
|
-
* Keep this module free of filesystem and process-level imports so client code
|
|
48
|
-
* can validate API responses without pulling the provider store into the bundle.
|
|
49
|
-
*/
|
|
50
|
-
export const ProviderConfigSchema = z.object({
|
|
51
|
-
id: z.string(),
|
|
52
|
-
name: z.string(),
|
|
53
|
-
apiKey: z.string(),
|
|
54
|
-
model: ProviderModelNameSchema.optional(),
|
|
55
|
-
models: ProviderModelsSchema.optional().default([]),
|
|
56
|
-
format: z.enum(["anthropic", "openai"]).optional(),
|
|
57
|
-
baseUrl: httpUrl().optional(),
|
|
58
|
-
anthropicBaseUrl: httpUrl().optional(),
|
|
59
|
-
openaiBaseUrl: httpUrl().optional(),
|
|
60
|
-
openaiResponsesBaseUrl: httpUrl().optional(),
|
|
61
|
-
authHeader: z.enum(["bearer", "x-api-key"]).optional().default("bearer"),
|
|
62
|
-
apiDocsUrl: z.string().optional(),
|
|
63
|
-
modelMetadataUrl: z.string().optional(),
|
|
64
|
-
modelMetadata: ProviderModelMetadataListSchema.optional(),
|
|
65
|
-
source: z.enum(["company", "personal"]).optional(),
|
|
66
|
-
createdAt: z.string(),
|
|
67
|
-
updatedAt: z.string(),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const REDACTED_PROVIDER_API_KEY = "configured";
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Secret-safe provider shape used at every API and tool output boundary.
|
|
74
|
-
*
|
|
75
|
-
* Keeping the marker in the existing `apiKey` field preserves compatibility
|
|
76
|
-
* with older browser clients while making plaintext provider credentials
|
|
77
|
-
* impossible to represent in a validated response.
|
|
78
|
-
*/
|
|
79
|
-
export const RedactedProviderDtoSchema = ProviderConfigSchema.extend({
|
|
80
|
-
apiKey: z.literal(REDACTED_PROVIDER_API_KEY),
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
export type ProviderModelMetadata = z.infer<typeof ProviderModelMetadataSchema>;
|
|
84
|
-
export type ProviderConfig = z.infer<typeof ProviderConfigSchema>;
|
|
85
|
-
export type RedactedProviderDto = z.infer<typeof RedactedProviderDtoSchema>;
|
|
86
|
-
|
|
87
|
-
export type ProviderModelLimitViolation = {
|
|
88
|
-
resource: "provider-models" | "provider-model-metadata";
|
|
89
|
-
limit: number;
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
function arrayFieldLength(value: unknown, key: string): number | null {
|
|
93
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
94
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
95
|
-
if (descriptor === undefined) return null;
|
|
96
|
-
const field: unknown = descriptor.value;
|
|
97
|
-
return Array.isArray(field) ? field.length : null;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export function getProviderModelLimitViolation(value: unknown): ProviderModelLimitViolation | null {
|
|
101
|
-
const modelCount = arrayFieldLength(value, "models");
|
|
102
|
-
if (modelCount !== null && modelCount > MAX_PROVIDER_MODELS) {
|
|
103
|
-
return { resource: "provider-models", limit: MAX_PROVIDER_MODELS };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const metadataCount = arrayFieldLength(value, "modelMetadata");
|
|
107
|
-
if (metadataCount !== null && metadataCount > MAX_PROVIDER_MODEL_METADATA) {
|
|
108
|
-
return { resource: "provider-model-metadata", limit: MAX_PROVIDER_MODEL_METADATA };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function toRedactedProviderDto(provider: ProviderConfig): RedactedProviderDto {
|
|
115
|
-
return {
|
|
116
|
-
...provider,
|
|
117
|
-
apiKey: REDACTED_PROVIDER_API_KEY,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export function toRedactedProviderDtos(
|
|
122
|
-
providers: readonly ProviderConfig[],
|
|
123
|
-
): RedactedProviderDto[] {
|
|
124
|
-
return providers.map(toRedactedProviderDto);
|
|
125
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
export const ScannedProviderDtoSchema = z.object({
|
|
4
|
-
selectionId: z.string().uuid(),
|
|
5
|
-
name: z.string(),
|
|
6
|
-
apiKeyHint: z.string(),
|
|
7
|
-
format: z.enum(["anthropic", "openai"]),
|
|
8
|
-
anthropicBaseUrl: z.string(),
|
|
9
|
-
openaiBaseUrl: z.string(),
|
|
10
|
-
openaiResponsesBaseUrl: z.string().optional().default(""),
|
|
11
|
-
models: z.array(z.string()),
|
|
12
|
-
sourceTool: z.enum(["claude-code", "opencode", "mimo-code"]),
|
|
13
|
-
alreadyExists: z.boolean(),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
export const ProviderScanResponseSchema = z.object({
|
|
17
|
-
scanId: z.string().uuid(),
|
|
18
|
-
providers: z.array(ScannedProviderDtoSchema),
|
|
19
|
-
warnings: z.array(z.string()).optional(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
export const ProviderScanImportRequestSchema = z.object({
|
|
23
|
-
scanId: z.string().uuid(),
|
|
24
|
-
selectionIds: z.array(z.string().uuid()).min(1).max(100),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type ScannedProviderDto = z.infer<typeof ScannedProviderDtoSchema>;
|