@oscharko-dev/keiko-server 0.2.0
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/dist/.tsbuildinfo +1 -0
- package/dist/assistant-response.d.ts +6 -0
- package/dist/assistant-response.d.ts.map +1 -0
- package/dist/assistant-response.js +12 -0
- package/dist/browser.d.ts +11 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +245 -0
- package/dist/chat-handlers.d.ts +48 -0
- package/dist/chat-handlers.d.ts.map +1 -0
- package/dist/chat-handlers.js +821 -0
- package/dist/chat-stream-handlers.d.ts +4 -0
- package/dist/chat-stream-handlers.d.ts.map +1 -0
- package/dist/chat-stream-handlers.js +136 -0
- package/dist/conversation-prompt.d.ts +8 -0
- package/dist/conversation-prompt.d.ts.map +1 -0
- package/dist/conversation-prompt.js +36 -0
- package/dist/conversation-validation.d.ts +26 -0
- package/dist/conversation-validation.d.ts.map +1 -0
- package/dist/conversation-validation.js +125 -0
- package/dist/credentialPersistence.d.ts +23 -0
- package/dist/credentialPersistence.d.ts.map +1 -0
- package/dist/credentialPersistence.js +93 -0
- package/dist/credentialVault.d.ts +30 -0
- package/dist/credentialVault.d.ts.map +1 -0
- package/dist/credentialVault.js +206 -0
- package/dist/csp.d.ts +3 -0
- package/dist/csp.d.ts.map +1 -0
- package/dist/csp.js +75 -0
- package/dist/deps.d.ts +78 -0
- package/dist/deps.d.ts.map +1 -0
- package/dist/deps.js +457 -0
- package/dist/editor/agentRoutes.d.ts +7 -0
- package/dist/editor/agentRoutes.d.ts.map +1 -0
- package/dist/editor/agentRoutes.js +197 -0
- package/dist/editor/assuredGateRunner.d.ts +36 -0
- package/dist/editor/assuredGateRunner.d.ts.map +1 -0
- package/dist/editor/assuredGateRunner.js +100 -0
- package/dist/editor/assuredPreFilter.d.ts +34 -0
- package/dist/editor/assuredPreFilter.d.ts.map +1 -0
- package/dist/editor/assuredPreFilter.js +134 -0
- package/dist/editor/assuredPreFilterRunner.d.ts +31 -0
- package/dist/editor/assuredPreFilterRunner.d.ts.map +1 -0
- package/dist/editor/assuredPreFilterRunner.js +312 -0
- package/dist/editor/builtinLanguageProviders.d.ts +6 -0
- package/dist/editor/builtinLanguageProviders.d.ts.map +1 -0
- package/dist/editor/builtinLanguageProviders.js +221 -0
- package/dist/editor/codingContext.d.ts +12 -0
- package/dist/editor/codingContext.d.ts.map +1 -0
- package/dist/editor/codingContext.js +121 -0
- package/dist/editor/codingContextEvidence.d.ts +7 -0
- package/dist/editor/codingContextEvidence.d.ts.map +1 -0
- package/dist/editor/codingContextEvidence.js +52 -0
- package/dist/editor/codingContextProviders.d.ts +36 -0
- package/dist/editor/codingContextProviders.d.ts.map +1 -0
- package/dist/editor/codingContextProviders.js +348 -0
- package/dist/editor/completionModelEvidence.d.ts +16 -0
- package/dist/editor/completionModelEvidence.d.ts.map +1 -0
- package/dist/editor/completionModelEvidence.js +50 -0
- package/dist/editor/completionRoutes.d.ts +37 -0
- package/dist/editor/completionRoutes.d.ts.map +1 -0
- package/dist/editor/completionRoutes.js +411 -0
- package/dist/editor/contextRoutes.d.ts +6 -0
- package/dist/editor/contextRoutes.d.ts.map +1 -0
- package/dist/editor/contextRoutes.js +411 -0
- package/dist/editor/disposableAssuredExecution.d.ts +22 -0
- package/dist/editor/disposableAssuredExecution.d.ts.map +1 -0
- package/dist/editor/disposableAssuredExecution.js +57 -0
- package/dist/editor/editorCompletionModel.d.ts +47 -0
- package/dist/editor/editorCompletionModel.d.ts.map +1 -0
- package/dist/editor/editorCompletionModel.js +156 -0
- package/dist/editor/editorInlineCompletionModel.d.ts +34 -0
- package/dist/editor/editorInlineCompletionModel.d.ts.map +1 -0
- package/dist/editor/editorInlineCompletionModel.js +112 -0
- package/dist/editor/editorModelTokenBudget.d.ts +46 -0
- package/dist/editor/editorModelTokenBudget.d.ts.map +1 -0
- package/dist/editor/editorModelTokenBudget.js +121 -0
- package/dist/editor/inlineCompletionRateLimiter.d.ts +19 -0
- package/dist/editor/inlineCompletionRateLimiter.d.ts.map +1 -0
- package/dist/editor/inlineCompletionRateLimiter.js +46 -0
- package/dist/editor/inlineCompletionRoutes.d.ts +26 -0
- package/dist/editor/inlineCompletionRoutes.d.ts.map +1 -0
- package/dist/editor/inlineCompletionRoutes.js +404 -0
- package/dist/editor/inlineCompletionTelemetryEvidence.d.ts +5 -0
- package/dist/editor/inlineCompletionTelemetryEvidence.d.ts.map +1 -0
- package/dist/editor/inlineCompletionTelemetryEvidence.js +42 -0
- package/dist/editor/languageCancellation.d.ts +19 -0
- package/dist/editor/languageCancellation.d.ts.map +1 -0
- package/dist/editor/languageCancellation.js +48 -0
- package/dist/editor/languageProvider.d.ts +39 -0
- package/dist/editor/languageProvider.d.ts.map +1 -0
- package/dist/editor/languageProvider.js +11 -0
- package/dist/editor/languageRoutes.d.ts +15 -0
- package/dist/editor/languageRoutes.d.ts.map +1 -0
- package/dist/editor/languageRoutes.js +106 -0
- package/dist/editor/languageSanitize.d.ts +8 -0
- package/dist/editor/languageSanitize.d.ts.map +1 -0
- package/dist/editor/languageSanitize.js +101 -0
- package/dist/editor/languageService.d.ts +36 -0
- package/dist/editor/languageService.d.ts.map +1 -0
- package/dist/editor/languageService.js +93 -0
- package/dist/editor/languageServiceHost.d.ts +14 -0
- package/dist/editor/languageServiceHost.d.ts.map +1 -0
- package/dist/editor/languageServiceHost.js +242 -0
- package/dist/editor/localKnowledgeRetrieval.d.ts +21 -0
- package/dist/editor/localKnowledgeRetrieval.d.ts.map +1 -0
- package/dist/editor/localKnowledgeRetrieval.js +44 -0
- package/dist/editor/patchApplyEvidence.d.ts +21 -0
- package/dist/editor/patchApplyEvidence.d.ts.map +1 -0
- package/dist/editor/patchApplyEvidence.js +87 -0
- package/dist/editor/patchApplyRoutes.d.ts +16 -0
- package/dist/editor/patchApplyRoutes.d.ts.map +1 -0
- package/dist/editor/patchApplyRoutes.js +307 -0
- package/dist/editor/postApplyVerification.d.ts +42 -0
- package/dist/editor/postApplyVerification.d.ts.map +1 -0
- package/dist/editor/postApplyVerification.js +177 -0
- package/dist/editor/testGenerationEvidence.d.ts +6 -0
- package/dist/editor/testGenerationEvidence.d.ts.map +1 -0
- package/dist/editor/testGenerationEvidence.js +72 -0
- package/dist/editor/testGenerationPatch.d.ts +10 -0
- package/dist/editor/testGenerationPatch.d.ts.map +1 -0
- package/dist/editor/testGenerationPatch.js +66 -0
- package/dist/editor/testGenerationRoutes.d.ts +21 -0
- package/dist/editor/testGenerationRoutes.d.ts.map +1 -0
- package/dist/editor/testGenerationRoutes.js +254 -0
- package/dist/editor/testGenerationRunner.d.ts +23 -0
- package/dist/editor/testGenerationRunner.d.ts.map +1 -0
- package/dist/editor/testGenerationRunner.js +120 -0
- package/dist/editor/textOffsets.d.ts +6 -0
- package/dist/editor/textOffsets.d.ts.map +1 -0
- package/dist/editor/textOffsets.js +82 -0
- package/dist/editor/typescriptLanguageProvider.d.ts +3 -0
- package/dist/editor/typescriptLanguageProvider.d.ts.map +1 -0
- package/dist/editor/typescriptLanguageProvider.js +217 -0
- package/dist/evidence.d.ts +28 -0
- package/dist/evidence.d.ts.map +1 -0
- package/dist/evidence.js +145 -0
- package/dist/files-deny.d.ts +3 -0
- package/dist/files-deny.d.ts.map +1 -0
- package/dist/files-deny.js +12 -0
- package/dist/files.d.ts +97 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +733 -0
- package/dist/gateway-setup.d.ts +10 -0
- package/dist/gateway-setup.d.ts.map +1 -0
- package/dist/gateway-setup.js +896 -0
- package/dist/governed-workflow.d.ts +17 -0
- package/dist/governed-workflow.d.ts.map +1 -0
- package/dist/governed-workflow.js +147 -0
- package/dist/grounded-answer.d.ts +12 -0
- package/dist/grounded-answer.d.ts.map +1 -0
- package/dist/grounded-answer.js +69 -0
- package/dist/grounded-context-index.d.ts +25 -0
- package/dist/grounded-context-index.d.ts.map +1 -0
- package/dist/grounded-context-index.js +169 -0
- package/dist/grounded-document-evidence.d.ts +28 -0
- package/dist/grounded-document-evidence.d.ts.map +1 -0
- package/dist/grounded-document-evidence.js +430 -0
- package/dist/grounded-handoff.d.ts +4 -0
- package/dist/grounded-handoff.d.ts.map +1 -0
- package/dist/grounded-handoff.js +445 -0
- package/dist/grounded-orchestrator.d.ts +43 -0
- package/dist/grounded-orchestrator.d.ts.map +1 -0
- package/dist/grounded-orchestrator.js +1445 -0
- package/dist/grounded-prompt.d.ts +2 -0
- package/dist/grounded-prompt.d.ts.map +1 -0
- package/dist/grounded-prompt.js +17 -0
- package/dist/grounded-qa-hybrid.d.ts +36 -0
- package/dist/grounded-qa-hybrid.d.ts.map +1 -0
- package/dist/grounded-qa-hybrid.js +762 -0
- package/dist/grounded-qa-multi-source.d.ts +38 -0
- package/dist/grounded-qa-multi-source.d.ts.map +1 -0
- package/dist/grounded-qa-multi-source.js +461 -0
- package/dist/grounded-qa.d.ts +45 -0
- package/dist/grounded-qa.d.ts.map +1 -0
- package/dist/grounded-qa.js +877 -0
- package/dist/grounded-rerank.d.ts +26 -0
- package/dist/grounded-rerank.d.ts.map +1 -0
- package/dist/grounded-rerank.js +72 -0
- package/dist/grounded-turn-registry.d.ts +23 -0
- package/dist/grounded-turn-registry.d.ts.map +1 -0
- package/dist/grounded-turn-registry.js +102 -0
- package/dist/headers.d.ts +3 -0
- package/dist/headers.d.ts.map +1 -0
- package/dist/headers.js +22 -0
- package/dist/host-check.d.ts +3 -0
- package/dist/host-check.d.ts.map +1 -0
- package/dist/host-check.js +58 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/load-csp.d.ts +3 -0
- package/dist/load-csp.d.ts.map +1 -0
- package/dist/load-csp.js +100 -0
- package/dist/local-knowledge-grounded-qa.d.ts +42 -0
- package/dist/local-knowledge-grounded-qa.d.ts.map +1 -0
- package/dist/local-knowledge-grounded-qa.js +678 -0
- package/dist/local-knowledge-handlers.d.ts +24 -0
- package/dist/local-knowledge-handlers.d.ts.map +1 -0
- package/dist/local-knowledge-handlers.js +1285 -0
- package/dist/local-knowledge-indexing-registry.d.ts +13 -0
- package/dist/local-knowledge-indexing-registry.d.ts.map +1 -0
- package/dist/local-knowledge-indexing-registry.js +53 -0
- package/dist/localKnowledgeKeyProvider.d.ts +11 -0
- package/dist/localKnowledgeKeyProvider.d.ts.map +1 -0
- package/dist/localKnowledgeKeyProvider.js +48 -0
- package/dist/memory-audit-event-builders.d.ts +21 -0
- package/dist/memory-audit-event-builders.d.ts.map +1 -0
- package/dist/memory-audit-event-builders.js +187 -0
- package/dist/memory-audit-handler.d.ts +23 -0
- package/dist/memory-audit-handler.d.ts.map +1 -0
- package/dist/memory-audit-handler.js +191 -0
- package/dist/memory-capture-policy.d.ts +10 -0
- package/dist/memory-capture-policy.d.ts.map +1 -0
- package/dist/memory-capture-policy.js +44 -0
- package/dist/memory-consolidation-handlers.d.ts +6 -0
- package/dist/memory-consolidation-handlers.d.ts.map +1 -0
- package/dist/memory-consolidation-handlers.js +491 -0
- package/dist/memory-consolidation-registry.d.ts +47 -0
- package/dist/memory-consolidation-registry.d.ts.map +1 -0
- package/dist/memory-consolidation-registry.js +106 -0
- package/dist/memory-conv-handlers.d.ts +8 -0
- package/dist/memory-conv-handlers.d.ts.map +1 -0
- package/dist/memory-conv-handlers.js +369 -0
- package/dist/memory-conversation-context.d.ts +13 -0
- package/dist/memory-conversation-context.d.ts.map +1 -0
- package/dist/memory-conversation-context.js +22 -0
- package/dist/memory-diagnostics.d.ts +29 -0
- package/dist/memory-diagnostics.d.ts.map +1 -0
- package/dist/memory-diagnostics.js +122 -0
- package/dist/memory-embedding.d.ts +21 -0
- package/dist/memory-embedding.d.ts.map +1 -0
- package/dist/memory-embedding.js +264 -0
- package/dist/memory-handlers.d.ts +19 -0
- package/dist/memory-handlers.d.ts.map +1 -0
- package/dist/memory-handlers.js +1204 -0
- package/dist/memory-maintenance-handlers.d.ts +35 -0
- package/dist/memory-maintenance-handlers.d.ts.map +1 -0
- package/dist/memory-maintenance-handlers.js +219 -0
- package/dist/memory-record-builders.d.ts +4 -0
- package/dist/memory-record-builders.d.ts.map +1 -0
- package/dist/memory-record-builders.js +19 -0
- package/dist/memory-retention.d.ts +31 -0
- package/dist/memory-retention.d.ts.map +1 -0
- package/dist/memory-retention.js +151 -0
- package/dist/memory-retrieval-signals.d.ts +12 -0
- package/dist/memory-retrieval-signals.d.ts.map +1 -0
- package/dist/memory-retrieval-signals.js +100 -0
- package/dist/memory-salience.d.ts +12 -0
- package/dist/memory-salience.d.ts.map +1 -0
- package/dist/memory-salience.js +154 -0
- package/dist/memory-scope-sanitizer.d.ts +6 -0
- package/dist/memory-scope-sanitizer.d.ts.map +1 -0
- package/dist/memory-scope-sanitizer.js +106 -0
- package/dist/memory-target-resolver.d.ts +4 -0
- package/dist/memory-target-resolver.d.ts.map +1 -0
- package/dist/memory-target-resolver.js +73 -0
- package/dist/memory-workflow-port.d.ts +14 -0
- package/dist/memory-workflow-port.d.ts.map +1 -0
- package/dist/memory-workflow-port.js +186 -0
- package/dist/private-json.d.ts +3 -0
- package/dist/private-json.d.ts.map +1 -0
- package/dist/private-json.js +62 -0
- package/dist/promptEnhancer/index.d.ts +3 -0
- package/dist/promptEnhancer/index.d.ts.map +1 -0
- package/dist/promptEnhancer/index.js +5 -0
- package/dist/promptEnhancer/orchestrate.d.ts +2 -0
- package/dist/promptEnhancer/orchestrate.d.ts.map +1 -0
- package/dist/promptEnhancer/orchestrate.js +5 -0
- package/dist/promptEnhancer/routes.d.ts +9 -0
- package/dist/promptEnhancer/routes.d.ts.map +1 -0
- package/dist/promptEnhancer/routes.js +205 -0
- package/dist/qualityIntelligence/capsuleAdapter.d.ts +27 -0
- package/dist/qualityIntelligence/capsuleAdapter.d.ts.map +1 -0
- package/dist/qualityIntelligence/capsuleAdapter.js +57 -0
- package/dist/qualityIntelligence/connectorAuthorization.d.ts +22 -0
- package/dist/qualityIntelligence/connectorAuthorization.d.ts.map +1 -0
- package/dist/qualityIntelligence/connectorAuthorization.js +35 -0
- package/dist/qualityIntelligence/connectorErrors.d.ts +16 -0
- package/dist/qualityIntelligence/connectorErrors.d.ts.map +1 -0
- package/dist/qualityIntelligence/connectorErrors.js +56 -0
- package/dist/qualityIntelligence/connectorRoutes.d.ts +7 -0
- package/dist/qualityIntelligence/connectorRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/connectorRoutes.js +167 -0
- package/dist/qualityIntelligence/editRoutes.d.ts +5 -0
- package/dist/qualityIntelligence/editRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/editRoutes.js +293 -0
- package/dist/qualityIntelligence/exportAssembly.d.ts +22 -0
- package/dist/qualityIntelligence/exportAssembly.d.ts.map +1 -0
- package/dist/qualityIntelligence/exportAssembly.js +352 -0
- package/dist/qualityIntelligence/exportRoutes.d.ts +5 -0
- package/dist/qualityIntelligence/exportRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/exportRoutes.js +320 -0
- package/dist/qualityIntelligence/figma/figmaConcurrency.d.ts +8 -0
- package/dist/qualityIntelligence/figma/figmaConcurrency.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConcurrency.js +34 -0
- package/dist/qualityIntelligence/figma/figmaConnector.d.ts +65 -0
- package/dist/qualityIntelligence/figma/figmaConnector.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConnector.js +184 -0
- package/dist/qualityIntelligence/figma/figmaConnectorAudit.d.ts +52 -0
- package/dist/qualityIntelligence/figma/figmaConnectorAudit.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConnectorAudit.js +63 -0
- package/dist/qualityIntelligence/figma/figmaConnectorErrors.d.ts +31 -0
- package/dist/qualityIntelligence/figma/figmaConnectorErrors.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConnectorErrors.js +220 -0
- package/dist/qualityIntelligence/figma/figmaConnectorMetrics.d.ts +44 -0
- package/dist/qualityIntelligence/figma/figmaConnectorMetrics.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConnectorMetrics.js +49 -0
- package/dist/qualityIntelligence/figma/figmaConsent.d.ts +39 -0
- package/dist/qualityIntelligence/figma/figmaConsent.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaConsent.js +62 -0
- package/dist/qualityIntelligence/figma/figmaHttpPort.d.ts +28 -0
- package/dist/qualityIntelligence/figma/figmaHttpPort.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaHttpPort.js +70 -0
- package/dist/qualityIntelligence/figma/figmaObservedActions.d.ts +49 -0
- package/dist/qualityIntelligence/figma/figmaObservedActions.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaObservedActions.js +89 -0
- package/dist/qualityIntelligence/figma/figmaReadiness.d.ts +32 -0
- package/dist/qualityIntelligence/figma/figmaReadiness.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaReadiness.js +67 -0
- package/dist/qualityIntelligence/figma/figmaRenderPort.d.ts +29 -0
- package/dist/qualityIntelligence/figma/figmaRenderPort.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaRenderPort.js +93 -0
- package/dist/qualityIntelligence/figma/figmaResnapshot.d.ts +28 -0
- package/dist/qualityIntelligence/figma/figmaResnapshot.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaResnapshot.js +38 -0
- package/dist/qualityIntelligence/figma/figmaRetry.d.ts +31 -0
- package/dist/qualityIntelligence/figma/figmaRetry.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaRetry.js +62 -0
- package/dist/qualityIntelligence/figma/figmaScopeRef.d.ts +9 -0
- package/dist/qualityIntelligence/figma/figmaScopeRef.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaScopeRef.js +18 -0
- package/dist/qualityIntelligence/figma/figmaScopedPagination.d.ts +86 -0
- package/dist/qualityIntelligence/figma/figmaScopedPagination.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaScopedPagination.js +308 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.d.ts +31 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.js +314 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotHash.d.ts +18 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotHash.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotHash.js +63 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotTypes.d.ts +65 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotTypes.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaSnapshotTypes.js +13 -0
- package/dist/qualityIntelligence/figma/figmaTokenSource.d.ts +9 -0
- package/dist/qualityIntelligence/figma/figmaTokenSource.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaTokenSource.js +61 -0
- package/dist/qualityIntelligence/figma/figmaTokenStore.d.ts +19 -0
- package/dist/qualityIntelligence/figma/figmaTokenStore.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaTokenStore.js +156 -0
- package/dist/qualityIntelligence/figma/figmaUrl.d.ts +6 -0
- package/dist/qualityIntelligence/figma/figmaUrl.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/figmaUrl.js +36 -0
- package/dist/qualityIntelligence/figma/index.d.ts +20 -0
- package/dist/qualityIntelligence/figma/index.d.ts.map +1 -0
- package/dist/qualityIntelligence/figma/index.js +26 -0
- package/dist/qualityIntelligence/figmaCodegenRoutes.d.ts +28 -0
- package/dist/qualityIntelligence/figmaCodegenRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/figmaCodegenRoutes.js +165 -0
- package/dist/qualityIntelligence/figmaSnapshotAdapter.d.ts +55 -0
- package/dist/qualityIntelligence/figmaSnapshotAdapter.d.ts.map +1 -0
- package/dist/qualityIntelligence/figmaSnapshotAdapter.js +219 -0
- package/dist/qualityIntelligence/figmaSnapshotOrchestration.d.ts +64 -0
- package/dist/qualityIntelligence/figmaSnapshotOrchestration.d.ts.map +1 -0
- package/dist/qualityIntelligence/figmaSnapshotOrchestration.js +203 -0
- package/dist/qualityIntelligence/figmaSnapshotRoutes.d.ts +112 -0
- package/dist/qualityIntelligence/figmaSnapshotRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/figmaSnapshotRoutes.js +1063 -0
- package/dist/qualityIntelligence/figmaSnapshotScreenIds.d.ts +19 -0
- package/dist/qualityIntelligence/figmaSnapshotScreenIds.d.ts.map +1 -0
- package/dist/qualityIntelligence/figmaSnapshotScreenIds.js +75 -0
- package/dist/qualityIntelligence/generationPort.d.ts +15 -0
- package/dist/qualityIntelligence/generationPort.d.ts.map +1 -0
- package/dist/qualityIntelligence/generationPort.js +185 -0
- package/dist/qualityIntelligence/handoffErrors.d.ts +9 -0
- package/dist/qualityIntelligence/handoffErrors.d.ts.map +1 -0
- package/dist/qualityIntelligence/handoffErrors.js +21 -0
- package/dist/qualityIntelligence/handoffRoutes.d.ts +15 -0
- package/dist/qualityIntelligence/handoffRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/handoffRoutes.js +341 -0
- package/dist/qualityIntelligence/index.d.ts +17 -0
- package/dist/qualityIntelligence/index.d.ts.map +1 -0
- package/dist/qualityIntelligence/index.js +36 -0
- package/dist/qualityIntelligence/judgePort.d.ts +30 -0
- package/dist/qualityIntelligence/judgePort.d.ts.map +1 -0
- package/dist/qualityIntelligence/judgePort.js +326 -0
- package/dist/qualityIntelligence/modelSelection.d.ts +58 -0
- package/dist/qualityIntelligence/modelSelection.d.ts.map +1 -0
- package/dist/qualityIntelligence/modelSelection.js +148 -0
- package/dist/qualityIntelligence/reCheckRoutes.d.ts +6 -0
- package/dist/qualityIntelligence/reCheckRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/reCheckRoutes.js +1157 -0
- package/dist/qualityIntelligence/retentionEnforcement.d.ts +13 -0
- package/dist/qualityIntelligence/retentionEnforcement.d.ts.map +1 -0
- package/dist/qualityIntelligence/retentionEnforcement.js +47 -0
- package/dist/qualityIntelligence/retentionRoutes.d.ts +8 -0
- package/dist/qualityIntelligence/retentionRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/retentionRoutes.js +74 -0
- package/dist/qualityIntelligence/reviewRoutes.d.ts +5 -0
- package/dist/qualityIntelligence/reviewRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/reviewRoutes.js +145 -0
- package/dist/qualityIntelligence/reviewStore.d.ts +75 -0
- package/dist/qualityIntelligence/reviewStore.d.ts.map +1 -0
- package/dist/qualityIntelligence/reviewStore.js +170 -0
- package/dist/qualityIntelligence/runExecution.d.ts +36 -0
- package/dist/qualityIntelligence/runExecution.d.ts.map +1 -0
- package/dist/qualityIntelligence/runExecution.js +180 -0
- package/dist/qualityIntelligence/runIngestion.d.ts +70 -0
- package/dist/qualityIntelligence/runIngestion.d.ts.map +1 -0
- package/dist/qualityIntelligence/runIngestion.js +1235 -0
- package/dist/qualityIntelligence/runRegistry.d.ts +31 -0
- package/dist/qualityIntelligence/runRegistry.d.ts.map +1 -0
- package/dist/qualityIntelligence/runRegistry.js +66 -0
- package/dist/qualityIntelligence/runRoutes.d.ts +16 -0
- package/dist/qualityIntelligence/runRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/runRoutes.js +357 -0
- package/dist/qualityIntelligence/traceabilityRoutes.d.ts +5 -0
- package/dist/qualityIntelligence/traceabilityRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/traceabilityRoutes.js +173 -0
- package/dist/qualityIntelligence/uiRoutes.d.ts +7 -0
- package/dist/qualityIntelligence/uiRoutes.d.ts.map +1 -0
- package/dist/qualityIntelligence/uiRoutes.js +336 -0
- package/dist/read-handlers.d.ts +9 -0
- package/dist/read-handlers.d.ts.map +1 -0
- package/dist/read-handlers.js +265 -0
- package/dist/relationship-handlers.d.ts +191 -0
- package/dist/relationship-handlers.d.ts.map +1 -0
- package/dist/relationship-handlers.js +0 -0
- package/dist/routes.d.ts +37 -0
- package/dist/routes.d.ts.map +1 -0
- package/dist/routes.js +507 -0
- package/dist/run-engine.d.ts +25 -0
- package/dist/run-engine.d.ts.map +1 -0
- package/dist/run-engine.js +385 -0
- package/dist/run-handlers.d.ts +9 -0
- package/dist/run-handlers.d.ts.map +1 -0
- package/dist/run-handlers.js +465 -0
- package/dist/run-request.d.ts +17 -0
- package/dist/run-request.d.ts.map +1 -0
- package/dist/run-request.js +219 -0
- package/dist/runs.d.ts +47 -0
- package/dist/runs.d.ts.map +1 -0
- package/dist/runs.js +100 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +152 -0
- package/dist/sink.d.ts +28 -0
- package/dist/sink.d.ts.map +1 -0
- package/dist/sink.js +80 -0
- package/dist/sse-write.d.ts +9 -0
- package/dist/sse-write.d.ts.map +1 -0
- package/dist/sse-write.js +26 -0
- package/dist/sse.d.ts +8 -0
- package/dist/sse.d.ts.map +1 -0
- package/dist/sse.js +27 -0
- package/dist/static.d.ts +5 -0
- package/dist/static.d.ts.map +1 -0
- package/dist/static.js +76 -0
- package/dist/store/chats.d.ts +17 -0
- package/dist/store/chats.d.ts.map +1 -0
- package/dist/store/chats.js +624 -0
- package/dist/store/db.d.ts +11 -0
- package/dist/store/db.d.ts.map +1 -0
- package/dist/store/db.js +203 -0
- package/dist/store/errors.d.ts +13 -0
- package/dist/store/errors.d.ts.map +1 -0
- package/dist/store/errors.js +30 -0
- package/dist/store/index.d.ts +7 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +6 -0
- package/dist/store/messages.d.ts +8 -0
- package/dist/store/messages.d.ts.map +1 -0
- package/dist/store/messages.js +149 -0
- package/dist/store/paths.d.ts +5 -0
- package/dist/store/paths.d.ts.map +1 -0
- package/dist/store/paths.js +84 -0
- package/dist/store/projects.d.ts +8 -0
- package/dist/store/projects.d.ts.map +1 -0
- package/dist/store/projects.js +59 -0
- package/dist/store/relationship-audit.d.ts +42 -0
- package/dist/store/relationship-audit.d.ts.map +1 -0
- package/dist/store/relationship-audit.js +155 -0
- package/dist/store/relationships.d.ts +191 -0
- package/dist/store/relationships.d.ts.map +1 -0
- package/dist/store/relationships.js +724 -0
- package/dist/store/schema.d.ts +4 -0
- package/dist/store/schema.d.ts.map +1 -0
- package/dist/store/schema.js +220 -0
- package/dist/store/types.d.ts +29 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +8 -0
- package/dist/store/validation.d.ts +7 -0
- package/dist/store/validation.d.ts.map +1 -0
- package/dist/store/validation.js +117 -0
- package/dist/store-handlers.d.ts +17 -0
- package/dist/store-handlers.d.ts.map +1 -0
- package/dist/store-handlers.js +872 -0
- package/dist/terminal-errors.d.ts +22 -0
- package/dist/terminal-errors.d.ts.map +1 -0
- package/dist/terminal-errors.js +45 -0
- package/dist/terminal-evidence.d.ts +21 -0
- package/dist/terminal-evidence.d.ts.map +1 -0
- package/dist/terminal-evidence.js +65 -0
- package/dist/terminal-routes.d.ts +10 -0
- package/dist/terminal-routes.d.ts.map +1 -0
- package/dist/terminal-routes.js +219 -0
- package/dist/terminal.d.ts +68 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +855 -0
- package/package.json +52 -0
|
@@ -0,0 +1,624 @@
|
|
|
1
|
+
// ADR-0013 — chats CRUD scoped to a project. Parameterized SQL only.
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { SELECTED_SCOPE_KINDS, isValidScopePath, } from "@oscharko-dev/keiko-contracts/connected-context";
|
|
4
|
+
import { DEFAULT_GROUNDING_LIMITS, GROUNDING_LIMIT_CEILINGS, } from "@oscharko-dev/keiko-contracts/bff-wire";
|
|
5
|
+
import { redact } from "@oscharko-dev/keiko-security";
|
|
6
|
+
import { pathIsDenied } from "../files-deny.js";
|
|
7
|
+
import { invalidRequest, notFound } from "./errors.js";
|
|
8
|
+
const MAX_CONNECTED_SCOPE_PATHS = 50;
|
|
9
|
+
const SELECTED_SCOPE_KIND_SET = new Set(SELECTED_SCOPE_KINDS);
|
|
10
|
+
const MAX_SELECTED_MODEL_LEN = 160;
|
|
11
|
+
const SELECTED_MODEL_RE = /^[A-Za-z0-9][A-Za-z0-9._/\- ]*$/;
|
|
12
|
+
const FORBIDDEN_SELECTED_MODEL_TERMS = [
|
|
13
|
+
"apiKey",
|
|
14
|
+
"api_key",
|
|
15
|
+
"baseUrl",
|
|
16
|
+
"base_url",
|
|
17
|
+
"provider",
|
|
18
|
+
"deployment",
|
|
19
|
+
"endpoint",
|
|
20
|
+
"secret",
|
|
21
|
+
"token",
|
|
22
|
+
"credential",
|
|
23
|
+
];
|
|
24
|
+
function isSelectedScopeKind(value) {
|
|
25
|
+
return typeof value === "string" && SELECTED_SCOPE_KIND_SET.has(value);
|
|
26
|
+
}
|
|
27
|
+
function hasValidPathCount(kind, count) {
|
|
28
|
+
if (kind === "workspace-root")
|
|
29
|
+
return count === 0;
|
|
30
|
+
if (kind === "directory")
|
|
31
|
+
return count === 1;
|
|
32
|
+
return count > 0 && count <= MAX_CONNECTED_SCOPE_PATHS;
|
|
33
|
+
}
|
|
34
|
+
// Issue #184 — validates scope-path cardinality and path shape against SelectedScope semantics.
|
|
35
|
+
// Repository-root scopes intentionally carry an empty path array; directory scopes carry exactly
|
|
36
|
+
// one relative path; files scopes carry one or more workspace-relative entries.
|
|
37
|
+
function validateScopePathsForKind(kind, paths) {
|
|
38
|
+
// Defense-in-depth (Copilot PR #254 finding): even though the BFF boundary validates every
|
|
39
|
+
// entry via isValidScopePath before writing, a corrupted or tampered DB row must not be
|
|
40
|
+
// able to re-introduce an absolute or traversal path on read. The same range cap also
|
|
41
|
+
// applies — a corrupted row carrying 10_000 entries collapses to undefined.
|
|
42
|
+
if (!hasValidPathCount(kind, paths.length)) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
const items = [];
|
|
46
|
+
for (const entry of paths) {
|
|
47
|
+
if (typeof entry !== "string" || !isValidScopePath(entry, { mustBeRelative: true })) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
items.push(entry);
|
|
51
|
+
}
|
|
52
|
+
return items;
|
|
53
|
+
}
|
|
54
|
+
function metadataIsSafe(value) {
|
|
55
|
+
const redacted = redact(value);
|
|
56
|
+
return typeof redacted !== "string" || redacted === value;
|
|
57
|
+
}
|
|
58
|
+
function assertMetadataSafe(value, label) {
|
|
59
|
+
if (!metadataIsSafe(value)) {
|
|
60
|
+
throw invalidRequest(`${label} must not contain credential-shaped metadata.`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function allMetadataSafe(values) {
|
|
64
|
+
return values.every(metadataIsSafe);
|
|
65
|
+
}
|
|
66
|
+
// Epic #532 — the connected_scope_paths column now holds EITHER a single scope object (legacy)
|
|
67
|
+
// OR a JSON array of scope objects (multi-source). The Issue #184 legacy form (a bare array of
|
|
68
|
+
// path strings) is still tolerated as a single files scope. Disambiguation: an array whose first
|
|
69
|
+
// element is an object is the new multi-source list; an array of strings is the #184 legacy form.
|
|
70
|
+
// Epic #532 audit (L2) — defense-in-depth on read. The connectedScope root is fully validated at
|
|
71
|
+
// the BFF write path (realpath → deny-list → containment). On read from a possibly-tampered DB row
|
|
72
|
+
// we re-assert the SHAPE the writer guarantees: an absolute path. A `root` key that is present but
|
|
73
|
+
// not a non-empty absolute string is treated as tampering — the whole scope decode collapses to
|
|
74
|
+
// undefined (matching the "a malformed entry can never widen the result" invariant) rather than
|
|
75
|
+
// silently grounding against an attacker-chosen relative location.
|
|
76
|
+
function decodeScopeRoot(raw) {
|
|
77
|
+
if (raw === undefined)
|
|
78
|
+
return { ok: true };
|
|
79
|
+
if (typeof raw === "string" &&
|
|
80
|
+
raw.length > 0 &&
|
|
81
|
+
isAbsolute(raw) &&
|
|
82
|
+
!pathIsDenied(raw) &&
|
|
83
|
+
metadataIsSafe(raw)) {
|
|
84
|
+
return { ok: true, root: raw };
|
|
85
|
+
}
|
|
86
|
+
return { ok: false };
|
|
87
|
+
}
|
|
88
|
+
function decodeSingleScopeObject(raw) {
|
|
89
|
+
if (!isSelectedScopeKind(raw.kind) || !Array.isArray(raw.relativePaths))
|
|
90
|
+
return undefined;
|
|
91
|
+
const relativePaths = validateScopePathsForKind(raw.kind, raw.relativePaths);
|
|
92
|
+
if (relativePaths === undefined)
|
|
93
|
+
return undefined;
|
|
94
|
+
if (!allMetadataSafe(relativePaths))
|
|
95
|
+
return undefined;
|
|
96
|
+
const decodedRoot = decodeScopeRoot(raw.root);
|
|
97
|
+
if (!decodedRoot.ok)
|
|
98
|
+
return undefined;
|
|
99
|
+
const root = decodedRoot.root;
|
|
100
|
+
const connectedAtMs = Number.isInteger(raw.connectedAtMs) && raw.connectedAtMs >= 0
|
|
101
|
+
? raw.connectedAtMs
|
|
102
|
+
: undefined;
|
|
103
|
+
return {
|
|
104
|
+
kind: raw.kind,
|
|
105
|
+
relativePaths,
|
|
106
|
+
...(root !== undefined ? { root } : {}),
|
|
107
|
+
...(connectedAtMs !== undefined ? { connectedAtMs } : {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function decodeLegacyFilesArray(parsed) {
|
|
111
|
+
const relativePaths = validateScopePathsForKind("files", parsed);
|
|
112
|
+
if (relativePaths === undefined || !allMetadataSafe(relativePaths))
|
|
113
|
+
return undefined;
|
|
114
|
+
return { kind: "files", relativePaths };
|
|
115
|
+
}
|
|
116
|
+
function decodeScopeObjectArray(entries) {
|
|
117
|
+
if (entries.length > GROUNDING_LIMIT_CEILINGS.maxConnectedSources)
|
|
118
|
+
return undefined;
|
|
119
|
+
const payloads = [];
|
|
120
|
+
for (const entry of entries) {
|
|
121
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry))
|
|
122
|
+
return undefined;
|
|
123
|
+
const decoded = decodeSingleScopeObject(entry);
|
|
124
|
+
if (decoded === undefined)
|
|
125
|
+
return undefined;
|
|
126
|
+
payloads.push(decoded);
|
|
127
|
+
}
|
|
128
|
+
return payloads;
|
|
129
|
+
}
|
|
130
|
+
function decodeArrayPayload(parsed) {
|
|
131
|
+
if (parsed.length === 0)
|
|
132
|
+
return undefined;
|
|
133
|
+
if (parsed.every((entry) => typeof entry === "string")) {
|
|
134
|
+
const legacy = decodeLegacyFilesArray(parsed);
|
|
135
|
+
return legacy === undefined ? undefined : [legacy];
|
|
136
|
+
}
|
|
137
|
+
return decodeScopeObjectArray(parsed);
|
|
138
|
+
}
|
|
139
|
+
// Decodes the column payload into an ORDERED list of scope payloads. A single object yields a
|
|
140
|
+
// 1-element list; an array of objects yields one entry per element. The #184 legacy string-array
|
|
141
|
+
// form yields a single files scope. A tampered row can never widen the result: any malformed
|
|
142
|
+
// entry collapses the whole decode to undefined. Returns undefined when nothing valid was found.
|
|
143
|
+
function decodeConnectedScopePayloads(parsed) {
|
|
144
|
+
if (Array.isArray(parsed))
|
|
145
|
+
return decodeArrayPayload(parsed);
|
|
146
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
147
|
+
return undefined;
|
|
148
|
+
const single = decodeSingleScopeObject(parsed);
|
|
149
|
+
return single === undefined ? undefined : [single];
|
|
150
|
+
}
|
|
151
|
+
function decodeConnectedScopes(paths, connectedAt) {
|
|
152
|
+
if (paths === null || connectedAt === null)
|
|
153
|
+
return undefined;
|
|
154
|
+
if (!Number.isInteger(connectedAt) || connectedAt < 0)
|
|
155
|
+
return undefined;
|
|
156
|
+
let parsed;
|
|
157
|
+
try {
|
|
158
|
+
parsed = JSON.parse(paths);
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
const payloads = decodeConnectedScopePayloads(parsed);
|
|
164
|
+
if (payloads === undefined)
|
|
165
|
+
return undefined;
|
|
166
|
+
return payloads.map((payload) => ({
|
|
167
|
+
kind: payload.kind,
|
|
168
|
+
relativePaths: payload.relativePaths,
|
|
169
|
+
// The newest connectedAtMs lives in the column; per-scope connectedAtMs is carried inside the
|
|
170
|
+
// array (decoded below). Legacy single-object/string-array rows have no per-scope value, so the
|
|
171
|
+
// column timestamp is the authoritative one for every entry in that 1-element list.
|
|
172
|
+
connectedAtMs: payload.connectedAtMs ?? connectedAt,
|
|
173
|
+
...(payload.root !== undefined ? { root: payload.root } : {}),
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
function decodeLocalKnowledgeScopeObject(raw) {
|
|
177
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw))
|
|
178
|
+
return undefined;
|
|
179
|
+
const scope = raw;
|
|
180
|
+
const connectedAtMs = decodeNonNegativeInteger(scope.connectedAtMs);
|
|
181
|
+
if (connectedAtMs === undefined)
|
|
182
|
+
return undefined;
|
|
183
|
+
return decodeLocalKnowledgeScopePayload(scope, connectedAtMs);
|
|
184
|
+
}
|
|
185
|
+
// Epic #189 — the local_knowledge_scope_json column now holds EITHER a single scope object (legacy)
|
|
186
|
+
// OR a JSON array of scope objects (multi-source). Mirrors decodeConnectedScopes: a single object
|
|
187
|
+
// yields a 1-element list; an array yields one entry per element. A tampered row can never widen
|
|
188
|
+
// the result — any malformed entry collapses the whole decode to undefined. Returns undefined when
|
|
189
|
+
// nothing valid was found (column null, parse error, or any invalid entry).
|
|
190
|
+
function decodeLocalKnowledgeScopes(raw) {
|
|
191
|
+
if (raw === null)
|
|
192
|
+
return undefined;
|
|
193
|
+
let parsed;
|
|
194
|
+
try {
|
|
195
|
+
parsed = JSON.parse(raw);
|
|
196
|
+
}
|
|
197
|
+
catch {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
if (Array.isArray(parsed))
|
|
201
|
+
return decodeLocalKnowledgeScopeArray(parsed);
|
|
202
|
+
const single = decodeLocalKnowledgeScopeObject(parsed);
|
|
203
|
+
return single === undefined ? undefined : [single];
|
|
204
|
+
}
|
|
205
|
+
function decodeLocalKnowledgeScopeArray(entries) {
|
|
206
|
+
if (entries.length === 0 || entries.length > GROUNDING_LIMIT_CEILINGS.maxLocalKnowledgeSources) {
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
const scopes = [];
|
|
210
|
+
for (const entry of entries) {
|
|
211
|
+
const decoded = decodeLocalKnowledgeScopeObject(entry);
|
|
212
|
+
if (decoded === undefined)
|
|
213
|
+
return undefined;
|
|
214
|
+
scopes.push(decoded);
|
|
215
|
+
}
|
|
216
|
+
return scopes;
|
|
217
|
+
}
|
|
218
|
+
function decodeNonNegativeInteger(value) {
|
|
219
|
+
return Number.isInteger(value) && value >= 0 ? value : undefined;
|
|
220
|
+
}
|
|
221
|
+
function decodeLocalKnowledgeScopePayload(scope, connectedAtMs) {
|
|
222
|
+
if (scope.kind === "capsule" &&
|
|
223
|
+
typeof scope.capsuleId === "string" &&
|
|
224
|
+
scope.capsuleId.trim().length > 0) {
|
|
225
|
+
return {
|
|
226
|
+
kind: "capsule",
|
|
227
|
+
capsuleId: scope.capsuleId.trim(),
|
|
228
|
+
connectedAtMs,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
if (scope.kind === "capsule-set" &&
|
|
232
|
+
typeof scope.capsuleSetId === "string" &&
|
|
233
|
+
scope.capsuleSetId.trim().length > 0) {
|
|
234
|
+
return {
|
|
235
|
+
kind: "capsule-set",
|
|
236
|
+
capsuleSetId: scope.capsuleSetId.trim(),
|
|
237
|
+
connectedAtMs,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
function rowToChat(row) {
|
|
243
|
+
const status = row.status === null ? undefined : row.status;
|
|
244
|
+
const connectedScopes = decodeConnectedScopes(row.connected_scope_paths, row.connected_scope_at);
|
|
245
|
+
const localKnowledgeScopes = decodeLocalKnowledgeScopes(row.local_knowledge_scope_json);
|
|
246
|
+
return {
|
|
247
|
+
id: row.id,
|
|
248
|
+
projectPath: row.project_path,
|
|
249
|
+
title: row.title,
|
|
250
|
+
selectedModel: row.selected_model,
|
|
251
|
+
branchLabel: row.branch_label ?? undefined,
|
|
252
|
+
status,
|
|
253
|
+
// Epic #532 — populate BOTH the canonical list and the back-compat single field
|
|
254
|
+
// (= list[0]). Absent binding → both undefined.
|
|
255
|
+
...(connectedScopes !== undefined && connectedScopes.length > 0
|
|
256
|
+
? { connectedScopes, connectedScope: connectedScopes[0] }
|
|
257
|
+
: { connectedScope: undefined }),
|
|
258
|
+
// Epic #189 — populate BOTH the canonical connector list and the back-compat single field
|
|
259
|
+
// (= list[0]). Absent binding → both undefined.
|
|
260
|
+
...(localKnowledgeScopes !== undefined && localKnowledgeScopes.length > 0
|
|
261
|
+
? { localKnowledgeScopes, localKnowledgeScope: localKnowledgeScopes[0] }
|
|
262
|
+
: { localKnowledgeScope: undefined }),
|
|
263
|
+
createdAt: row.created_at,
|
|
264
|
+
updatedAt: row.updated_at,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
const SELECT_COLUMNS = "id, project_path, title, selected_model, branch_label, status, " +
|
|
268
|
+
"connected_scope_paths, connected_scope_at, local_knowledge_scope_json, created_at, updated_at";
|
|
269
|
+
const SQL_LIST = `SELECT ${SELECT_COLUMNS} FROM chats WHERE project_path = ? ORDER BY created_at ASC`;
|
|
270
|
+
const SQL_LIST_LIMITED = `${SQL_LIST} LIMIT ?`;
|
|
271
|
+
// Epic #177 audit: grounded-ask and chat PATCH paths used a project-scan + chat-scan helper that
|
|
272
|
+
// fired O(projects × chats) row fetches per request. The chat id is unique across projects (the
|
|
273
|
+
// schema enforces it via the chats.id primary key), so a single-row lookup is correct and bounded.
|
|
274
|
+
const SQL_FIND_BY_ID = `SELECT ${SELECT_COLUMNS} FROM chats WHERE id = ? LIMIT 1`;
|
|
275
|
+
const SQL_INSERT = `
|
|
276
|
+
INSERT INTO chats (id, project_path, title, selected_model, branch_label, status,
|
|
277
|
+
connected_scope_paths, connected_scope_at, local_knowledge_scope_json, created_at, updated_at)
|
|
278
|
+
VALUES (?, ?, ?, ?, ?, NULL, NULL, NULL, NULL, ?, ?)
|
|
279
|
+
RETURNING ${SELECT_COLUMNS}
|
|
280
|
+
`;
|
|
281
|
+
// Issue #184 — the trailing CASE WHEN ? = 1 ... ELSE col END pattern lets the caller signal three
|
|
282
|
+
// states without polluting the existing four COALESCE columns: apply_scope = 0 → leave both
|
|
283
|
+
// scope columns untouched (patch.connectedScope === undefined); apply_scope = 1 → write the two
|
|
284
|
+
// scope parameters verbatim (writing NULL into both clears the binding when patch.connectedScope
|
|
285
|
+
// === null; writing JSON+ms sets it). The statement contains TWO separate `CASE WHEN ? = 1`
|
|
286
|
+
// guards (one per column) so the same apply_scope value is passed twice. The local-knowledge
|
|
287
|
+
// scope uses the same 3-state encoding against a single JSON column. Parameter order:
|
|
288
|
+
// title, model, branch, status, updated_at, apply_scope, scope_paths, apply_scope, scope_at,
|
|
289
|
+
// apply_local_scope, local_scope_json, id.
|
|
290
|
+
const SQL_UPDATE = `
|
|
291
|
+
UPDATE chats SET
|
|
292
|
+
title = COALESCE(?, title),
|
|
293
|
+
selected_model = COALESCE(?, selected_model),
|
|
294
|
+
branch_label = COALESCE(?, branch_label),
|
|
295
|
+
status = COALESCE(?, status),
|
|
296
|
+
updated_at = ?,
|
|
297
|
+
connected_scope_paths = CASE WHEN ? = 1 THEN ? ELSE connected_scope_paths END,
|
|
298
|
+
connected_scope_at = CASE WHEN ? = 1 THEN ? ELSE connected_scope_at END,
|
|
299
|
+
local_knowledge_scope_json = CASE WHEN ? = 1 THEN ? ELSE local_knowledge_scope_json END
|
|
300
|
+
WHERE id = ?
|
|
301
|
+
RETURNING ${SELECT_COLUMNS}
|
|
302
|
+
`;
|
|
303
|
+
const SQL_DELETE = "DELETE FROM chats WHERE id = ?";
|
|
304
|
+
const SQL_PROJECT_EXISTS = "SELECT 1 FROM projects WHERE path = ?";
|
|
305
|
+
const SQL_TOUCH = "UPDATE chats SET updated_at = ? WHERE id = ?";
|
|
306
|
+
function validateSelectedModel(value) {
|
|
307
|
+
if (value.length === 0)
|
|
308
|
+
throw invalidRequest("selectedModel is required.");
|
|
309
|
+
if (value.length > MAX_SELECTED_MODEL_LEN || !SELECTED_MODEL_RE.test(value)) {
|
|
310
|
+
throw invalidRequest("selectedModel must be a registry id.");
|
|
311
|
+
}
|
|
312
|
+
const lower = value.toLowerCase();
|
|
313
|
+
if (value.includes("://") ||
|
|
314
|
+
value.trim().startsWith("{") ||
|
|
315
|
+
FORBIDDEN_SELECTED_MODEL_TERMS.some((term) => lower.includes(term.toLowerCase()))) {
|
|
316
|
+
throw invalidRequest("selectedModel must be a registry id.");
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
export function listChats(db, projectPath) {
|
|
320
|
+
return db.prepare(SQL_LIST).all(projectPath).map(rowToChat);
|
|
321
|
+
}
|
|
322
|
+
export function listChatsLimited(db, projectPath, limit) {
|
|
323
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
324
|
+
throw invalidRequest("limit must be a positive integer.");
|
|
325
|
+
}
|
|
326
|
+
return db.prepare(SQL_LIST_LIMITED).all(projectPath, limit).map(rowToChat);
|
|
327
|
+
}
|
|
328
|
+
export function findChatById(db, id) {
|
|
329
|
+
const row = db.prepare(SQL_FIND_BY_ID).get(id);
|
|
330
|
+
return row === undefined ? undefined : rowToChat(row);
|
|
331
|
+
}
|
|
332
|
+
export function insertChat(db, args) {
|
|
333
|
+
if (args.title.length === 0)
|
|
334
|
+
throw invalidRequest("Title is required.");
|
|
335
|
+
validateSelectedModel(args.selectedModel);
|
|
336
|
+
const projectExists = db.prepare(SQL_PROJECT_EXISTS).get(args.projectPath) !== undefined;
|
|
337
|
+
if (!projectExists)
|
|
338
|
+
throw notFound("Project");
|
|
339
|
+
const branch = args.opts?.branchLabel ?? null;
|
|
340
|
+
const row = db
|
|
341
|
+
.prepare(SQL_INSERT)
|
|
342
|
+
.get(args.id, args.projectPath, args.title, args.selectedModel, branch, args.now, args.now);
|
|
343
|
+
return rowToChat(row);
|
|
344
|
+
}
|
|
345
|
+
const VALID_CHAT_STATUSES = new Set(["open", "closed"]);
|
|
346
|
+
// Issue #184 — defense-in-depth at the store boundary. The BFF handler is the AUTHORITATIVE
|
|
347
|
+
// gate (path validation via isValidScopePath, range guard, finite-integer guard); these checks
|
|
348
|
+
// are a runtime safety net for in-process callers that bypass HTTP, and for the cast from
|
|
349
|
+
// `unknown`. They must never weaken the BFF rules: the criteria here are strict-subset.
|
|
350
|
+
function validateConnectedScopeShape(scope) {
|
|
351
|
+
if (!isSelectedScopeKind(scope.kind)) {
|
|
352
|
+
throw invalidRequest("connectedScope.kind must be a recognized scope kind.");
|
|
353
|
+
}
|
|
354
|
+
if (!Array.isArray(scope.relativePaths)) {
|
|
355
|
+
throw invalidRequest("connectedScope.relativePaths must be an array.");
|
|
356
|
+
}
|
|
357
|
+
const relativePaths = validateScopePathsForKind(scope.kind, scope.relativePaths);
|
|
358
|
+
if (relativePaths === undefined) {
|
|
359
|
+
throw invalidRequest("connectedScope.relativePaths must match connectedScope.kind and contain valid workspace-relative paths.");
|
|
360
|
+
}
|
|
361
|
+
validateConnectedScopeTimestamp(scope);
|
|
362
|
+
validateConnectedScopeMetadata(relativePaths, scope.root);
|
|
363
|
+
}
|
|
364
|
+
function validateConnectedScopeMetadata(relativePaths, root) {
|
|
365
|
+
if (root !== undefined && pathIsDenied(root)) {
|
|
366
|
+
throw invalidRequest("connectedScope.root must not reference a deny-listed path.");
|
|
367
|
+
}
|
|
368
|
+
for (const relativePath of relativePaths) {
|
|
369
|
+
assertMetadataSafe(relativePath, "connectedScope.relativePaths");
|
|
370
|
+
}
|
|
371
|
+
if (root !== undefined) {
|
|
372
|
+
assertMetadataSafe(root, "connectedScope.root");
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function validateConnectedScopeTimestamp(scope) {
|
|
376
|
+
if (typeof scope.connectedAtMs !== "number" ||
|
|
377
|
+
!Number.isInteger(scope.connectedAtMs) ||
|
|
378
|
+
scope.connectedAtMs < 0) {
|
|
379
|
+
throw invalidRequest("connectedScope.connectedAtMs must be a finite non-negative integer.");
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
function validateLocalKnowledgeScopeShape(scope) {
|
|
383
|
+
if (typeof scope.connectedAtMs !== "number" ||
|
|
384
|
+
!Number.isInteger(scope.connectedAtMs) ||
|
|
385
|
+
scope.connectedAtMs < 0) {
|
|
386
|
+
throw invalidRequest("localKnowledgeScope.connectedAtMs must be a finite non-negative integer.");
|
|
387
|
+
}
|
|
388
|
+
switch (scope.kind) {
|
|
389
|
+
case "capsule":
|
|
390
|
+
if (typeof scope.capsuleId !== "string" || scope.capsuleId.trim().length === 0) {
|
|
391
|
+
throw invalidRequest("localKnowledgeScope.capsuleId must be a non-empty string.");
|
|
392
|
+
}
|
|
393
|
+
return;
|
|
394
|
+
case "capsule-set":
|
|
395
|
+
if (typeof scope.capsuleSetId !== "string" || scope.capsuleSetId.trim().length === 0) {
|
|
396
|
+
throw invalidRequest("localKnowledgeScope.capsuleSetId must be a non-empty string.");
|
|
397
|
+
}
|
|
398
|
+
return;
|
|
399
|
+
default:
|
|
400
|
+
throw invalidRequest("localKnowledgeScope.kind must be capsule or capsule-set.");
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
function validatePatchScope(scope) {
|
|
404
|
+
if (scope === undefined || scope === null)
|
|
405
|
+
return;
|
|
406
|
+
if (typeof scope !== "object" || Array.isArray(scope)) {
|
|
407
|
+
throw invalidRequest("connectedScope must be an object or null.");
|
|
408
|
+
}
|
|
409
|
+
validateConnectedScopeShape(scope);
|
|
410
|
+
}
|
|
411
|
+
// Epic #532 — validate the multi-source list. Each entry runs the same defense-in-depth shape
|
|
412
|
+
// check as the single field; the list is bounded by maxSources (defaults to
|
|
413
|
+
// DEFAULT_GROUNDING_LIMITS.maxConnectedSources — a strict subset of the BFF gate). Callers may
|
|
414
|
+
// supply a lower operator-configured cap; the store stays self-defending when no limit is passed.
|
|
415
|
+
// undefined/null are pass-through (leave-unchanged / clear-all).
|
|
416
|
+
function validatePatchScopes(scopes, maxSources = DEFAULT_GROUNDING_LIMITS.maxConnectedSources) {
|
|
417
|
+
if (scopes === undefined || scopes === null)
|
|
418
|
+
return;
|
|
419
|
+
if (!Array.isArray(scopes)) {
|
|
420
|
+
throw invalidRequest("connectedScopes must be an array or null.");
|
|
421
|
+
}
|
|
422
|
+
if (scopes.length > maxSources) {
|
|
423
|
+
throw invalidRequest(`connectedScopes must contain at most ${String(maxSources)} sources.`);
|
|
424
|
+
}
|
|
425
|
+
for (const scope of scopes) {
|
|
426
|
+
if (typeof scope !== "object" || scope === null || Array.isArray(scope)) {
|
|
427
|
+
throw invalidRequest("connectedScopes entries must be objects.");
|
|
428
|
+
}
|
|
429
|
+
validateConnectedScopeShape(scope);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
function validatePatchLocalKnowledgeScope(scope) {
|
|
433
|
+
if (scope === undefined || scope === null)
|
|
434
|
+
return;
|
|
435
|
+
if (typeof scope !== "object" || Array.isArray(scope)) {
|
|
436
|
+
throw invalidRequest("localKnowledgeScope must be an object or null.");
|
|
437
|
+
}
|
|
438
|
+
validateLocalKnowledgeScopeShape(scope);
|
|
439
|
+
}
|
|
440
|
+
// Epic #189 — validate the multi-source connector list. Each entry runs the same defense-in-depth
|
|
441
|
+
// shape check as the single field; the list is bounded by maxSources (defaults to
|
|
442
|
+
// DEFAULT_GROUNDING_LIMITS.maxLocalKnowledgeSources — a strict subset of the BFF gate). Callers
|
|
443
|
+
// may supply a lower operator-configured cap; the store stays self-defending when no limit is
|
|
444
|
+
// passed. undefined/null are pass-through (leave-unchanged / clear-all).
|
|
445
|
+
function validatePatchLocalKnowledgeScopes(scopes, maxSources = DEFAULT_GROUNDING_LIMITS.maxLocalKnowledgeSources) {
|
|
446
|
+
if (scopes === undefined || scopes === null)
|
|
447
|
+
return;
|
|
448
|
+
if (!Array.isArray(scopes)) {
|
|
449
|
+
throw invalidRequest("localKnowledgeScopes must be an array or null.");
|
|
450
|
+
}
|
|
451
|
+
if (scopes.length > maxSources) {
|
|
452
|
+
throw invalidRequest(`localKnowledgeScopes must contain at most ${String(maxSources)} sources.`);
|
|
453
|
+
}
|
|
454
|
+
for (const scope of scopes) {
|
|
455
|
+
if (typeof scope !== "object" || scope === null || Array.isArray(scope)) {
|
|
456
|
+
throw invalidRequest("localKnowledgeScopes entries must be objects.");
|
|
457
|
+
}
|
|
458
|
+
validateLocalKnowledgeScopeShape(scope);
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
function validateChatPatch(patch, limits) {
|
|
462
|
+
// Runtime defense: handlers may pass widened (unknown) input cast to UpdateChatPatch.
|
|
463
|
+
const raw = patch.status;
|
|
464
|
+
if (raw !== undefined && (typeof raw !== "string" || !VALID_CHAT_STATUSES.has(raw))) {
|
|
465
|
+
throw invalidRequest("Invalid status.");
|
|
466
|
+
}
|
|
467
|
+
validatePatchScope(patch.connectedScope);
|
|
468
|
+
validatePatchScopes(patch.connectedScopes, limits?.maxConnectedSources);
|
|
469
|
+
validatePatchLocalKnowledgeScope(patch.localKnowledgeScope);
|
|
470
|
+
validatePatchLocalKnowledgeScopes(patch.localKnowledgeScopes, limits?.maxLocalKnowledgeSources);
|
|
471
|
+
}
|
|
472
|
+
// Epic #532 — resolve the effective scope-patch intent. `connectedScopes` SUPERSEDES the legacy
|
|
473
|
+
// single `connectedScope`: when the list field is present (including null), it wins. A single
|
|
474
|
+
// `connectedScope` object is normalized to a 1-element list. Returns undefined (leave unchanged),
|
|
475
|
+
// null (clear all), or the ordered list to persist.
|
|
476
|
+
function resolveScopePatch(patch) {
|
|
477
|
+
if (patch.connectedScopes !== undefined) {
|
|
478
|
+
if (patch.connectedScopes === null || patch.connectedScopes.length === 0)
|
|
479
|
+
return null;
|
|
480
|
+
return patch.connectedScopes;
|
|
481
|
+
}
|
|
482
|
+
if (patch.connectedScope === undefined)
|
|
483
|
+
return undefined;
|
|
484
|
+
if (patch.connectedScope === null)
|
|
485
|
+
return null;
|
|
486
|
+
return [patch.connectedScope];
|
|
487
|
+
}
|
|
488
|
+
function encodeScopeObject(value) {
|
|
489
|
+
return {
|
|
490
|
+
kind: value.kind,
|
|
491
|
+
relativePaths: value.relativePaths,
|
|
492
|
+
// Epic #532 — persist the optional scope root (a folder outside the chat's project) inside the
|
|
493
|
+
// existing connected_scope_paths JSON column, so no schema migration is needed.
|
|
494
|
+
...(value.root !== undefined ? { root: value.root } : {}),
|
|
495
|
+
// Per-scope connectedAtMs is carried inside the array so each source keeps its own connect time;
|
|
496
|
+
// the column-level connected_scope_at holds the newest value (for legacy single-object readers).
|
|
497
|
+
connectedAtMs: value.connectedAtMs,
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
// Epic #532 — encode the resolved scope-patch intent. A single source encodes as the legacy single
|
|
501
|
+
// object (byte-identical to the pre-#532 single-source form, so back-compat decode is unchanged); a
|
|
502
|
+
// multi-source list encodes as a JSON array. connected_scope_at = newest per-scope connectedAtMs.
|
|
503
|
+
function scopeUpdateParams(value) {
|
|
504
|
+
if (value === undefined)
|
|
505
|
+
return { apply: 0, pathsJson: null, connectedAtMs: null };
|
|
506
|
+
if (value === null || value.length === 0) {
|
|
507
|
+
return { apply: 1, pathsJson: null, connectedAtMs: null };
|
|
508
|
+
}
|
|
509
|
+
const newestConnectedAtMs = value.reduce((max, scope) => Math.max(max, scope.connectedAtMs), 0);
|
|
510
|
+
const first = value[0];
|
|
511
|
+
if (value.length === 1 && first !== undefined) {
|
|
512
|
+
const single = encodeScopeObject(first);
|
|
513
|
+
delete single.connectedAtMs;
|
|
514
|
+
return { apply: 1, pathsJson: JSON.stringify(single), connectedAtMs: first.connectedAtMs };
|
|
515
|
+
}
|
|
516
|
+
return {
|
|
517
|
+
apply: 1,
|
|
518
|
+
pathsJson: JSON.stringify(value.map(encodeScopeObject)),
|
|
519
|
+
connectedAtMs: newestConnectedAtMs,
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
function encodeLocalKnowledgeScopeObject(value) {
|
|
523
|
+
return value.kind === "capsule"
|
|
524
|
+
? { kind: "capsule", capsuleId: value.capsuleId.trim(), connectedAtMs: value.connectedAtMs }
|
|
525
|
+
: {
|
|
526
|
+
kind: "capsule-set",
|
|
527
|
+
capsuleSetId: value.capsuleSetId.trim(),
|
|
528
|
+
connectedAtMs: value.connectedAtMs,
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
// Epic #189 — resolve the effective connector-patch intent. `localKnowledgeScopes` (plural)
|
|
532
|
+
// SUPERSEDES the legacy single `localKnowledgeScope`: when the list field is present (including
|
|
533
|
+
// null), it wins. A single object normalizes to a 1-element list. Returns undefined (leave
|
|
534
|
+
// unchanged), null (clear), or the ordered list to persist. Mirrors resolveScopePatch (#532).
|
|
535
|
+
function resolveLocalKnowledgeScopePatch(patch) {
|
|
536
|
+
if (patch.localKnowledgeScopes !== undefined) {
|
|
537
|
+
if (patch.localKnowledgeScopes === null || patch.localKnowledgeScopes.length === 0)
|
|
538
|
+
return null;
|
|
539
|
+
return patch.localKnowledgeScopes;
|
|
540
|
+
}
|
|
541
|
+
if (patch.localKnowledgeScope === undefined)
|
|
542
|
+
return undefined;
|
|
543
|
+
if (patch.localKnowledgeScope === null)
|
|
544
|
+
return null;
|
|
545
|
+
return [patch.localKnowledgeScope];
|
|
546
|
+
}
|
|
547
|
+
// Epic #189 — encode the resolved connector-patch intent into the single local_knowledge_scope_json
|
|
548
|
+
// column. A single source encodes as the legacy single object (byte-identical to the pre-#189 form,
|
|
549
|
+
// so back-compat decode is unchanged); a multi-source list encodes as a JSON array. Mirrors
|
|
550
|
+
// scopeUpdateParams (#532); per-scope connectedAtMs lives inside each object.
|
|
551
|
+
function localKnowledgeScopesUpdateParams(value) {
|
|
552
|
+
if (value === undefined)
|
|
553
|
+
return { apply: 0, json: null };
|
|
554
|
+
if (value === null || value.length === 0)
|
|
555
|
+
return { apply: 1, json: null };
|
|
556
|
+
const first = value[0];
|
|
557
|
+
if (value.length === 1 && first !== undefined) {
|
|
558
|
+
return { apply: 1, json: JSON.stringify(encodeLocalKnowledgeScopeObject(first)) };
|
|
559
|
+
}
|
|
560
|
+
return { apply: 1, json: JSON.stringify(value.map(encodeLocalKnowledgeScopeObject)) };
|
|
561
|
+
}
|
|
562
|
+
// Release 0.2.0 — combined source cap. "Up to 16 sources" is a TOTAL across both lists
|
|
563
|
+
// (folders/files/repos in connectedScopes + knowledge connectors in localKnowledgeScopes),
|
|
564
|
+
// mirroring the QI ingestion total cap (MAX_QI_SOURCES = 16) so "16 sources" means the same
|
|
565
|
+
// thing everywhere. The cap is max(maxConnectedSources, maxLocalKnowledgeSources): never
|
|
566
|
+
// smaller than either per-list limit, so each list's own cap stays reachable. Growth-only:
|
|
567
|
+
// a pre-existing over-cap chat may shrink or hold its lists (no migration lock-out), but no
|
|
568
|
+
// patch may grow the combined total past the cap.
|
|
569
|
+
// Effective count after applying a resolved list patch: undefined = unchanged, null = cleared.
|
|
570
|
+
function patchedCount(resolved, prev) {
|
|
571
|
+
if (resolved === undefined)
|
|
572
|
+
return prev;
|
|
573
|
+
return resolved === null ? 0 : resolved.length;
|
|
574
|
+
}
|
|
575
|
+
function combinedSourceCap(options) {
|
|
576
|
+
return Math.max(options?.maxConnectedSources ?? DEFAULT_GROUNDING_LIMITS.maxConnectedSources, options?.maxLocalKnowledgeSources ?? DEFAULT_GROUNDING_LIMITS.maxLocalKnowledgeSources);
|
|
577
|
+
}
|
|
578
|
+
function validateTotalSourceCap(db, id, patch, options) {
|
|
579
|
+
const nextConnected = resolveScopePatch(patch);
|
|
580
|
+
const nextLk = resolveLocalKnowledgeScopePatch(patch);
|
|
581
|
+
if (nextConnected === undefined && nextLk === undefined)
|
|
582
|
+
return;
|
|
583
|
+
const existing = findChatById(db, id);
|
|
584
|
+
if (existing === undefined)
|
|
585
|
+
return; // the UPDATE below raises notFound
|
|
586
|
+
const prevConnected = existing.connectedScopes ??
|
|
587
|
+
(existing.connectedScope !== undefined ? [existing.connectedScope] : []);
|
|
588
|
+
const prevLk = existing.localKnowledgeScopes ??
|
|
589
|
+
(existing.localKnowledgeScope !== undefined ? [existing.localKnowledgeScope] : []);
|
|
590
|
+
const total = patchedCount(nextConnected, prevConnected.length) + patchedCount(nextLk, prevLk.length);
|
|
591
|
+
const prevTotal = prevConnected.length + prevLk.length;
|
|
592
|
+
const cap = combinedSourceCap(options);
|
|
593
|
+
if (total > cap && total > prevTotal) {
|
|
594
|
+
throw invalidRequest(`A chat may connect at most ${String(cap)} sources in total (folders, files, repositories, and knowledge connectors combined).`);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
export function updateChat(db, id, patch, now, options) {
|
|
598
|
+
validateChatPatch(patch, options);
|
|
599
|
+
validateTotalSourceCap(db, id, patch, options);
|
|
600
|
+
if (patch.selectedModel !== undefined)
|
|
601
|
+
validateSelectedModel(patch.selectedModel);
|
|
602
|
+
const titleParam = patch.title ?? null;
|
|
603
|
+
const modelParam = patch.selectedModel ?? null;
|
|
604
|
+
const branchParam = patch.branchLabel ?? null;
|
|
605
|
+
const statusParam = patch.status ?? null;
|
|
606
|
+
const scope = scopeUpdateParams(resolveScopePatch(patch));
|
|
607
|
+
const localScope = localKnowledgeScopesUpdateParams(resolveLocalKnowledgeScopePatch(patch));
|
|
608
|
+
const row = db
|
|
609
|
+
.prepare(SQL_UPDATE)
|
|
610
|
+
.get(titleParam, modelParam, branchParam, statusParam, now, scope.apply, scope.pathsJson, scope.apply, scope.connectedAtMs, localScope.apply, localScope.json, id);
|
|
611
|
+
if (row === undefined)
|
|
612
|
+
throw notFound("Chat");
|
|
613
|
+
return rowToChat(row);
|
|
614
|
+
}
|
|
615
|
+
export function deleteChat(db, id) {
|
|
616
|
+
const info = db.prepare(SQL_DELETE).run(id);
|
|
617
|
+
if (info.changes === 0)
|
|
618
|
+
throw notFound("Chat");
|
|
619
|
+
}
|
|
620
|
+
export function touchChat(db, id, now) {
|
|
621
|
+
const info = db.prepare(SQL_TOUCH).run(now, id);
|
|
622
|
+
if (info.changes === 0)
|
|
623
|
+
throw notFound("Chat");
|
|
624
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DatabaseSync } from "node:sqlite";
|
|
2
|
+
import type { UiStore, UiStoreFactoryOptions } from "./types.js";
|
|
3
|
+
export declare function isProjectAvailable(project: {
|
|
4
|
+
readonly path: string;
|
|
5
|
+
}): boolean;
|
|
6
|
+
export declare const UI_DB_BUSY_TIMEOUT_MS = 5000;
|
|
7
|
+
export declare function createInMemoryUiStore(opts?: UiStoreFactoryOptions): UiStore;
|
|
8
|
+
export declare function openNodeUiDatabase(dbPath: string): DatabaseSync;
|
|
9
|
+
export declare function buildUiStoreOverDatabase(db: DatabaseSync, opts?: UiStoreFactoryOptions): UiStore;
|
|
10
|
+
export declare function createNodeUiStore(dbPath: string, opts?: UiStoreFactoryOptions): UiStore;
|
|
11
|
+
//# sourceMappingURL=db.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/store/db.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,KAAK,EAMV,OAAO,EACP,qBAAqB,EAKtB,MAAM,YAAY,CAAC;AAiCpB,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAM9E;AA+JD,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAa3C,wBAAgB,qBAAqB,CAAC,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAI3E;AAgCD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAkB/D;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAEhG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAEvF"}
|