@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,50 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { AddInspectorGroupSessionInputSchema } from "../../../lib/groupContract";
|
|
3
|
-
import { addInspectorGroupSession, readInspectorGroupSessions } from "../../../services/groups";
|
|
4
|
-
|
|
5
|
-
type JsonBodyResult = { ok: true; value: unknown } | { ok: false };
|
|
6
|
-
|
|
7
|
-
async function readJsonBody(request: Request): Promise<JsonBodyResult> {
|
|
8
|
-
try {
|
|
9
|
-
const raw = await request.text();
|
|
10
|
-
if (raw.trim().length === 0) return { ok: true, value: {} };
|
|
11
|
-
return { ok: true, value: JSON.parse(raw) };
|
|
12
|
-
} catch {
|
|
13
|
-
return { ok: false };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const Route = createFileRoute("/api/groups/$groupId/sessions")({
|
|
18
|
-
server: {
|
|
19
|
-
handlers: {
|
|
20
|
-
GET: ({ params }: { params: { groupId: string } }) => {
|
|
21
|
-
const sessions = readInspectorGroupSessions(params.groupId);
|
|
22
|
-
if (!sessions.ok) {
|
|
23
|
-
return Response.json({ error: sessions.message }, { status: sessions.status });
|
|
24
|
-
}
|
|
25
|
-
return Response.json(sessions.value);
|
|
26
|
-
},
|
|
27
|
-
POST: async ({ params, request }: { params: { groupId: string }; request: Request }) => {
|
|
28
|
-
const body = await readJsonBody(request);
|
|
29
|
-
if (!body.ok) {
|
|
30
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const parsed = AddInspectorGroupSessionInputSchema.safeParse(body.value);
|
|
34
|
-
if (!parsed.success) {
|
|
35
|
-
return Response.json(
|
|
36
|
-
{ error: "Invalid request body", details: parsed.error.format() },
|
|
37
|
-
{ status: 400 },
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const updated = addInspectorGroupSession(params.groupId, parsed.data);
|
|
42
|
-
if (!updated.ok) {
|
|
43
|
-
return Response.json({ error: updated.message }, { status: updated.status });
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return Response.json(updated.value);
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { UpdateInspectorGroupInputSchema } from "../../../lib/groupContract";
|
|
3
|
-
import {
|
|
4
|
-
deleteInspectorGroup,
|
|
5
|
-
getInspectorGroup,
|
|
6
|
-
updateInspectorGroup,
|
|
7
|
-
} from "../../../services/groups";
|
|
8
|
-
|
|
9
|
-
type JsonBodyResult = { ok: true; value: unknown } | { ok: false };
|
|
10
|
-
type DeleteEvidenceFlagResult = { ok: true; value: boolean | undefined } | { ok: false };
|
|
11
|
-
|
|
12
|
-
async function readJsonBody(request: Request): Promise<JsonBodyResult> {
|
|
13
|
-
try {
|
|
14
|
-
const raw = await request.text();
|
|
15
|
-
if (raw.trim().length === 0) return { ok: true, value: {} };
|
|
16
|
-
return { ok: true, value: JSON.parse(raw) };
|
|
17
|
-
} catch {
|
|
18
|
-
return { ok: false };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function readDeleteEvidenceFlag(request: Request): DeleteEvidenceFlagResult {
|
|
23
|
-
try {
|
|
24
|
-
const value = new URL(request.url).searchParams.get("deleteEvidence");
|
|
25
|
-
switch (value) {
|
|
26
|
-
case null:
|
|
27
|
-
return { ok: true, value: undefined };
|
|
28
|
-
case "1":
|
|
29
|
-
case "true":
|
|
30
|
-
return { ok: true, value: true };
|
|
31
|
-
case "0":
|
|
32
|
-
case "false":
|
|
33
|
-
return { ok: true, value: false };
|
|
34
|
-
default:
|
|
35
|
-
return { ok: false };
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
return { ok: false };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const Route = createFileRoute("/api/groups/$groupId")({
|
|
43
|
-
server: {
|
|
44
|
-
handlers: {
|
|
45
|
-
GET: ({ params }: { params: { groupId: string } }) => {
|
|
46
|
-
const group = getInspectorGroup(params.groupId);
|
|
47
|
-
if (!group.ok) {
|
|
48
|
-
return Response.json({ error: group.message }, { status: group.status });
|
|
49
|
-
}
|
|
50
|
-
return Response.json(group.value);
|
|
51
|
-
},
|
|
52
|
-
PATCH: async ({ params, request }: { params: { groupId: string }; request: Request }) => {
|
|
53
|
-
const body = await readJsonBody(request);
|
|
54
|
-
if (!body.ok) {
|
|
55
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const parsed = UpdateInspectorGroupInputSchema.safeParse(body.value);
|
|
59
|
-
if (!parsed.success) {
|
|
60
|
-
return Response.json(
|
|
61
|
-
{ error: "Invalid request body", details: parsed.error.format() },
|
|
62
|
-
{ status: 400 },
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const updated = updateInspectorGroup(params.groupId, parsed.data);
|
|
67
|
-
if (!updated.ok) {
|
|
68
|
-
return Response.json({ error: updated.message }, { status: updated.status });
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return Response.json(updated.value);
|
|
72
|
-
},
|
|
73
|
-
DELETE: ({ params, request }: { params: { groupId: string }; request: Request }) => {
|
|
74
|
-
const deleteEvidence = readDeleteEvidenceFlag(request);
|
|
75
|
-
if (!deleteEvidence.ok) {
|
|
76
|
-
return Response.json(
|
|
77
|
-
{ error: "deleteEvidence must be one of true, false, 1, or 0" },
|
|
78
|
-
{ status: 400 },
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const deleted = deleteInspectorGroup(params.groupId, {
|
|
83
|
-
deleteEvidence: deleteEvidence.value,
|
|
84
|
-
});
|
|
85
|
-
if (!deleted.ok) {
|
|
86
|
-
return Response.json({ error: deleted.message }, { status: deleted.status });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return Response.json(deleted.value);
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
});
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { CreateInspectorGroupInputSchema } from "../../../lib/groupContract";
|
|
3
|
-
import {
|
|
4
|
-
createInspectorGroup,
|
|
5
|
-
deleteInspectorGroups,
|
|
6
|
-
listInspectorGroups,
|
|
7
|
-
} from "../../../services/groups";
|
|
8
|
-
|
|
9
|
-
type JsonBodyResult = { ok: true; value: unknown } | { ok: false };
|
|
10
|
-
type DeleteEvidenceFlagResult = { ok: true; value: boolean | undefined } | { ok: false };
|
|
11
|
-
|
|
12
|
-
async function readJsonBody(request: Request): Promise<JsonBodyResult> {
|
|
13
|
-
try {
|
|
14
|
-
const raw = await request.text();
|
|
15
|
-
if (raw.trim().length === 0) return { ok: true, value: undefined };
|
|
16
|
-
return { ok: true, value: JSON.parse(raw) };
|
|
17
|
-
} catch {
|
|
18
|
-
return { ok: false };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function readDeleteEvidenceFlag(request: Request): DeleteEvidenceFlagResult {
|
|
23
|
-
try {
|
|
24
|
-
const value = new URL(request.url).searchParams.get("deleteEvidence");
|
|
25
|
-
switch (value) {
|
|
26
|
-
case null:
|
|
27
|
-
return { ok: true, value: undefined };
|
|
28
|
-
case "1":
|
|
29
|
-
case "true":
|
|
30
|
-
return { ok: true, value: true };
|
|
31
|
-
case "0":
|
|
32
|
-
case "false":
|
|
33
|
-
return { ok: true, value: false };
|
|
34
|
-
default:
|
|
35
|
-
return { ok: false };
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
return { ok: false };
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export const Route = createFileRoute("/api/groups")({
|
|
43
|
-
server: {
|
|
44
|
-
handlers: {
|
|
45
|
-
GET: () => Response.json(listInspectorGroups()),
|
|
46
|
-
POST: async ({ request }: { request: Request }) => {
|
|
47
|
-
const body = await readJsonBody(request);
|
|
48
|
-
if (!body.ok) {
|
|
49
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const parsed = CreateInspectorGroupInputSchema.safeParse(body.value);
|
|
53
|
-
if (!parsed.success) {
|
|
54
|
-
return Response.json(
|
|
55
|
-
{ error: "Invalid request body", details: parsed.error.format() },
|
|
56
|
-
{ status: 400 },
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return Response.json(createInspectorGroup(parsed.data), { status: 201 });
|
|
61
|
-
},
|
|
62
|
-
DELETE: ({ request }: { request: Request }) => {
|
|
63
|
-
const deleteEvidence = readDeleteEvidenceFlag(request);
|
|
64
|
-
if (!deleteEvidence.ok) {
|
|
65
|
-
return Response.json(
|
|
66
|
-
{ error: "deleteEvidence must be one of true, false, 1, or 0" },
|
|
67
|
-
{ status: 400 },
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return Response.json(
|
|
72
|
-
deleteInspectorGroups({
|
|
73
|
-
deleteEvidence: deleteEvidence.value,
|
|
74
|
-
}),
|
|
75
|
-
);
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { logger } from "../../../proxy/logger";
|
|
3
|
-
import { getRuntimeReadiness } from "../../../proxy/runtimeHealth";
|
|
4
|
-
import { installRuntimeShutdownSignalHandlers } from "../../../proxy/runtimeShutdown";
|
|
5
|
-
|
|
6
|
-
// Trigger logger auto-initialization when this module loads
|
|
7
|
-
installRuntimeShutdownSignalHandlers();
|
|
8
|
-
logger.debug("Health endpoint loaded");
|
|
9
|
-
|
|
10
|
-
export const Route = createFileRoute("/api/health")({
|
|
11
|
-
server: {
|
|
12
|
-
handlers: {
|
|
13
|
-
GET: async () => {
|
|
14
|
-
const readiness = await getRuntimeReadiness();
|
|
15
|
-
return Response.json(
|
|
16
|
-
{ status: "ok", readiness: readiness.status },
|
|
17
|
-
{ headers: { "cache-control": "no-store" } },
|
|
18
|
-
);
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { getNamedInstanceConnection } from "../../../cli/instance";
|
|
3
|
-
import { instanceResultResponse } from "./-instances";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/api/instances/$name/connection")({
|
|
6
|
-
server: {
|
|
7
|
-
handlers: {
|
|
8
|
-
GET: async ({ params }: { params: { name: string } }) =>
|
|
9
|
-
instanceResultResponse(await getNamedInstanceConnection(params.name)),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { restartNamedInstance } from "../../../cli/instance";
|
|
3
|
-
import { InstanceStartRequestSchema } from "../../../lib/instanceContract";
|
|
4
|
-
import {
|
|
5
|
-
instanceErrorResponse,
|
|
6
|
-
instanceResultResponse,
|
|
7
|
-
parseInstanceBody,
|
|
8
|
-
selfLifecycleError,
|
|
9
|
-
} from "./-instances";
|
|
10
|
-
|
|
11
|
-
export const Route = createFileRoute("/api/instances/$name/restart")({
|
|
12
|
-
server: {
|
|
13
|
-
handlers: {
|
|
14
|
-
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
15
|
-
const body = await parseInstanceBody(request, InstanceStartRequestSchema);
|
|
16
|
-
if (!body.ok) return body.response;
|
|
17
|
-
const selfError = selfLifecycleError(params.name);
|
|
18
|
-
if (selfError !== null) return instanceErrorResponse(selfError);
|
|
19
|
-
return instanceResultResponse(await restartNamedInstance(params.name, body.value));
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { startNamedInstance } from "../../../cli/instance";
|
|
3
|
-
import { InstanceStartRequestSchema } from "../../../lib/instanceContract";
|
|
4
|
-
import { instanceResultResponse, parseInstanceBody } from "./-instances";
|
|
5
|
-
|
|
6
|
-
export const Route = createFileRoute("/api/instances/$name/start")({
|
|
7
|
-
server: {
|
|
8
|
-
handlers: {
|
|
9
|
-
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
10
|
-
const body = await parseInstanceBody(request, InstanceStartRequestSchema);
|
|
11
|
-
if (!body.ok) return body.response;
|
|
12
|
-
const result = await startNamedInstance(params.name, body.value);
|
|
13
|
-
const status = result.kind === "success" && result.value.outcome === "created" ? 201 : 200;
|
|
14
|
-
return instanceResultResponse(result, status);
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { stopNamedInstance } from "../../../cli/instance";
|
|
3
|
-
import { InstanceEmptyRequestSchema } from "../../../lib/instanceContract";
|
|
4
|
-
import {
|
|
5
|
-
instanceErrorResponse,
|
|
6
|
-
instanceResultResponse,
|
|
7
|
-
parseInstanceBody,
|
|
8
|
-
selfLifecycleError,
|
|
9
|
-
} from "./-instances";
|
|
10
|
-
|
|
11
|
-
export const Route = createFileRoute("/api/instances/$name/stop")({
|
|
12
|
-
server: {
|
|
13
|
-
handlers: {
|
|
14
|
-
POST: async ({ params, request }: { params: { name: string }; request: Request }) => {
|
|
15
|
-
const body = await parseInstanceBody(request, InstanceEmptyRequestSchema);
|
|
16
|
-
if (!body.ok) return body.response;
|
|
17
|
-
const selfError = selfLifecycleError(params.name);
|
|
18
|
-
if (selfError !== null) return instanceErrorResponse(selfError);
|
|
19
|
-
return instanceResultResponse(await stopNamedInstance(params.name));
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { getNamedInstance } from "../../../cli/instance";
|
|
3
|
-
import { instanceResultResponse } from "./-instances";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/api/instances/$name")({
|
|
6
|
-
server: {
|
|
7
|
-
handlers: {
|
|
8
|
-
GET: async ({ params }: { params: { name: string } }) =>
|
|
9
|
-
instanceResultResponse(await getNamedInstance(params.name)),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
});
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { listNamedInstances } from "../../../cli/instance";
|
|
3
|
-
import { instanceListResponse, instanceResultResponse } from "./-instances";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/api/instances")({
|
|
6
|
-
server: {
|
|
7
|
-
handlers: {
|
|
8
|
-
GET: async () => {
|
|
9
|
-
const result = await listNamedInstances();
|
|
10
|
-
return result.kind === "error"
|
|
11
|
-
? instanceResultResponse(result)
|
|
12
|
-
: instanceListResponse(result.value);
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import {
|
|
3
|
-
getCandidate,
|
|
4
|
-
markCandidateFailed,
|
|
5
|
-
markCandidatePromoted,
|
|
6
|
-
} from "../../../knowledge/candidateStore";
|
|
7
|
-
import { promoteToOpenClaw } from "../../../knowledge/openclawClient";
|
|
8
|
-
|
|
9
|
-
export const Route = createFileRoute("/api/knowledge/candidates/$candidateId/promote")({
|
|
10
|
-
server: {
|
|
11
|
-
handlers: {
|
|
12
|
-
POST: async ({ params }: { params: { candidateId: string } }) => {
|
|
13
|
-
const candidate = getCandidate(params.candidateId);
|
|
14
|
-
if (candidate === null) {
|
|
15
|
-
return Response.json({ error: "Knowledge candidate not found" }, { status: 404 });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const result = await promoteToOpenClaw(candidate);
|
|
19
|
-
if (!result.success) {
|
|
20
|
-
const updated = markCandidateFailed(candidate.id, result.error);
|
|
21
|
-
return Response.json(
|
|
22
|
-
{ error: result.error, candidate: updated ?? candidate },
|
|
23
|
-
{ status: 400 },
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const updated = markCandidatePromoted(candidate.id, result.memoryId);
|
|
28
|
-
return Response.json({ candidate: updated ?? candidate });
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { getCandidate, updateCandidateDraft } from "../../../knowledge/candidateStore";
|
|
4
|
-
import { KnowledgeCandidateSchema, KnowledgeCandidateTypeSchema } from "../../../knowledge/types";
|
|
5
|
-
|
|
6
|
-
const CandidateUpdateSchema = z
|
|
7
|
-
.object({
|
|
8
|
-
type: KnowledgeCandidateTypeSchema.optional(),
|
|
9
|
-
title: z.string().trim().min(1).max(160).optional(),
|
|
10
|
-
content: z.string().trim().min(1).max(12000).optional(),
|
|
11
|
-
tags: z.array(z.string().trim().min(1).max(64)).max(24).optional(),
|
|
12
|
-
})
|
|
13
|
-
.strict();
|
|
14
|
-
|
|
15
|
-
const CandidateUpdateResponseSchema = z.object({
|
|
16
|
-
candidate: KnowledgeCandidateSchema,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export type CandidateUpdateResponse = z.infer<typeof CandidateUpdateResponseSchema>;
|
|
20
|
-
|
|
21
|
-
export const Route = createFileRoute("/api/knowledge/candidates/$candidateId")({
|
|
22
|
-
server: {
|
|
23
|
-
handlers: {
|
|
24
|
-
PATCH: async ({ params, request }: { params: { candidateId: string }; request: Request }) => {
|
|
25
|
-
const existing = getCandidate(params.candidateId);
|
|
26
|
-
if (existing === null) {
|
|
27
|
-
return Response.json({ error: "Knowledge candidate not found" }, { status: 404 });
|
|
28
|
-
}
|
|
29
|
-
if (existing.status === "promoted") {
|
|
30
|
-
return Response.json(
|
|
31
|
-
{ error: "Promoted knowledge candidates cannot be edited" },
|
|
32
|
-
{ status: 409 },
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const raw: unknown = await request.json().catch(() => null);
|
|
37
|
-
const parsed = CandidateUpdateSchema.safeParse(raw);
|
|
38
|
-
if (!parsed.success) {
|
|
39
|
-
return Response.json({ error: parsed.error.message }, { status: 400 });
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const updated = updateCandidateDraft(existing.id, parsed.data);
|
|
43
|
-
if (updated === null) {
|
|
44
|
-
return Response.json({ error: "Knowledge candidate update failed" }, { status: 409 });
|
|
45
|
-
}
|
|
46
|
-
return Response.json({ candidate: updated } satisfies CandidateUpdateResponse);
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { listCandidates } from "../../../knowledge/candidateStore";
|
|
3
|
-
|
|
4
|
-
export const Route = createFileRoute("/api/knowledge/candidates")({
|
|
5
|
-
server: {
|
|
6
|
-
handlers: {
|
|
7
|
-
GET: () => Response.json({ candidates: listCandidates() }),
|
|
8
|
-
},
|
|
9
|
-
},
|
|
10
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { searchOpenClaw } from "../../../knowledge/openclawClient";
|
|
3
|
-
import { MAX_SEARCH_PROJECT_CHARS, resourceLimitResponse } from "../../../lib/resourceLimits";
|
|
4
|
-
|
|
5
|
-
export const Route = createFileRoute("/api/knowledge/project-context")({
|
|
6
|
-
server: {
|
|
7
|
-
handlers: {
|
|
8
|
-
GET: async ({ request }: { request: Request }) => {
|
|
9
|
-
const url = new URL(request.url);
|
|
10
|
-
const project = url.searchParams.get("project") ?? "";
|
|
11
|
-
if (project === "") {
|
|
12
|
-
return Response.json({ error: "Missing project search parameter" }, { status: 400 });
|
|
13
|
-
}
|
|
14
|
-
if (project.length > MAX_SEARCH_PROJECT_CHARS) {
|
|
15
|
-
return resourceLimitResponse({
|
|
16
|
-
error: `Search project filters may contain at most ${String(MAX_SEARCH_PROJECT_CHARS)} characters.`,
|
|
17
|
-
code: "search-limit-exceeded",
|
|
18
|
-
status: 400,
|
|
19
|
-
resource: "knowledge-search-project",
|
|
20
|
-
limit: MAX_SEARCH_PROJECT_CHARS,
|
|
21
|
-
retryable: false,
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
const response = await searchOpenClaw(`project context ${project}`, project);
|
|
25
|
-
return Response.json({ project, ...response });
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { searchOpenClaw } from "../../../knowledge/openclawClient";
|
|
4
|
-
import { MAX_SEARCH_QUERY_CHARS, resourceLimitResponse } from "../../../lib/resourceLimits";
|
|
5
|
-
|
|
6
|
-
const SearchBodySchema = z.object({
|
|
7
|
-
query: z.string().min(1).max(MAX_SEARCH_QUERY_CHARS),
|
|
8
|
-
project: z.string().optional(),
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
function searchLimitResponse(): Response {
|
|
12
|
-
return resourceLimitResponse({
|
|
13
|
-
error: `Search queries may contain at most ${String(MAX_SEARCH_QUERY_CHARS)} characters.`,
|
|
14
|
-
code: "search-limit-exceeded",
|
|
15
|
-
status: 400,
|
|
16
|
-
resource: "knowledge-search-query",
|
|
17
|
-
limit: MAX_SEARCH_QUERY_CHARS,
|
|
18
|
-
retryable: false,
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function bodySearchQuery(value: unknown): string | null {
|
|
23
|
-
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
24
|
-
const descriptor = Object.getOwnPropertyDescriptor(value, "query");
|
|
25
|
-
if (descriptor === undefined) return null;
|
|
26
|
-
const query: unknown = descriptor.value;
|
|
27
|
-
return typeof query === "string" ? query : null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export const Route = createFileRoute("/api/knowledge/search")({
|
|
31
|
-
server: {
|
|
32
|
-
handlers: {
|
|
33
|
-
GET: async ({ request }: { request: Request }) => {
|
|
34
|
-
const url = new URL(request.url);
|
|
35
|
-
const query = url.searchParams.get("q") ?? "";
|
|
36
|
-
const project = url.searchParams.get("project") ?? undefined;
|
|
37
|
-
if (query === "") {
|
|
38
|
-
return Response.json({ error: "Missing q search parameter" }, { status: 400 });
|
|
39
|
-
}
|
|
40
|
-
if (query.length > MAX_SEARCH_QUERY_CHARS) return searchLimitResponse();
|
|
41
|
-
return Response.json(await searchOpenClaw(query, project));
|
|
42
|
-
},
|
|
43
|
-
POST: async ({ request }: { request: Request }) => {
|
|
44
|
-
let body: unknown;
|
|
45
|
-
try {
|
|
46
|
-
body = await request.json();
|
|
47
|
-
} catch {
|
|
48
|
-
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
|
|
49
|
-
}
|
|
50
|
-
const query = bodySearchQuery(body);
|
|
51
|
-
if (query !== null && query.length > MAX_SEARCH_QUERY_CHARS) {
|
|
52
|
-
return searchLimitResponse();
|
|
53
|
-
}
|
|
54
|
-
const parsed = SearchBodySchema.safeParse(body);
|
|
55
|
-
if (!parsed.success) {
|
|
56
|
-
return Response.json({ error: parsed.error.message }, { status: 400 });
|
|
57
|
-
}
|
|
58
|
-
return Response.json(await searchOpenClaw(parsed.data.query, parsed.data.project));
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
});
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { getFilteredLogs, getLogSessionId } from "../../../proxy/store";
|
|
3
|
-
import { distillSessionCandidates } from "../../../knowledge/distiller";
|
|
4
|
-
import { saveCandidates } from "../../../knowledge/candidateStore";
|
|
5
|
-
|
|
6
|
-
function getCandidateScopeId(log: ReturnType<typeof getFilteredLogs>[number]): string {
|
|
7
|
-
return getLogSessionId(log) ?? "default";
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function getLogsForCandidateScope(scopeId: string): ReturnType<typeof getFilteredLogs> {
|
|
11
|
-
const direct = getFilteredLogs(scopeId);
|
|
12
|
-
if (direct.length > 0) return direct;
|
|
13
|
-
return getFilteredLogs().filter((log) => getCandidateScopeId(log) === scopeId);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const Route = createFileRoute("/api/knowledge/sessions/$sessionId/candidates")({
|
|
17
|
-
server: {
|
|
18
|
-
handlers: {
|
|
19
|
-
POST: ({ params }: { params: { sessionId: string } }) => {
|
|
20
|
-
const logs = getLogsForCandidateScope(params.sessionId);
|
|
21
|
-
const candidates = saveCandidates(distillSessionCandidates(params.sessionId, logs));
|
|
22
|
-
return Response.json({ candidates });
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
});
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { LogBodyPartSchema, parseLogId } from "../../../contracts";
|
|
3
|
-
import {
|
|
4
|
-
createLogBodyChunk,
|
|
5
|
-
DEFAULT_LOG_BODY_CHUNK_BYTES,
|
|
6
|
-
MAX_LOG_BODY_CHUNK_BYTES,
|
|
7
|
-
} from "../../../proxy/logBodyChunks";
|
|
8
|
-
import { getLogById } from "../../../proxy/store";
|
|
9
|
-
import { parseBoundedIntegerParameter } from "../../../lib/resourceLimits";
|
|
10
|
-
|
|
11
|
-
function parseIntegerParam(value: string | null, fallback: number): number {
|
|
12
|
-
if (value === null) return fallback;
|
|
13
|
-
const parsed = Number(value);
|
|
14
|
-
if (!Number.isInteger(parsed)) return fallback;
|
|
15
|
-
return parsed;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const Route = createFileRoute("/api/logs/$id/body")({
|
|
19
|
-
server: {
|
|
20
|
-
handlers: {
|
|
21
|
-
GET: async ({ params, request }: { params: { id: string }; request: Request }) => {
|
|
22
|
-
const id = parseLogId(params.id);
|
|
23
|
-
if (id === null) {
|
|
24
|
-
return Response.json({ error: "Invalid log ID" }, { status: 400 });
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const url = new URL(request.url);
|
|
28
|
-
const partResult = LogBodyPartSchema.safeParse(url.searchParams.get("part"));
|
|
29
|
-
if (!partResult.success) {
|
|
30
|
-
return Response.json({ error: "Invalid body part" }, { status: 400 });
|
|
31
|
-
}
|
|
32
|
-
const limitResult = parseBoundedIntegerParameter({
|
|
33
|
-
value: url.searchParams.get("limit"),
|
|
34
|
-
parameter: "limit",
|
|
35
|
-
fallback: DEFAULT_LOG_BODY_CHUNK_BYTES,
|
|
36
|
-
minimum: 1,
|
|
37
|
-
maximum: MAX_LOG_BODY_CHUNK_BYTES,
|
|
38
|
-
resource: "log-body-page-bytes",
|
|
39
|
-
});
|
|
40
|
-
if (!limitResult.ok) return limitResult.response;
|
|
41
|
-
|
|
42
|
-
const log = await getLogById(id);
|
|
43
|
-
if (log === null) {
|
|
44
|
-
return Response.json({ error: "Log not found" }, { status: 404 });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return Response.json(
|
|
48
|
-
createLogBodyChunk({
|
|
49
|
-
log,
|
|
50
|
-
part: partResult.data,
|
|
51
|
-
offset: parseIntegerParam(url.searchParams.get("offset"), 0),
|
|
52
|
-
limit: limitResult.value,
|
|
53
|
-
}),
|
|
54
|
-
);
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createFileRoute } from "@tanstack/react-router";
|
|
2
|
-
import { parseLogId } from "../../../contracts";
|
|
3
|
-
import { getLogById } from "../../../proxy/store";
|
|
4
|
-
import { readChunks } from "../../../proxy/chunkStorage";
|
|
5
|
-
|
|
6
|
-
export const Route = createFileRoute("/api/logs/$id/chunks")({
|
|
7
|
-
server: {
|
|
8
|
-
handlers: {
|
|
9
|
-
GET: async ({ params }: { params: { id: string } }) => {
|
|
10
|
-
const id = parseLogId(params.id);
|
|
11
|
-
if (id === null) {
|
|
12
|
-
return Response.json({ error: "Invalid log ID" }, { status: 400 });
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const log = await getLogById(id);
|
|
16
|
-
if (log === null) {
|
|
17
|
-
return Response.json({ error: "Log not found" }, { status: 404 });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Try disk file first (persistent chunks from real proxy streaming)
|
|
21
|
-
if (log.streamingChunksPath !== null && log.streamingChunksPath !== undefined) {
|
|
22
|
-
const chunksData = readChunks(log.streamingChunksPath);
|
|
23
|
-
if (chunksData !== null) {
|
|
24
|
-
return Response.json(chunksData);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Fall back to in-memory streamingChunks (e.g., from provider test)
|
|
29
|
-
if (log.streamingChunks !== undefined && log.streamingChunks.chunks.length > 0) {
|
|
30
|
-
return Response.json(log.streamingChunks);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return Response.json({ error: "Chunks not found" }, { status: 404 });
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
});
|