@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,26 @@
|
|
|
1
|
+
export declare const RRF_K = 60;
|
|
2
|
+
export type RerankKind = "folder" | "connector";
|
|
3
|
+
export interface RerankInput<P> {
|
|
4
|
+
readonly kind: RerankKind;
|
|
5
|
+
readonly redactedText: string;
|
|
6
|
+
readonly engineScore: number;
|
|
7
|
+
readonly sourceLabel: string;
|
|
8
|
+
readonly tieKey: string;
|
|
9
|
+
readonly payload: P;
|
|
10
|
+
}
|
|
11
|
+
export interface RerankBudget {
|
|
12
|
+
readonly maxCandidates: number;
|
|
13
|
+
readonly maxExcerptBytes: number;
|
|
14
|
+
}
|
|
15
|
+
export interface SelectedCandidate<P> {
|
|
16
|
+
readonly kind: RerankKind;
|
|
17
|
+
readonly redactedText: string;
|
|
18
|
+
readonly bytes: number;
|
|
19
|
+
readonly sourceLabel: string;
|
|
20
|
+
readonly engineRank: number;
|
|
21
|
+
readonly fusedScore: number;
|
|
22
|
+
readonly marker: number;
|
|
23
|
+
readonly payload: P;
|
|
24
|
+
}
|
|
25
|
+
export declare function rerankAndSelect<P>(inputs: readonly RerankInput<P>[], budget: RerankBudget): readonly SelectedCandidate<P>[];
|
|
26
|
+
//# sourceMappingURL=grounded-rerank.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grounded-rerank.d.ts","sourceRoot":"","sources":["../src/grounded-rerank.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK,KAAK,CAAC;AAExB,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,WAAW,CAAC;AAEhD,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;CACrB;AA4DD,wBAAgB,eAAe,CAAC,CAAC,EAC/B,MAAM,EAAE,SAAS,WAAW,CAAC,CAAC,CAAC,EAAE,EACjC,MAAM,EAAE,YAAY,GACnB,SAAS,iBAAiB,CAAC,CAAC,CAAC,EAAE,CA4BjC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Reciprocal Rank Fusion (Cormack et al. 2009, k=60) over candidates from two retrieval engines
|
|
2
|
+
// whose native scores are NOT comparable (folder lexical vs connector vector). Each engine's
|
|
3
|
+
// candidates are ranked among themselves; RRF fuses by rank; a shared budget then selects globally
|
|
4
|
+
// so neither engine structurally dominates. Deterministic. See ADR-0036.
|
|
5
|
+
export const RRF_K = 60;
|
|
6
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
7
|
+
function quantize(x) {
|
|
8
|
+
return Math.round(x * 1e6) / 1e6;
|
|
9
|
+
}
|
|
10
|
+
// Partition inputs by kind, rank within each kind, return merged ranked list.
|
|
11
|
+
// Tie-break order within the merged sort:
|
|
12
|
+
// 1. fusedScore DESC
|
|
13
|
+
// 2. kind: "connector" before "folder" — anti-dominance at rank parity: a connector never loses
|
|
14
|
+
// a same-rank tie to a folder. This preserves equal representation when both engines produce
|
|
15
|
+
// identical top-k ranks.
|
|
16
|
+
// 3. tieKey ASC — stable, deterministic across any input permutation.
|
|
17
|
+
function buildRanked(inputs) {
|
|
18
|
+
const folders = inputs.filter((i) => i.kind === "folder");
|
|
19
|
+
const connectors = inputs.filter((i) => i.kind === "connector");
|
|
20
|
+
function rankGroup(group) {
|
|
21
|
+
const sorted = [...group].sort((a, b) => b.engineScore - a.engineScore || a.tieKey.localeCompare(b.tieKey));
|
|
22
|
+
return sorted.map((input, idx) => {
|
|
23
|
+
const engineRank = idx + 1;
|
|
24
|
+
return {
|
|
25
|
+
input,
|
|
26
|
+
engineRank,
|
|
27
|
+
fusedScore: quantize(1 / (RRF_K + engineRank)),
|
|
28
|
+
bytes: Buffer.byteLength(input.redactedText, "utf8"),
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const ranked = [...rankGroup(folders), ...rankGroup(connectors)];
|
|
33
|
+
// Sort merged list: score DESC, then connector before folder, then tieKey ASC.
|
|
34
|
+
ranked.sort((a, b) => {
|
|
35
|
+
if (b.fusedScore !== a.fusedScore)
|
|
36
|
+
return b.fusedScore - a.fusedScore;
|
|
37
|
+
if (a.input.kind !== b.input.kind) {
|
|
38
|
+
// "connector" < "folder" lexicographically, but we want connector FIRST.
|
|
39
|
+
return a.input.kind === "connector" ? -1 : 1;
|
|
40
|
+
}
|
|
41
|
+
return a.input.tieKey.localeCompare(b.input.tieKey);
|
|
42
|
+
});
|
|
43
|
+
return ranked;
|
|
44
|
+
}
|
|
45
|
+
// ─── Public function ──────────────────────────────────────────────────────────
|
|
46
|
+
export function rerankAndSelect(inputs, budget) {
|
|
47
|
+
if (inputs.length === 0)
|
|
48
|
+
return [];
|
|
49
|
+
const ranked = buildRanked(inputs);
|
|
50
|
+
const selected = [];
|
|
51
|
+
let runningBytes = 0;
|
|
52
|
+
for (const r of ranked) {
|
|
53
|
+
if (selected.length >= budget.maxCandidates)
|
|
54
|
+
break;
|
|
55
|
+
const fits = runningBytes + r.bytes <= budget.maxExcerptBytes;
|
|
56
|
+
// Floor: always keep the first candidate even if it alone exceeds the byte budget.
|
|
57
|
+
if (!fits && selected.length > 0)
|
|
58
|
+
continue;
|
|
59
|
+
runningBytes += r.bytes;
|
|
60
|
+
selected.push({
|
|
61
|
+
kind: r.input.kind,
|
|
62
|
+
redactedText: r.input.redactedText,
|
|
63
|
+
bytes: r.bytes,
|
|
64
|
+
sourceLabel: r.input.sourceLabel,
|
|
65
|
+
engineRank: r.engineRank,
|
|
66
|
+
fusedScore: r.fusedScore,
|
|
67
|
+
marker: selected.length + 1,
|
|
68
|
+
payload: r.input.payload,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return selected;
|
|
72
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ConnectedContextPack } from "@oscharko-dev/keiko-contracts/connected-context";
|
|
2
|
+
export interface GroundedTurnRecord {
|
|
3
|
+
readonly assistantMessageId: string;
|
|
4
|
+
readonly chatId: string;
|
|
5
|
+
readonly workspaceRoot: string;
|
|
6
|
+
readonly evidenceRunId?: string | undefined;
|
|
7
|
+
readonly packs: readonly ConnectedContextPack[];
|
|
8
|
+
}
|
|
9
|
+
export interface GroundedTurnRegistry {
|
|
10
|
+
remember: (record: GroundedTurnRecord, nowMs?: () => number) => void;
|
|
11
|
+
lookup: (assistantMessageId: string, nowMs?: () => number) => GroundedTurnRecord | undefined;
|
|
12
|
+
clearConversation: (chatId: string) => void;
|
|
13
|
+
clearWorkspace: (workspaceRoot: string) => void;
|
|
14
|
+
clearAll: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function createGroundedTurnRegistry(ttlMs?: number, maxEntries?: number): GroundedTurnRegistry;
|
|
17
|
+
export declare const groundedTurnRegistry: GroundedTurnRegistry;
|
|
18
|
+
export declare function rememberGroundedTurn(record: GroundedTurnRecord, nowMs?: () => number): void;
|
|
19
|
+
export declare function lookupGroundedTurn(assistantMessageId: string, nowMs?: () => number): GroundedTurnRecord | undefined;
|
|
20
|
+
export declare function clearGroundedTurnsForConversation(chatId: string): void;
|
|
21
|
+
export declare function clearGroundedTurnsForWorkspace(workspaceRoot: string): void;
|
|
22
|
+
export declare function clearAllGroundedTurns(): void;
|
|
23
|
+
//# sourceMappingURL=grounded-turn-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grounded-turn-registry.d.ts","sourceRoot":"","sources":["../src/grounded-turn-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AAK5F,MAAM,WAAW,kBAAkB;IACjC,QAAQ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TL_MS = 15 * 60_000;
|
|
2
|
+
const DEFAULT_MAX_ENTRIES = 256;
|
|
3
|
+
function packForHandoffRegistry(pack) {
|
|
4
|
+
return {
|
|
5
|
+
...pack,
|
|
6
|
+
files: pack.files.map((file) => ({
|
|
7
|
+
...file,
|
|
8
|
+
excerpts: file.excerpts.map((excerpt) => ({
|
|
9
|
+
...excerpt,
|
|
10
|
+
content: "",
|
|
11
|
+
contentBytes: 0,
|
|
12
|
+
})),
|
|
13
|
+
})),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function recordForHandoffRegistry(record) {
|
|
17
|
+
return {
|
|
18
|
+
...record,
|
|
19
|
+
packs: record.packs.map(packForHandoffRegistry),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function sweepExpired(entries, now) {
|
|
23
|
+
for (const [key, entry] of entries) {
|
|
24
|
+
if (entry.expiresAtMs <= now) {
|
|
25
|
+
entries.delete(key);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function evictOldest(entries, maxEntries) {
|
|
30
|
+
while (entries.size >= maxEntries) {
|
|
31
|
+
let oldest;
|
|
32
|
+
for (const entry of entries.values()) {
|
|
33
|
+
if (oldest === undefined || entry.touchedAtMs < oldest.touchedAtMs) {
|
|
34
|
+
oldest = entry;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (oldest === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
entries.delete(oldest.assistantMessageId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function createGroundedTurnRegistry(ttlMs = DEFAULT_TTL_MS, maxEntries = DEFAULT_MAX_ENTRIES) {
|
|
44
|
+
const entries = new Map();
|
|
45
|
+
return {
|
|
46
|
+
remember(record, nowMs = Date.now) {
|
|
47
|
+
const now = nowMs();
|
|
48
|
+
sweepExpired(entries, now);
|
|
49
|
+
evictOldest(entries, maxEntries);
|
|
50
|
+
const safeRecord = recordForHandoffRegistry(record);
|
|
51
|
+
entries.set(record.assistantMessageId, {
|
|
52
|
+
...safeRecord,
|
|
53
|
+
touchedAtMs: now,
|
|
54
|
+
expiresAtMs: now + ttlMs,
|
|
55
|
+
});
|
|
56
|
+
},
|
|
57
|
+
lookup(assistantMessageId, nowMs = Date.now) {
|
|
58
|
+
const now = nowMs();
|
|
59
|
+
sweepExpired(entries, now);
|
|
60
|
+
const entry = entries.get(assistantMessageId);
|
|
61
|
+
if (entry === undefined) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
entry.touchedAtMs = now;
|
|
65
|
+
entry.expiresAtMs = now + ttlMs;
|
|
66
|
+
return entry;
|
|
67
|
+
},
|
|
68
|
+
clearConversation(chatId) {
|
|
69
|
+
for (const [key, entry] of entries) {
|
|
70
|
+
if (entry.chatId === chatId) {
|
|
71
|
+
entries.delete(key);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
clearWorkspace(workspaceRoot) {
|
|
76
|
+
for (const [key, entry] of entries) {
|
|
77
|
+
if (entry.workspaceRoot === workspaceRoot) {
|
|
78
|
+
entries.delete(key);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
clearAll() {
|
|
83
|
+
entries.clear();
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export const groundedTurnRegistry = createGroundedTurnRegistry();
|
|
88
|
+
export function rememberGroundedTurn(record, nowMs) {
|
|
89
|
+
groundedTurnRegistry.remember(record, nowMs);
|
|
90
|
+
}
|
|
91
|
+
export function lookupGroundedTurn(assistantMessageId, nowMs) {
|
|
92
|
+
return groundedTurnRegistry.lookup(assistantMessageId, nowMs);
|
|
93
|
+
}
|
|
94
|
+
export function clearGroundedTurnsForConversation(chatId) {
|
|
95
|
+
groundedTurnRegistry.clearConversation(chatId);
|
|
96
|
+
}
|
|
97
|
+
export function clearGroundedTurnsForWorkspace(workspaceRoot) {
|
|
98
|
+
groundedTurnRegistry.clearWorkspace(workspaceRoot);
|
|
99
|
+
}
|
|
100
|
+
export function clearAllGroundedTurns() {
|
|
101
|
+
groundedTurnRegistry.clearAll();
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"headers.d.ts","sourceRoot":"","sources":["../src/headers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAchD,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,IAAI,CAQ/F"}
|
package/dist/headers.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Security headers (ADR-0011 D5) applied to every BFF response. The CSP is precomputed once from
|
|
2
|
+
// the static export's inline-script hashes (see csp.ts) and reused for all responses.
|
|
3
|
+
// Headers set on every response regardless of route.
|
|
4
|
+
const BASE_SECURITY_HEADERS = {
|
|
5
|
+
"X-Content-Type-Options": "nosniff",
|
|
6
|
+
"X-Frame-Options": "DENY",
|
|
7
|
+
"Referrer-Policy": "no-referrer",
|
|
8
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
9
|
+
"Cross-Origin-Resource-Policy": "same-origin",
|
|
10
|
+
"Permissions-Policy": "camera=(), geolocation=(), microphone=(), payment=(), usb=()",
|
|
11
|
+
};
|
|
12
|
+
// Applies the CSP and the base security headers, plus `Cache-Control: no-store` for API responses
|
|
13
|
+
// (the contract requires it on every `/api/*` response; D5).
|
|
14
|
+
export function applySecurityHeaders(res, csp, isApiPath) {
|
|
15
|
+
res.setHeader("Content-Security-Policy", csp);
|
|
16
|
+
for (const [name, value] of Object.entries(BASE_SECURITY_HEADERS)) {
|
|
17
|
+
res.setHeader(name, value);
|
|
18
|
+
}
|
|
19
|
+
if (isApiPath) {
|
|
20
|
+
res.setHeader("Cache-Control", "no-store");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-check.d.ts","sourceRoot":"","sources":["../src/host-check.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AA+CjD,wBAAgB,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAWjF"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// DNS-rebinding defense (ADR-0011 D5). The BFF binds 127.0.0.1 only and rejects any request whose
|
|
2
|
+
// `Host` header (or `Origin`, when present) does not name the loopback interface on the bound port.
|
|
3
|
+
// A rebinding attacker controls the victim's DNS but cannot forge the loopback host:port the
|
|
4
|
+
// browser sends, so this check blocks cross-origin access to the local server.
|
|
5
|
+
// Hostnames that legitimately resolve to the loopback interface.
|
|
6
|
+
const LOOPBACK_HOSTS = new Set(["127.0.0.1", "localhost", "[::1]", "::1"]);
|
|
7
|
+
// Parses a `host:port` authority into its host (lowercased) and optional port. IPv6 literals are
|
|
8
|
+
// kept in their bracketed form so they compare against LOOPBACK_HOSTS.
|
|
9
|
+
function splitAuthority(authority) {
|
|
10
|
+
const trimmed = authority.trim().toLowerCase();
|
|
11
|
+
if (trimmed.startsWith("[")) {
|
|
12
|
+
const close = trimmed.indexOf("]");
|
|
13
|
+
const host = close === -1 ? trimmed : trimmed.slice(0, close + 1);
|
|
14
|
+
const rest = close === -1 ? "" : trimmed.slice(close + 1);
|
|
15
|
+
const port = rest.startsWith(":") ? rest.slice(1) : undefined;
|
|
16
|
+
return { host, port };
|
|
17
|
+
}
|
|
18
|
+
const colon = trimmed.lastIndexOf(":");
|
|
19
|
+
if (colon === -1) {
|
|
20
|
+
return { host: trimmed, port: undefined };
|
|
21
|
+
}
|
|
22
|
+
return { host: trimmed.slice(0, colon), port: trimmed.slice(colon + 1) };
|
|
23
|
+
}
|
|
24
|
+
function isLoopbackAuthority(authority, expectedPort) {
|
|
25
|
+
const { host, port } = splitAuthority(authority);
|
|
26
|
+
if (!LOOPBACK_HOSTS.has(host)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return port === String(expectedPort);
|
|
30
|
+
}
|
|
31
|
+
function originAuthority(origin) {
|
|
32
|
+
try {
|
|
33
|
+
const parsed = new URL(origin);
|
|
34
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
return parsed.host;
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// A request is accepted only if its `Host` is a loopback authority on the bound port and, when an
|
|
44
|
+
// `Origin` is present, that origin is also loopback on the bound port. Opaque `Origin: null` is
|
|
45
|
+
// rejected because state-changing API routes are reachable from sandboxed/file origins otherwise.
|
|
46
|
+
// A missing `Host` is rejected.
|
|
47
|
+
export function isAllowedHost(req, expectedPort) {
|
|
48
|
+
const host = req.headers.host;
|
|
49
|
+
if (host === undefined || !isLoopbackAuthority(host, expectedPort)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
const origin = req.headers.origin;
|
|
53
|
+
if (origin === undefined) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
const authority = originAuthority(origin);
|
|
57
|
+
return authority !== undefined && isLoopbackAuthority(authority, expectedPort);
|
|
58
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export { createUiServer, DEFAULT_UI_PORT, UI_HOST, type UiServerDeps } from "./server.js";
|
|
2
|
+
export { buildCspHeader, extractInlineScriptHashes } from "./csp.js";
|
|
3
|
+
export { createLiveCspHeaderProvider, loadCspHeader } from "./load-csp.js";
|
|
4
|
+
export { applySecurityHeaders } from "./headers.js";
|
|
5
|
+
export { isAllowedHost } from "./host-check.js";
|
|
6
|
+
export { resolveContainedPath, serveFile } from "./static.js";
|
|
7
|
+
export { API_ROUTES, isApiPath, matchRoute, errorBody, STREAMING, type ApiError, type HandlerOutcome, type RouteContext, type RouteDefinition, type RouteHandler, type RouteMatch, type RouteResult, } from "./routes.js";
|
|
8
|
+
export { buildUiHandlerDeps, buildRedactor, type UiHandlerDeps, type BuildHandlerDepsOptions, type Redactor, type ModelPortFactory, } from "./deps.js";
|
|
9
|
+
export { createRunRegistry, ActiveRunLimitError, type RunRegistry, type RunRecord, type RunStatus, type AppliableSnapshot, } from "./runs.js";
|
|
10
|
+
export { QueueEventSink, type StreamEvent, type SseWriter } from "./sink.js";
|
|
11
|
+
export { parseRunRequest, type RunRequest, type RunKind } from "./run-request.js";
|
|
12
|
+
export { startRun, applyRun, type StartRunResult } from "./run-engine.js";
|
|
13
|
+
export { handleCreateRun, handleRunEvents, handleCancelRun, handleGetRun, handleApplyRun, } from "./run-handlers.js";
|
|
14
|
+
export { persistWorkflowEvidence, persistExplainEvidence, type EvidencePersistContext, type RunIdentity, } from "./evidence.js";
|
|
15
|
+
export { createInMemoryUiStore, createNodeUiStore, isProjectAvailable, resolveUiDbPath, runMigrations, SCHEMA_VERSION, UI_DB_DIRNAME, UI_DB_FILENAME, UiStoreError, validateProjectPath, type Chat, type ChatMessage, type ChatRole, type CreateChatOptions, type NewChatMessage, type Project, type UiStore, type UiStoreErrorCode, type UiStoreFactoryOptions, type UpdateChatPatch, type UpdateProjectPatch, type WorkflowStatus, } from "./store/index.js";
|
|
16
|
+
export { handleListProjects, handleCreateProject, handleUpdateProject, handleDeleteProject, handleListChats, handleCreateChat, handleUpdateChat, handleDeleteChat, handleListMessages, handleCreateMessage, } from "./store-handlers.js";
|
|
17
|
+
export { handleDeleteLocalKnowledgeCapsule, handleGetLocalKnowledgeCapsule, handleListLocalKnowledgeCapsules, handleReindexLocalKnowledgeCapsule, } from "./local-knowledge-handlers.js";
|
|
18
|
+
export { createTerminalExecutionManager, buildTerminalPolicySummary, listDirectories, type TerminalDirectoryListing, type TerminalExecutionInput, type TerminalExecutionManager, type TerminalExecutionResult, type TerminalEventEmitter, type TerminalEventEnvelope, type TerminalEventKind, type TerminalPolicySummary, } from "./terminal.js";
|
|
19
|
+
export { TerminalToolError, type TerminalErrorCode } from "./terminal-errors.js";
|
|
20
|
+
export { runMemoryMaintenance, type MaintenanceCounts } from "./memory-maintenance-handlers.js";
|
|
21
|
+
export { exportMemoryDiagnostics, type ExportMemoryDiagnosticsOptions, type MemoryDiagnostics, type MemoryScopeCount, type MemoryStatusHistogram, } from "./memory-diagnostics.js";
|
|
22
|
+
export { createMemoryEmbedder, selectMemoryEmbeddingModelId, type MemoryEmbedder, } from "./memory-embedding.js";
|
|
23
|
+
export { buildTerminalEvidenceEntry, appendTerminalEvidence, type TerminalEvidenceEntry, } from "./terminal-evidence.js";
|
|
24
|
+
export { handleFilesContent, listFilesDirectories, readFilesContent, readFilesPreview, readFilesTree, writeFilesContent, type FilesContentResponse, type FilesDirectoryEntry, type FilesDirectoryListing, type FilesDirectoryRoot, type FilesEntryKind, type FilesPreviewResponse, type FilesTreeEntry, type FilesTreeResponse, } from "./files.js";
|
|
25
|
+
export { handlePromptEnhancement, buildPromptEnhancementRecordInput, runPromptEnhancement, PromptEnhancementCancelledError, PromptEnhancementInputError, type RunPromptEnhancementDeps, } from "./promptEnhancer/index.js";
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,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ACb,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC1B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC;AAKpB,OAAO,EACL,uBAAuB,EACvB,iCAAiC,EACjC,oBAAoB,EACpB,+BAA+B,EAC/B,2BAA2B,EAC3B,KAAK,wBAAwB,GAC9B,MAAM,2BAA2B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Public barrel for the local UI BFF runtime (ADR-0019 §"Target Package Topology"
|
|
2
|
+
// row keiko-server). The browser tier stays presentation-only: model, filesystem,
|
|
3
|
+
// PTY, and harness authority remain in the loopback Node process behind JSON, SSE,
|
|
4
|
+
// and token-scoped WebSocket seams.
|
|
5
|
+
export { createUiServer, DEFAULT_UI_PORT, UI_HOST } from "./server.js";
|
|
6
|
+
export { buildCspHeader, extractInlineScriptHashes } from "./csp.js";
|
|
7
|
+
export { createLiveCspHeaderProvider, loadCspHeader } from "./load-csp.js";
|
|
8
|
+
export { applySecurityHeaders } from "./headers.js";
|
|
9
|
+
export { isAllowedHost } from "./host-check.js";
|
|
10
|
+
export { resolveContainedPath, serveFile } from "./static.js";
|
|
11
|
+
export { API_ROUTES, isApiPath, matchRoute, errorBody, STREAMING, } from "./routes.js";
|
|
12
|
+
export { buildUiHandlerDeps, buildRedactor, } from "./deps.js";
|
|
13
|
+
export { createRunRegistry, ActiveRunLimitError, } from "./runs.js";
|
|
14
|
+
export { QueueEventSink } from "./sink.js";
|
|
15
|
+
export { parseRunRequest } from "./run-request.js";
|
|
16
|
+
export { startRun, applyRun } from "./run-engine.js";
|
|
17
|
+
export { handleCreateRun, handleRunEvents, handleCancelRun, handleGetRun, handleApplyRun, } from "./run-handlers.js";
|
|
18
|
+
export { persistWorkflowEvidence, persistExplainEvidence, } from "./evidence.js";
|
|
19
|
+
// ADR-0013 — UI-local SQLite persistence: ports, factories, and route handlers.
|
|
20
|
+
export { createInMemoryUiStore, createNodeUiStore, isProjectAvailable, resolveUiDbPath, runMigrations, SCHEMA_VERSION, UI_DB_DIRNAME, UI_DB_FILENAME, UiStoreError, validateProjectPath, } from "./store/index.js";
|
|
21
|
+
export { handleListProjects, handleCreateProject, handleUpdateProject, handleDeleteProject, handleListChats, handleCreateChat, handleUpdateChat, handleDeleteChat, handleListMessages, handleCreateMessage, } from "./store-handlers.js";
|
|
22
|
+
export { handleDeleteLocalKnowledgeCapsule, handleGetLocalKnowledgeCapsule, handleListLocalKnowledgeCapsules, handleReindexLocalKnowledgeCapsule, } from "./local-knowledge-handlers.js";
|
|
23
|
+
export { createTerminalExecutionManager, buildTerminalPolicySummary, listDirectories, } from "./terminal.js";
|
|
24
|
+
export { TerminalToolError } from "./terminal-errors.js";
|
|
25
|
+
export { runMemoryMaintenance } from "./memory-maintenance-handlers.js";
|
|
26
|
+
export { exportMemoryDiagnostics, } from "./memory-diagnostics.js";
|
|
27
|
+
export { createMemoryEmbedder, selectMemoryEmbeddingModelId, } from "./memory-embedding.js";
|
|
28
|
+
export { buildTerminalEvidenceEntry, appendTerminalEvidence, } from "./terminal-evidence.js";
|
|
29
|
+
export { handleFilesContent, listFilesDirectories, readFilesContent, readFilesPreview, readFilesTree, writeFilesContent, } from "./files.js";
|
|
30
|
+
// Epic #1307 / Issue #1314 — Prompt Enhancer governed surface. The BFF route handler and the reusable,
|
|
31
|
+
// deterministic orchestration the CLI command (`keiko prompt-enhancer`) drives so both surfaces produce
|
|
32
|
+
// byte-identical enhancements (AC1). Routed through the Model Gateway; never dispatches a model.
|
|
33
|
+
export { handlePromptEnhancement, buildPromptEnhancementRecordInput, runPromptEnhancement, PromptEnhancementCancelledError, PromptEnhancementInputError, } from "./promptEnhancer/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-csp.d.ts","sourceRoot":"","sources":["../src/load-csp.ts"],"names":[],"mappings":"AA0EA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CASvE;AAWD,wBAAgB,2BAA2B,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAiBrF"}
|
package/dist/load-csp.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { readFile, readdir, stat } from "node:fs/promises";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { buildCspHeader, extractInlineScriptHashes } from "./csp.js";
|
|
4
|
+
function parseHashes(raw) {
|
|
5
|
+
const parsed = JSON.parse(raw);
|
|
6
|
+
if (!Array.isArray(parsed)) {
|
|
7
|
+
return [];
|
|
8
|
+
}
|
|
9
|
+
return parsed.filter((entry) => typeof entry === "string");
|
|
10
|
+
}
|
|
11
|
+
async function collectHtmlFiles(staticRoot) {
|
|
12
|
+
let entries;
|
|
13
|
+
try {
|
|
14
|
+
const raw = await readdir(staticRoot, { withFileTypes: true });
|
|
15
|
+
entries = raw.map((entry) => ({
|
|
16
|
+
isDirectory: () => entry.isDirectory(),
|
|
17
|
+
name: entry.name,
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const files = [];
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
const resolved = join(staticRoot, entry.name);
|
|
26
|
+
if (entry.isDirectory()) {
|
|
27
|
+
files.push(...(await collectHtmlFiles(resolved)));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (entry.name.endsWith(".html")) {
|
|
31
|
+
files.push(resolved);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return files;
|
|
35
|
+
}
|
|
36
|
+
function normalizeHashes(raw) {
|
|
37
|
+
return [...raw].filter((value) => value !== "").sort();
|
|
38
|
+
}
|
|
39
|
+
function hashesMatch(left, right) {
|
|
40
|
+
if (left.length !== right.length)
|
|
41
|
+
return false;
|
|
42
|
+
for (let i = 0; i < left.length; i += 1) {
|
|
43
|
+
if (left[i] !== right[i])
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
async function loadHashesFromFile(hashesFile) {
|
|
49
|
+
try {
|
|
50
|
+
const raw = await readFile(hashesFile, "utf8");
|
|
51
|
+
return normalizeHashes(parseHashes(raw));
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async function loadHashesFromExport(staticRoot) {
|
|
58
|
+
const htmlFiles = await collectHtmlFiles(staticRoot);
|
|
59
|
+
if (htmlFiles.length === 0) {
|
|
60
|
+
return [];
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
const documents = await Promise.all(htmlFiles.map((file) => readFile(file, "utf8")));
|
|
64
|
+
return normalizeHashes(extractInlineScriptHashes(documents));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
export async function loadCspHeader(hashesFile) {
|
|
71
|
+
const fileHashes = await loadHashesFromFile(hashesFile);
|
|
72
|
+
const staticRoot = join(dirname(hashesFile), "static");
|
|
73
|
+
const exportHashes = await loadHashesFromExport(staticRoot);
|
|
74
|
+
// If persisted hashes are stale or incompatible with current exported HTML,
|
|
75
|
+
// prefer derived hashes so startup can recover from stale artifacts.
|
|
76
|
+
const hashes = exportHashes.length > 0 && !hashesMatch(fileHashes, exportHashes) ? exportHashes : fileHashes;
|
|
77
|
+
return buildCspHeader(hashes);
|
|
78
|
+
}
|
|
79
|
+
function signatureFor(stats) {
|
|
80
|
+
return `${String(stats.mtimeMs)}:${String(stats.size)}`;
|
|
81
|
+
}
|
|
82
|
+
export function createLiveCspHeaderProvider(hashesFile) {
|
|
83
|
+
const cache = { signature: undefined, header: buildCspHeader([]) };
|
|
84
|
+
return async () => {
|
|
85
|
+
let signature;
|
|
86
|
+
try {
|
|
87
|
+
signature = signatureFor(await stat(hashesFile));
|
|
88
|
+
}
|
|
89
|
+
catch {
|
|
90
|
+
cache.signature = undefined;
|
|
91
|
+
cache.header = buildCspHeader([]);
|
|
92
|
+
return cache.header;
|
|
93
|
+
}
|
|
94
|
+
if (signature !== cache.signature) {
|
|
95
|
+
cache.signature = signature;
|
|
96
|
+
cache.header = await loadCspHeader(hashesFile);
|
|
97
|
+
}
|
|
98
|
+
return cache.header;
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { runGroundedAnswer, type AnswerGeneratorInput, type KnowledgeStore } from "@oscharko-dev/keiko-local-knowledge";
|
|
2
|
+
import type { Chat, ChatLocalKnowledgeScope, LocalKnowledgeEvidenceCitation } from "@oscharko-dev/keiko-contracts/bff-wire";
|
|
3
|
+
import type { KnowledgeCapsule, RetrievalReference } from "@oscharko-dev/keiko-contracts";
|
|
4
|
+
import { type OpenAIEmbeddingAdapter } from "@oscharko-dev/keiko-model-gateway";
|
|
5
|
+
import type { UiHandlerDeps } from "./deps.js";
|
|
6
|
+
import type { RouteResult } from "./routes.js";
|
|
7
|
+
export declare const DEFAULT_REFERENCE_BUDGET = 16;
|
|
8
|
+
export declare const MAX_EXCERPT_CHARS = 900;
|
|
9
|
+
export declare const MAX_PROMPT_REFERENCES = 16;
|
|
10
|
+
export declare const LOCAL_KNOWLEDGE_NO_EVIDENCE_ANSWER = "Keine Evidenz im ausgew\u00E4hlten Wissensumfang gefunden.";
|
|
11
|
+
export declare const LOCAL_KNOWLEDGE_SYSTEM_PROMPT: string;
|
|
12
|
+
interface AskInput {
|
|
13
|
+
readonly chatId: string;
|
|
14
|
+
readonly content: string;
|
|
15
|
+
readonly modelId: string | undefined;
|
|
16
|
+
}
|
|
17
|
+
export interface SelectedLocalKnowledgeScope {
|
|
18
|
+
readonly capsules: readonly KnowledgeCapsule[];
|
|
19
|
+
readonly scopeKind: "capsule" | "capsule-set";
|
|
20
|
+
readonly scopeLabel: string;
|
|
21
|
+
}
|
|
22
|
+
export type LocalKnowledgeCitationSourceLookup = (reference: RetrievalReference) => string | undefined;
|
|
23
|
+
type LabelRedactor = (value: string) => string;
|
|
24
|
+
type AnswerCitation = AnswerGeneratorInput["references"][number]["citation"];
|
|
25
|
+
export declare function openStoreForDeps(deps: UiHandlerDeps): {
|
|
26
|
+
readonly store: KnowledgeStore;
|
|
27
|
+
close(): void;
|
|
28
|
+
};
|
|
29
|
+
export declare function createEmbeddingAdapter(deps: UiHandlerDeps, capsules: readonly KnowledgeCapsule[]): OpenAIEmbeddingAdapter | RouteResult;
|
|
30
|
+
export declare function selectedCapsulesForScope(scope: ChatLocalKnowledgeScope, store: KnowledgeStore): SelectedLocalKnowledgeScope | RouteResult;
|
|
31
|
+
export declare function scopeStateFailure(selected: SelectedLocalKnowledgeScope): {
|
|
32
|
+
readonly reason: string;
|
|
33
|
+
readonly message: string;
|
|
34
|
+
} | undefined;
|
|
35
|
+
export declare function renderCitationLabel(citation: AnswerCitation, redactLabel?: LabelRedactor): string;
|
|
36
|
+
export declare function buildSelectedScopeSourceLookup(store: KnowledgeStore, selected: SelectedLocalKnowledgeScope): LocalKnowledgeCitationSourceLookup;
|
|
37
|
+
export declare function projectLocalKnowledgeCitation(reference: RetrievalReference, marker: string, sourceLookup?: LocalKnowledgeCitationSourceLookup, redactLabel?: LabelRedactor): LocalKnowledgeEvidenceCitation;
|
|
38
|
+
export declare function enforcedNoEvidenceReason(result: Awaited<ReturnType<typeof runGroundedAnswer>>): string | undefined;
|
|
39
|
+
export declare function buildLocalKnowledgeCitations(result: Awaited<ReturnType<typeof runGroundedAnswer>>, noEvidenceReason: string | undefined, sourceLookup?: LocalKnowledgeCitationSourceLookup, redactLabel?: LabelRedactor): readonly LocalKnowledgeEvidenceCitation[];
|
|
40
|
+
export declare function handleLocalKnowledgeGroundedAsk(chat: Chat, input: AskInput, deps: UiHandlerDeps, signal: AbortSignal): Promise<RouteResult>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=local-knowledge-grounded-qa.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-knowledge-grounded-qa.d.ts","sourceRoot":"","sources":["../src/local-knowledge-grounded-qa.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,iBAAiB,EAEjB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACpB,MAAM,qCAAqC,CAAC;AAE7C,OAAO,KAAK,EACV,IAAI,EACJ,uBAAuB,EAIvB,8BAA8B,EAE/B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EACV,gBAAgB,EAGhB,kBAAkB,EACnB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAOL,KAAK,sBAAsB,EAG5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,eAAO,MAAM,wBAAwB,KAAK,CAAC;AAC3C,eAAO,MAAM,iBAAiB,MAAM,CAAC;AACrC,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,eAAO,MAAM,kCAAkC,+DACU,CAAC;AAG1D,eAAO,MAAM,6BAA6B,QAM0D,CAAC;AAYrG,UAAU,QAAQ;IAChB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;CACtC;AAED,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,QAAQ,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,aAAa,CAAC;IAC9C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM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