@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
package/src/contracts/index.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export { JsonValueSchema, trustAsJsonValue } from "./json";
|
|
2
|
-
export type { JsonValue } from "./json";
|
|
3
|
-
|
|
4
|
-
export {
|
|
5
|
-
CaptureIncompleteReasonSchema,
|
|
6
|
-
CapturedLogSchema,
|
|
7
|
-
LogBodyChunkSchema,
|
|
8
|
-
LogIdSchema,
|
|
9
|
-
LogBodyPartSchema,
|
|
10
|
-
parseLogId,
|
|
11
|
-
StreamingChunkSchema,
|
|
12
|
-
StopReasonSchema,
|
|
13
|
-
ToolTraceEventSchema,
|
|
14
|
-
} from "./log";
|
|
15
|
-
export type {
|
|
16
|
-
ApiFormat,
|
|
17
|
-
CaptureIncompleteReason,
|
|
18
|
-
CapturedLog,
|
|
19
|
-
LogBodyChunk,
|
|
20
|
-
LogId,
|
|
21
|
-
LogBodyPart,
|
|
22
|
-
StreamingChunk,
|
|
23
|
-
StopReason,
|
|
24
|
-
ToolTraceEvent,
|
|
25
|
-
TokenUsage,
|
|
26
|
-
} from "./log";
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
AnthropicRequestSchema,
|
|
30
|
-
AnthropicResponseSchema,
|
|
31
|
-
SseEventSchema,
|
|
32
|
-
} from "./anthropic";
|
|
33
|
-
export type { AnthropicResponse, ResponseContentBlockType } from "./anthropic";
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
OpenAIChoice,
|
|
37
|
-
OpenAIChoiceDelta,
|
|
38
|
-
OpenAIFunctionCall,
|
|
39
|
-
OpenAIMessage,
|
|
40
|
-
OpenAIMessageContent,
|
|
41
|
-
OpenAIRequestSchema,
|
|
42
|
-
OpenAIResponsesRequestSchema,
|
|
43
|
-
OpenAIResponsesResponseSchema,
|
|
44
|
-
OpenAIResponsesSSEventSchema,
|
|
45
|
-
OpenAIResponsesToolDefinition,
|
|
46
|
-
OpenAIResponsesUsageSchema,
|
|
47
|
-
OpenAIResponsesOutputItemSchema,
|
|
48
|
-
OpenAIResponseSchema,
|
|
49
|
-
OpenAISSERawChunkSchema,
|
|
50
|
-
OpenAIToolCallSchema,
|
|
51
|
-
OpenAIToolDefinition,
|
|
52
|
-
parseOpenAIResponsesResponse,
|
|
53
|
-
parseOpenAIResponse,
|
|
54
|
-
} from "./openai";
|
|
55
|
-
export type {
|
|
56
|
-
OpenAIResponse,
|
|
57
|
-
OpenAIResponsesResponse,
|
|
58
|
-
OpenAIToolCall,
|
|
59
|
-
} from "./openai";
|
package/src/contracts/json.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Shared JSON value type for API payload fragments and streaming chunks.
|
|
5
|
-
*/
|
|
6
|
-
export type JsonValue =
|
|
7
|
-
| string
|
|
8
|
-
| number
|
|
9
|
-
| boolean
|
|
10
|
-
| null
|
|
11
|
-
| JsonValue[]
|
|
12
|
-
| { [key: string]: JsonValue };
|
|
13
|
-
|
|
14
|
-
export const JsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>
|
|
15
|
-
z.union([
|
|
16
|
-
z.string(),
|
|
17
|
-
z.number(),
|
|
18
|
-
z.boolean(),
|
|
19
|
-
z.null(),
|
|
20
|
-
z.array(JsonValueSchema),
|
|
21
|
-
z.record(z.string(), JsonValueSchema),
|
|
22
|
-
]),
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Re-types a value as `JsonValue` without a full recursive walk. A lightweight
|
|
27
|
-
* runtime guard rejects the most dangerous non-JSON types (undefined, bigint,
|
|
28
|
-
* functions) that would crash JSON.stringify downstream. Use when the value
|
|
29
|
-
* has already been validated by Zod or originated from JSON.parse.
|
|
30
|
-
*/
|
|
31
|
-
export function trustAsJsonValue<T>(value: T): JsonValue {
|
|
32
|
-
if (value === undefined || typeof value === "bigint" || typeof value === "function") {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
36
|
-
return value as unknown as JsonValue;
|
|
37
|
-
}
|
package/src/contracts/log.ts
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { JsonValueSchema } from "./json";
|
|
3
|
-
|
|
4
|
-
export type ApiFormat = "anthropic" | "openai" | "unknown";
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Persisted log ID contract. New captures allocate positive IDs, while zero
|
|
8
|
-
* remains readable for legacy data. Unsafe integers are never valid IDs.
|
|
9
|
-
*/
|
|
10
|
-
export const LogIdSchema = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
11
|
-
|
|
12
|
-
export type LogId = z.infer<typeof LogIdSchema>;
|
|
13
|
-
|
|
14
|
-
/** Parse a decimal path/query/header value using the persisted log ID contract. */
|
|
15
|
-
export function parseLogId(value: string): LogId | null {
|
|
16
|
-
if (!/^\d+$/.test(value)) return null;
|
|
17
|
-
const result = LogIdSchema.safeParse(Number(value));
|
|
18
|
-
return result.success ? result.data : null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const CaptureIncompleteReasonSchema = z.enum([
|
|
22
|
-
"capacity-exceeded",
|
|
23
|
-
"pipeline-closed",
|
|
24
|
-
"write-failed",
|
|
25
|
-
"finalize-failed",
|
|
26
|
-
"finalize-timeout",
|
|
27
|
-
"upstream-stream-error",
|
|
28
|
-
"shutdown",
|
|
29
|
-
]);
|
|
30
|
-
|
|
31
|
-
export type CaptureIncompleteReason = z.infer<typeof CaptureIncompleteReasonSchema>;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A single SSE event from a streaming response.
|
|
35
|
-
*/
|
|
36
|
-
export const StreamingChunkSchema = z.object({
|
|
37
|
-
index: z.number(),
|
|
38
|
-
timestamp: z.number(),
|
|
39
|
-
type: z.string(),
|
|
40
|
-
data: JsonValueSchema,
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export type StreamingChunk = z.infer<typeof StreamingChunkSchema>;
|
|
44
|
-
|
|
45
|
-
export const ToolTraceEventSchema = z.object({
|
|
46
|
-
id: z.string(),
|
|
47
|
-
logId: LogIdSchema,
|
|
48
|
-
index: z.number().int().nonnegative(),
|
|
49
|
-
provider: z.enum(["anthropic", "openai"]),
|
|
50
|
-
name: z.string(),
|
|
51
|
-
argumentsText: z.string().nullable(),
|
|
52
|
-
argumentsPreview: z.string().nullable(),
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
export type ToolTraceEvent = z.infer<typeof ToolTraceEventSchema>;
|
|
56
|
-
|
|
57
|
-
const StopReasonValueSchema = z.enum(["end_turn", "tool_use", "stop", "length"]);
|
|
58
|
-
export const StopReasonSchema = StopReasonValueSchema.nullable();
|
|
59
|
-
export type StopReason = z.infer<typeof StopReasonSchema>;
|
|
60
|
-
|
|
61
|
-
const StreamingChunksArraySchema = z.object({
|
|
62
|
-
chunks: z.array(StreamingChunkSchema),
|
|
63
|
-
truncated: z.boolean().optional().default(false),
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
export const LogBodyPartSchema = z.enum(["request", "response"]);
|
|
67
|
-
export type LogBodyPart = z.infer<typeof LogBodyPartSchema>;
|
|
68
|
-
|
|
69
|
-
export const LogBodyChunkSchema = z.object({
|
|
70
|
-
logId: LogIdSchema,
|
|
71
|
-
part: LogBodyPartSchema,
|
|
72
|
-
text: z.string(),
|
|
73
|
-
offset: z.number().int().nonnegative(),
|
|
74
|
-
limit: z.number().int().positive(),
|
|
75
|
-
totalBytes: z.number().int().nonnegative(),
|
|
76
|
-
textBytes: z.number().int().nonnegative(),
|
|
77
|
-
nextOffset: z.number().int().nonnegative().nullable(),
|
|
78
|
-
hasMore: z.boolean(),
|
|
79
|
-
contentMode: z.enum(["empty", "partial", "full"]),
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
export type LogBodyChunk = z.infer<typeof LogBodyChunkSchema>;
|
|
83
|
-
|
|
84
|
-
export const CapturedLogSchema = z.object({
|
|
85
|
-
id: LogIdSchema,
|
|
86
|
-
timestamp: z.string(),
|
|
87
|
-
method: z.string(),
|
|
88
|
-
path: z.string(),
|
|
89
|
-
model: z.string().nullable(),
|
|
90
|
-
sessionId: z.string().nullable(),
|
|
91
|
-
rawRequestBody: z.string().nullable(),
|
|
92
|
-
responseStatus: z.number().nullable(),
|
|
93
|
-
responseText: z.string().nullable(),
|
|
94
|
-
inputTokens: z.number().nullable(),
|
|
95
|
-
outputTokens: z.number().nullable(),
|
|
96
|
-
cacheCreationInputTokens: z.number().nullable(),
|
|
97
|
-
cacheReadInputTokens: z.number().nullable(),
|
|
98
|
-
elapsedMs: z.number().nullable(),
|
|
99
|
-
firstChunkMs: z.number().nullable().optional(),
|
|
100
|
-
totalStreamMs: z.number().nullable().optional(),
|
|
101
|
-
tokensPerSecond: z.number().nullable().optional(),
|
|
102
|
-
streaming: z.boolean(),
|
|
103
|
-
userAgent: z.string().nullable(),
|
|
104
|
-
origin: z.string().nullable(),
|
|
105
|
-
rawHeaders: z.record(z.string(), z.string()).optional(),
|
|
106
|
-
/** Headers sent to the upstream LLM */
|
|
107
|
-
headers: z.record(z.string(), z.string()).optional(),
|
|
108
|
-
apiFormat: z.enum(["anthropic", "openai", "unknown"]).default("unknown"),
|
|
109
|
-
isTest: z.boolean().optional().default(false),
|
|
110
|
-
replayOfLogId: LogIdSchema.nullable().optional(),
|
|
111
|
-
providerName: z.string().nullable().optional(),
|
|
112
|
-
clientPort: z.number().nullable().optional(),
|
|
113
|
-
clientPid: z.number().nullable().optional(),
|
|
114
|
-
clientCwd: z.string().nullable().optional(),
|
|
115
|
-
clientProjectFolder: z.string().nullable().optional(),
|
|
116
|
-
streamingChunks: StreamingChunksArraySchema.optional(),
|
|
117
|
-
streamingChunksPath: z.string().nullable().optional(),
|
|
118
|
-
rawRequestBodyBytes: z.number().int().nonnegative().nullable().optional(),
|
|
119
|
-
responseTextBytes: z.number().int().nonnegative().nullable().optional(),
|
|
120
|
-
bodyContentMode: z.enum(["full", "compact", "truncated"]).optional(),
|
|
121
|
-
captureIncomplete: z.boolean().optional(),
|
|
122
|
-
droppedChunks: z.number().int().nonnegative().optional(),
|
|
123
|
-
droppedBytes: z.number().int().nonnegative().optional(),
|
|
124
|
-
captureIncompleteReason: CaptureIncompleteReasonSchema.nullable().optional(),
|
|
125
|
-
warnings: z.array(z.string()).optional(),
|
|
126
|
-
toolTraceEvents: z.array(ToolTraceEventSchema).optional(),
|
|
127
|
-
stopReason: StopReasonSchema.optional(),
|
|
128
|
-
/** Error message from streaming response (e.g., SSE error event) */
|
|
129
|
-
error: z.string().nullable().optional(),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
export type CapturedLog = z.infer<typeof CapturedLogSchema>;
|
|
133
|
-
|
|
134
|
-
export type TokenUsage = {
|
|
135
|
-
inputTokens: number | null;
|
|
136
|
-
outputTokens: number | null;
|
|
137
|
-
cacheCreationInputTokens: number | null;
|
|
138
|
-
cacheReadInputTokens: number | null;
|
|
139
|
-
};
|
package/src/contracts/openai.ts
DELETED
|
@@ -1,267 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { JsonValueSchema } from "./json";
|
|
3
|
-
|
|
4
|
-
export const OpenAIMessageContent = z.union([
|
|
5
|
-
z.string(),
|
|
6
|
-
z.array(
|
|
7
|
-
z.discriminatedUnion("type", [
|
|
8
|
-
z.object({ type: z.literal("text"), text: z.string() }),
|
|
9
|
-
z.object({
|
|
10
|
-
type: z.literal("image_url"),
|
|
11
|
-
image_url: z.object({ url: z.string(), detail: z.string().optional() }),
|
|
12
|
-
}),
|
|
13
|
-
]),
|
|
14
|
-
),
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
export const OpenAIMessage = z.object({
|
|
18
|
-
role: z.enum(["system", "user", "assistant", "tool"]),
|
|
19
|
-
content: OpenAIMessageContent,
|
|
20
|
-
name: z.string().optional(),
|
|
21
|
-
reasoning_content: z.string().optional(),
|
|
22
|
-
thinking: z.string().optional(),
|
|
23
|
-
think: z.string().optional(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export const OpenAIFunctionCall = z.object({
|
|
27
|
-
name: z.string(),
|
|
28
|
-
arguments: z.string(),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export const OpenAIToolCallSchema = z.object({
|
|
32
|
-
index: z.number().optional(),
|
|
33
|
-
id: z.string().optional(),
|
|
34
|
-
type: z.literal("function").optional(),
|
|
35
|
-
function: z.object({
|
|
36
|
-
name: z.string().optional(),
|
|
37
|
-
arguments: z.string().optional(),
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
export type OpenAIToolCall = z.infer<typeof OpenAIToolCallSchema>;
|
|
42
|
-
|
|
43
|
-
const OpenAIMessageWithFunctionCall = OpenAIMessage.extend({
|
|
44
|
-
content: z
|
|
45
|
-
.union([z.string(), z.array(z.object({ type: z.literal("text"), text: z.string() }))])
|
|
46
|
-
.optional(),
|
|
47
|
-
function_call: OpenAIFunctionCall.optional(),
|
|
48
|
-
tool_calls: z.array(OpenAIToolCallSchema).optional(),
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
export const OpenAIToolDefinition = z.object({
|
|
52
|
-
type: z.literal("function"),
|
|
53
|
-
function: z.object({
|
|
54
|
-
name: z.string(),
|
|
55
|
-
description: z.string().optional(),
|
|
56
|
-
parameters: z.record(z.string(), JsonValueSchema),
|
|
57
|
-
}),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
export const OpenAIRequestSchema = z.object({
|
|
61
|
-
model: z.string(),
|
|
62
|
-
messages: z.array(OpenAIMessage),
|
|
63
|
-
temperature: z.number().optional(),
|
|
64
|
-
max_tokens: z.number().optional(),
|
|
65
|
-
stream: z.boolean().optional(),
|
|
66
|
-
tools: z.array(OpenAIToolDefinition).optional(),
|
|
67
|
-
tool_choice: z
|
|
68
|
-
.union([
|
|
69
|
-
z.enum(["auto", "none", "required"]),
|
|
70
|
-
z.object({ type: z.literal("auto") }),
|
|
71
|
-
z.object({ type: z.literal("none") }),
|
|
72
|
-
z.object({ type: z.literal("function"), function: z.object({ name: z.string() }) }),
|
|
73
|
-
])
|
|
74
|
-
.optional(),
|
|
75
|
-
user: z.string().optional(),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
export const OpenAIResponsesToolDefinition = z
|
|
79
|
-
.object({
|
|
80
|
-
type: z.string(),
|
|
81
|
-
name: z.string().optional(),
|
|
82
|
-
description: z.string().optional(),
|
|
83
|
-
parameters: JsonValueSchema.optional(),
|
|
84
|
-
function: z
|
|
85
|
-
.object({
|
|
86
|
-
name: z.string().optional(),
|
|
87
|
-
description: z.string().optional(),
|
|
88
|
-
parameters: JsonValueSchema.optional(),
|
|
89
|
-
})
|
|
90
|
-
.optional(),
|
|
91
|
-
})
|
|
92
|
-
.passthrough();
|
|
93
|
-
|
|
94
|
-
export const OpenAIResponsesRequestSchema = z
|
|
95
|
-
.object({
|
|
96
|
-
model: z.string(),
|
|
97
|
-
input: z.unknown().optional(),
|
|
98
|
-
instructions: z.union([z.string(), z.null()]).optional(),
|
|
99
|
-
stream: z.boolean().optional(),
|
|
100
|
-
tools: z.array(OpenAIResponsesToolDefinition).optional(),
|
|
101
|
-
tool_choice: z.unknown().optional(),
|
|
102
|
-
max_output_tokens: z.number().optional(),
|
|
103
|
-
temperature: z.number().optional(),
|
|
104
|
-
user: z.string().optional(),
|
|
105
|
-
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
106
|
-
})
|
|
107
|
-
.passthrough();
|
|
108
|
-
|
|
109
|
-
export const OpenAIChoiceDelta = z.object({
|
|
110
|
-
role: z.enum(["assistant"]).optional(),
|
|
111
|
-
content: z.string().nullable().optional(),
|
|
112
|
-
reasoning_content: z.string().nullable().optional(),
|
|
113
|
-
thinking: z.string().nullable().optional(),
|
|
114
|
-
think: z.string().nullable().optional(),
|
|
115
|
-
function_call: z
|
|
116
|
-
.object({ name: z.string().optional(), arguments: z.string().optional() })
|
|
117
|
-
.nullable()
|
|
118
|
-
.optional(),
|
|
119
|
-
tool_calls: z
|
|
120
|
-
.array(
|
|
121
|
-
z.object({
|
|
122
|
-
index: z.number(),
|
|
123
|
-
id: z.string().optional(),
|
|
124
|
-
type: z.literal("function").optional(),
|
|
125
|
-
function: z.object({
|
|
126
|
-
name: z.string().optional(),
|
|
127
|
-
arguments: z.string().optional(),
|
|
128
|
-
}),
|
|
129
|
-
}),
|
|
130
|
-
)
|
|
131
|
-
.nullable()
|
|
132
|
-
.optional(),
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
export const OpenAIChoice = z.object({
|
|
136
|
-
index: z.number(),
|
|
137
|
-
message: z
|
|
138
|
-
.object({
|
|
139
|
-
role: z.enum(["assistant"]),
|
|
140
|
-
content: z.string().nullable(),
|
|
141
|
-
reasoning_content: z.string().optional(),
|
|
142
|
-
thinking: z.string().optional(),
|
|
143
|
-
think: z.string().optional(),
|
|
144
|
-
function_call: z.object({ name: z.string(), arguments: z.string() }).nullable().optional(),
|
|
145
|
-
tool_calls: z.array(OpenAIToolCallSchema).optional(),
|
|
146
|
-
})
|
|
147
|
-
.optional(),
|
|
148
|
-
delta: OpenAIChoiceDelta.optional(),
|
|
149
|
-
finish_reason: z.string().nullable(),
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
export const OpenAIResponseSchema = z
|
|
153
|
-
.object({
|
|
154
|
-
id: z.string(),
|
|
155
|
-
object: z.literal("chat.completion"),
|
|
156
|
-
created: z.number(),
|
|
157
|
-
model: z.string(),
|
|
158
|
-
choices: z.array(OpenAIChoice),
|
|
159
|
-
usage: z
|
|
160
|
-
.object({
|
|
161
|
-
prompt_tokens: z.number().nullable().optional(),
|
|
162
|
-
completion_tokens: z.number().nullable().optional(),
|
|
163
|
-
total_tokens: z.number().nullable().optional(),
|
|
164
|
-
})
|
|
165
|
-
.passthrough(),
|
|
166
|
-
service_tier: z.string().nullable().optional(),
|
|
167
|
-
system_fingerprint: z.string().nullable().optional(),
|
|
168
|
-
})
|
|
169
|
-
.passthrough();
|
|
170
|
-
|
|
171
|
-
export const OpenAISSERawChunkSchema = z
|
|
172
|
-
.object({
|
|
173
|
-
id: z.string(),
|
|
174
|
-
object: z.literal("chat.completion.chunk"),
|
|
175
|
-
created: z.number(),
|
|
176
|
-
model: z.string(),
|
|
177
|
-
choices: z.array(
|
|
178
|
-
z.object({
|
|
179
|
-
index: z.number(),
|
|
180
|
-
delta: OpenAIChoiceDelta,
|
|
181
|
-
finish_reason: z.string().nullable().optional(),
|
|
182
|
-
}),
|
|
183
|
-
),
|
|
184
|
-
usage: z
|
|
185
|
-
.object({
|
|
186
|
-
prompt_tokens: z.number().nullable().optional(),
|
|
187
|
-
completion_tokens: z.number().nullable().optional(),
|
|
188
|
-
total_tokens: z.number().nullable().optional(),
|
|
189
|
-
})
|
|
190
|
-
.passthrough()
|
|
191
|
-
.nullable()
|
|
192
|
-
.optional(),
|
|
193
|
-
})
|
|
194
|
-
.passthrough();
|
|
195
|
-
|
|
196
|
-
export const OpenAIResponsesUsageSchema = z
|
|
197
|
-
.object({
|
|
198
|
-
input_tokens: z.number().nullable().optional(),
|
|
199
|
-
output_tokens: z.number().nullable().optional(),
|
|
200
|
-
total_tokens: z.number().nullable().optional(),
|
|
201
|
-
input_tokens_details: z
|
|
202
|
-
.object({
|
|
203
|
-
cached_tokens: z.number().nullable().optional(),
|
|
204
|
-
})
|
|
205
|
-
.passthrough()
|
|
206
|
-
.nullable()
|
|
207
|
-
.optional(),
|
|
208
|
-
output_tokens_details: z
|
|
209
|
-
.object({
|
|
210
|
-
reasoning_tokens: z.number().nullable().optional(),
|
|
211
|
-
})
|
|
212
|
-
.passthrough()
|
|
213
|
-
.nullable()
|
|
214
|
-
.optional(),
|
|
215
|
-
})
|
|
216
|
-
.passthrough();
|
|
217
|
-
|
|
218
|
-
export const OpenAIResponsesOutputItemSchema = z
|
|
219
|
-
.object({
|
|
220
|
-
type: z.string(),
|
|
221
|
-
})
|
|
222
|
-
.passthrough();
|
|
223
|
-
|
|
224
|
-
export const OpenAIResponsesResponseSchema = z
|
|
225
|
-
.object({
|
|
226
|
-
id: z.string(),
|
|
227
|
-
object: z.literal("response").optional(),
|
|
228
|
-
created_at: z.number().optional(),
|
|
229
|
-
status: z.string().nullable().optional(),
|
|
230
|
-
model: z.string().optional(),
|
|
231
|
-
output: z.array(OpenAIResponsesOutputItemSchema).optional(),
|
|
232
|
-
output_text: z.string().optional(),
|
|
233
|
-
usage: OpenAIResponsesUsageSchema.nullable().optional(),
|
|
234
|
-
error: z.unknown().optional(),
|
|
235
|
-
})
|
|
236
|
-
.passthrough();
|
|
237
|
-
|
|
238
|
-
export const OpenAIResponsesSSEventSchema = z
|
|
239
|
-
.object({
|
|
240
|
-
type: z.string(),
|
|
241
|
-
})
|
|
242
|
-
.passthrough();
|
|
243
|
-
|
|
244
|
-
export type OpenAIResponse = z.infer<typeof OpenAIResponseSchema>;
|
|
245
|
-
export type OpenAIResponsesResponse = z.infer<typeof OpenAIResponsesResponseSchema>;
|
|
246
|
-
|
|
247
|
-
export function parseOpenAIResponse(rawBody: string): OpenAIResponse | null {
|
|
248
|
-
try {
|
|
249
|
-
const json: unknown = JSON.parse(rawBody);
|
|
250
|
-
const result = OpenAIResponseSchema.safeParse(json);
|
|
251
|
-
if (result.success) return result.data;
|
|
252
|
-
return null;
|
|
253
|
-
} catch {
|
|
254
|
-
return null;
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
export function parseOpenAIResponsesResponse(rawBody: string): OpenAIResponsesResponse | null {
|
|
259
|
-
try {
|
|
260
|
-
const json: unknown = JSON.parse(rawBody);
|
|
261
|
-
const result = OpenAIResponsesResponseSchema.safeParse(json);
|
|
262
|
-
if (result.success) return result.data;
|
|
263
|
-
return null;
|
|
264
|
-
} catch {
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
}
|
package/src/index.css
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { KnowledgeCandidate, KnowledgeCandidateType } from "./types";
|
|
2
|
-
import { redactCandidate } from "./redactor";
|
|
3
|
-
|
|
4
|
-
export type CandidateDraftUpdate = {
|
|
5
|
-
type?: KnowledgeCandidateType;
|
|
6
|
-
title?: string;
|
|
7
|
-
content?: string;
|
|
8
|
-
tags?: string[];
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const candidates = new Map<string, KnowledgeCandidate>();
|
|
12
|
-
|
|
13
|
-
export function listCandidates(): KnowledgeCandidate[] {
|
|
14
|
-
return [...candidates.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function getCandidate(id: string): KnowledgeCandidate | null {
|
|
18
|
-
return candidates.get(id) ?? null;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function saveCandidates(items: KnowledgeCandidate[]): KnowledgeCandidate[] {
|
|
22
|
-
for (const item of items) {
|
|
23
|
-
const existing = candidates.get(item.id);
|
|
24
|
-
if (existing === undefined) {
|
|
25
|
-
candidates.set(item.id, item);
|
|
26
|
-
} else {
|
|
27
|
-
candidates.set(item.id, {
|
|
28
|
-
...item,
|
|
29
|
-
status: existing.status,
|
|
30
|
-
createdAt: existing.createdAt,
|
|
31
|
-
openClawMemoryId: existing.openClawMemoryId,
|
|
32
|
-
error: existing.error,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return items.map((item) => candidates.get(item.id) ?? item);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export function markCandidatePromoted(
|
|
40
|
-
id: string,
|
|
41
|
-
memoryId: string | null,
|
|
42
|
-
): KnowledgeCandidate | null {
|
|
43
|
-
const existing = candidates.get(id);
|
|
44
|
-
if (existing === undefined) return null;
|
|
45
|
-
const updated: KnowledgeCandidate = {
|
|
46
|
-
...existing,
|
|
47
|
-
status: "promoted",
|
|
48
|
-
openClawMemoryId: memoryId,
|
|
49
|
-
error: null,
|
|
50
|
-
updatedAt: new Date().toISOString(),
|
|
51
|
-
};
|
|
52
|
-
candidates.set(id, updated);
|
|
53
|
-
return updated;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function markCandidateFailed(id: string, error: string): KnowledgeCandidate | null {
|
|
57
|
-
const existing = candidates.get(id);
|
|
58
|
-
if (existing === undefined) return null;
|
|
59
|
-
const updated: KnowledgeCandidate = {
|
|
60
|
-
...existing,
|
|
61
|
-
status: "failed",
|
|
62
|
-
error,
|
|
63
|
-
updatedAt: new Date().toISOString(),
|
|
64
|
-
};
|
|
65
|
-
candidates.set(id, updated);
|
|
66
|
-
return updated;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function updateCandidateDraft(
|
|
70
|
-
id: string,
|
|
71
|
-
updates: CandidateDraftUpdate,
|
|
72
|
-
): KnowledgeCandidate | null {
|
|
73
|
-
const existing = candidates.get(id);
|
|
74
|
-
if (existing === undefined) return null;
|
|
75
|
-
if (existing.status === "promoted") return null;
|
|
76
|
-
|
|
77
|
-
const updated = redactCandidate({
|
|
78
|
-
...existing,
|
|
79
|
-
type: updates.type ?? existing.type,
|
|
80
|
-
title: updates.title ?? existing.title,
|
|
81
|
-
content: updates.content ?? existing.content,
|
|
82
|
-
tags: updates.tags ?? existing.tags,
|
|
83
|
-
status: "draft",
|
|
84
|
-
error: null,
|
|
85
|
-
openClawMemoryId: null,
|
|
86
|
-
updatedAt: new Date().toISOString(),
|
|
87
|
-
});
|
|
88
|
-
candidates.set(id, updated);
|
|
89
|
-
return updated;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export function _resetCandidatesForTests(): void {
|
|
93
|
-
candidates.clear();
|
|
94
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { extractLastUserMessagePreview, extractResponsePreview } from "../mcp/previewExtractor";
|
|
2
|
-
import type { CapturedLog } from "../contracts";
|
|
3
|
-
import type { KnowledgeCandidate, KnowledgeCandidateType } from "./types";
|
|
4
|
-
import { redactCandidate } from "./redactor";
|
|
5
|
-
|
|
6
|
-
function uniqueStrings(values: Array<string | null | undefined>): string[] {
|
|
7
|
-
const set = new Set<string>();
|
|
8
|
-
for (const value of values) {
|
|
9
|
-
if (value !== null && value !== undefined && value !== "") {
|
|
10
|
-
set.add(value);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
return [...set];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function firstProject(logs: CapturedLog[]): string | null {
|
|
17
|
-
for (const log of logs) {
|
|
18
|
-
if (log.clientProjectFolder !== null && log.clientProjectFolder !== undefined) {
|
|
19
|
-
return log.clientProjectFolder;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function outcomeFor(logs: CapturedLog[]): string {
|
|
26
|
-
const hasFailure = logs.some((log) => log.responseStatus !== null && log.responseStatus >= 400);
|
|
27
|
-
const hasPending = logs.some((log) => log.responseStatus === null);
|
|
28
|
-
if (hasFailure) return "failure";
|
|
29
|
-
if (hasPending) return "pending";
|
|
30
|
-
return "success";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function latestPreview(logs: CapturedLog[], pick: (log: CapturedLog) => string | null): string {
|
|
34
|
-
for (let i = logs.length - 1; i >= 0; i--) {
|
|
35
|
-
const log = logs[i];
|
|
36
|
-
if (log === undefined) continue;
|
|
37
|
-
const preview = pick(log);
|
|
38
|
-
if (preview !== null && preview !== "") {
|
|
39
|
-
return preview;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return "No text preview available.";
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function candidateId(sessionId: string, type: KnowledgeCandidateType, logIds: number[]): string {
|
|
46
|
-
const first = logIds[0] ?? 0;
|
|
47
|
-
const last = logIds[logIds.length - 1] ?? first;
|
|
48
|
-
return `inspector:${sessionId}:${type}:${first}-${last}`;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function distillSessionCandidates(
|
|
52
|
-
sessionId: string,
|
|
53
|
-
logs: CapturedLog[],
|
|
54
|
-
): KnowledgeCandidate[] {
|
|
55
|
-
if (logs.length === 0) return [];
|
|
56
|
-
|
|
57
|
-
const sorted = [...logs].sort((a, b) => a.id - b.id);
|
|
58
|
-
const logIds = sorted.map((log) => log.id);
|
|
59
|
-
const models = uniqueStrings(sorted.map((log) => log.model));
|
|
60
|
-
const project = firstProject(sorted);
|
|
61
|
-
const outcome = outcomeFor(sorted);
|
|
62
|
-
const lastUser = latestPreview(sorted, extractLastUserMessagePreview);
|
|
63
|
-
const response = latestPreview(sorted, extractResponsePreview);
|
|
64
|
-
const now = new Date().toISOString();
|
|
65
|
-
const titleProject = project === null ? "agent session" : `${project} agent session`;
|
|
66
|
-
|
|
67
|
-
const candidate: KnowledgeCandidate = {
|
|
68
|
-
id: candidateId(sessionId, "episode", logIds),
|
|
69
|
-
type: "episode",
|
|
70
|
-
title: `Episode: ${titleProject}`,
|
|
71
|
-
content: [
|
|
72
|
-
`Outcome: ${outcome}.`,
|
|
73
|
-
`Captured ${String(sorted.length)} log(s) for session ${sessionId}.`,
|
|
74
|
-
`Models: ${models.length === 0 ? "unknown" : models.join(", ")}.`,
|
|
75
|
-
`Last user request: ${lastUser}`,
|
|
76
|
-
`Latest response preview: ${response}`,
|
|
77
|
-
].join("\n"),
|
|
78
|
-
tags: ["agent-inspector", "episode", ...(project === null ? [] : [project])],
|
|
79
|
-
source: "agent-inspector",
|
|
80
|
-
sessionId,
|
|
81
|
-
logIds,
|
|
82
|
-
evidence: {
|
|
83
|
-
source: "agent-inspector",
|
|
84
|
-
sessionId,
|
|
85
|
-
logIds,
|
|
86
|
-
project,
|
|
87
|
-
models,
|
|
88
|
-
},
|
|
89
|
-
status: "draft",
|
|
90
|
-
createdAt: now,
|
|
91
|
-
updatedAt: now,
|
|
92
|
-
openClawMemoryId: null,
|
|
93
|
-
error: null,
|
|
94
|
-
redaction: { redacted: false, patterns: [] },
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
return [redactCandidate(candidate)];
|
|
98
|
-
}
|