@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,9 @@
|
|
|
1
|
+
import type { RouteContext, RouteResult } from "../routes.js";
|
|
2
|
+
import type { UiHandlerDeps } from "../deps.js";
|
|
3
|
+
/**
|
|
4
|
+
* POST /api/prompt-enhancement — generate a governed, reviewable Enhanced Prompt from a raw draft.
|
|
5
|
+
* Validation, Model-Gateway routing (AC3), cancellation, and safe error shaping are all handled here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const handlePromptEnhancement: (ctx: RouteContext, deps: UiHandlerDeps) => Promise<RouteResult>;
|
|
8
|
+
export declare const handlePromptEnhancementEvidence: (ctx: RouteContext, deps: UiHandlerDeps) => RouteResult;
|
|
9
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/promptEnhancer/routes.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+JhD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,OAAO,CAAC,WAAW,CAwCrB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,WA0BF,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
// Prompt Enhancer BFF route (Epic #1307, Issue #1314; ADR-0044 §1 "BFF /api/prompt-enhancer/* routes").
|
|
2
|
+
//
|
|
3
|
+
// A single additive POST handler under `/api/prompt-enhancement`. It composes the existing route
|
|
4
|
+
// plumbing (RouteContext / UiHandlerDeps / errorBody) exactly like `qualityIntelligence/connectorRoutes`
|
|
5
|
+
// and does not modify any sibling handler. The deterministic enhancement is assembled by
|
|
6
|
+
// `runPromptEnhancement` (orchestrate.ts); this file owns only the HTTP envelope: bounded body read,
|
|
7
|
+
// JSON parsing, wire validation, cancellation, Model-Gateway config hand-off, redaction, and safe error
|
|
8
|
+
// shaping. No provider SDK import, no outbound network request, no model dispatch.
|
|
9
|
+
import { validatePromptEnhancementWireRequest } from "@oscharko-dev/keiko-contracts";
|
|
10
|
+
import { EvidenceReadError, EvidenceWriteError, InvalidRunIdError, loadPromptEnhancementRun, recordPromptEnhancementRun, } from "@oscharko-dev/keiko-evidence";
|
|
11
|
+
import { errorBody } from "../routes.js";
|
|
12
|
+
import { currentEvidenceRequiresFullStringRedaction, currentEvidenceTopologyRedactionSecrets, currentGatewayConfig, } from "../deps.js";
|
|
13
|
+
import { PromptEnhancementCancelledError, PromptEnhancementInputError, buildPromptEnhancementRecordInput, promptEnhancementGatewayRoutingConfig, runPromptEnhancement, } from "./orchestrate.js";
|
|
14
|
+
// A generous-but-bounded cap. A maximal valid request (a 100k-character draft, fully \uXXXX-escaped in
|
|
15
|
+
// JSON, plus the small metadata fields) stays well under this ceiling; anything larger is rejected with
|
|
16
|
+
// a 413 before parsing so a hostile upload cannot exhaust memory.
|
|
17
|
+
const MAX_BODY_BYTES = 1_048_576;
|
|
18
|
+
class BodyTooLargeError extends Error {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("Request body exceeds prompt-enhancement route cap");
|
|
21
|
+
this.name = "BodyTooLargeError";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const readBody = (req) => new Promise((resolve, reject) => {
|
|
25
|
+
const chunks = [];
|
|
26
|
+
let total = 0;
|
|
27
|
+
let capped = false;
|
|
28
|
+
req.on("data", (chunk) => {
|
|
29
|
+
total += chunk.length;
|
|
30
|
+
if (total > MAX_BODY_BYTES) {
|
|
31
|
+
if (!capped) {
|
|
32
|
+
capped = true;
|
|
33
|
+
chunks.length = 0;
|
|
34
|
+
reject(new BodyTooLargeError());
|
|
35
|
+
req.resume();
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
chunks.push(chunk);
|
|
40
|
+
});
|
|
41
|
+
req.on("end", () => {
|
|
42
|
+
if (!capped)
|
|
43
|
+
resolve(Buffer.concat(chunks).toString("utf8"));
|
|
44
|
+
});
|
|
45
|
+
req.on("error", reject);
|
|
46
|
+
});
|
|
47
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
48
|
+
const invalidRequest = (details) => ({
|
|
49
|
+
status: 400,
|
|
50
|
+
body: {
|
|
51
|
+
...errorBody("PROMPT_ENHANCER_INVALID_REQUEST", "The prompt enhancement request was invalid."),
|
|
52
|
+
details,
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
// Bind an AbortSignal to client disconnect. The res "close" event is the canonical "client gone" signal
|
|
56
|
+
// (the req "aborted" event is deprecated and fires unreliably since Node 17), mirroring grounded-qa.
|
|
57
|
+
const requestAbortSignal = (ctx) => {
|
|
58
|
+
const controller = new AbortController();
|
|
59
|
+
ctx.res.on("close", () => {
|
|
60
|
+
if (!ctx.res.writableEnded && !controller.signal.aborted) {
|
|
61
|
+
controller.abort("prompt enhancement request cancelled");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return controller.signal;
|
|
65
|
+
};
|
|
66
|
+
const cancelledResult = () => ({
|
|
67
|
+
status: 499,
|
|
68
|
+
body: errorBody("PROMPT_ENHANCER_CANCELLED", "The prompt enhancement request was cancelled."),
|
|
69
|
+
});
|
|
70
|
+
const notRecordedEvidence = () => ({
|
|
71
|
+
status: "not-recorded",
|
|
72
|
+
reason: "evidence-store-not-configured",
|
|
73
|
+
});
|
|
74
|
+
const peEvidenceUrl = (runId) => `/api/prompt-enhancement/evidence/${encodeURIComponent(runId)}`;
|
|
75
|
+
function recordEvidenceReference(rawInput, result, deps) {
|
|
76
|
+
if (deps.evidenceDir === undefined) {
|
|
77
|
+
return notRecordedEvidence();
|
|
78
|
+
}
|
|
79
|
+
const record = buildPromptEnhancementRecordInput({
|
|
80
|
+
rawInput,
|
|
81
|
+
result,
|
|
82
|
+
recordedAt: new Date().toISOString(),
|
|
83
|
+
});
|
|
84
|
+
const { manifest } = recordPromptEnhancementRun(record, {
|
|
85
|
+
evidenceDir: deps.evidenceDir,
|
|
86
|
+
redaction: {
|
|
87
|
+
additionalSecrets: currentEvidenceTopologyRedactionSecrets(deps),
|
|
88
|
+
redactAllStrings: currentEvidenceRequiresFullStringRedaction(deps),
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
status: "recorded",
|
|
93
|
+
reason: "evidence-recorded",
|
|
94
|
+
runId: manifest.runId,
|
|
95
|
+
manifestUrl: peEvidenceUrl(manifest.runId),
|
|
96
|
+
peEvidenceSchemaVersion: manifest.peEvidenceSchemaVersion,
|
|
97
|
+
recordIntegritySha256: manifest.integrityHashes.record,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
async function readPromptEnhancementRequest(ctx, signal) {
|
|
101
|
+
let raw;
|
|
102
|
+
try {
|
|
103
|
+
raw = await readBody(ctx.req);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (error instanceof BodyTooLargeError) {
|
|
107
|
+
return {
|
|
108
|
+
ok: false,
|
|
109
|
+
result: {
|
|
110
|
+
status: 413,
|
|
111
|
+
body: errorBody("PROMPT_ENHANCER_PAYLOAD_TOO_LARGE", "The request body is too large."),
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return { ok: false, result: invalidRequest(["request body could not be read"]) };
|
|
116
|
+
}
|
|
117
|
+
if (signal.aborted)
|
|
118
|
+
return { ok: false, result: cancelledResult() };
|
|
119
|
+
let parsed;
|
|
120
|
+
try {
|
|
121
|
+
parsed = JSON.parse(raw);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return { ok: false, result: invalidRequest(["request body is not valid JSON"]) };
|
|
125
|
+
}
|
|
126
|
+
if (!isPlainObject(parsed)) {
|
|
127
|
+
return { ok: false, result: invalidRequest(["request body must be a JSON object"]) };
|
|
128
|
+
}
|
|
129
|
+
const validated = validatePromptEnhancementWireRequest(parsed);
|
|
130
|
+
if (!validated.ok) {
|
|
131
|
+
return { ok: false, result: invalidRequest(validated.errors) };
|
|
132
|
+
}
|
|
133
|
+
return { ok: true, value: validated.value };
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* POST /api/prompt-enhancement — generate a governed, reviewable Enhanced Prompt from a raw draft.
|
|
137
|
+
* Validation, Model-Gateway routing (AC3), cancellation, and safe error shaping are all handled here.
|
|
138
|
+
*/
|
|
139
|
+
export const handlePromptEnhancement = async (ctx, deps) => {
|
|
140
|
+
const signal = requestAbortSignal(ctx);
|
|
141
|
+
const validated = await readPromptEnhancementRequest(ctx, signal);
|
|
142
|
+
if (!validated.ok)
|
|
143
|
+
return validated.result;
|
|
144
|
+
try {
|
|
145
|
+
const result = runPromptEnhancement(validated.value, {
|
|
146
|
+
gatewayRoutingConfig: promptEnhancementGatewayRoutingConfig(currentGatewayConfig(deps)),
|
|
147
|
+
signal,
|
|
148
|
+
});
|
|
149
|
+
const body = {
|
|
150
|
+
...result,
|
|
151
|
+
evidence: recordEvidenceReference(validated.value.text, result, deps),
|
|
152
|
+
};
|
|
153
|
+
// AC4 defence-in-depth: deep-redact every string leaf of the response through the live audit
|
|
154
|
+
// redactor before it leaves the server, so any secret-shaped substring a user pasted into their own
|
|
155
|
+
// draft is scrubbed from the echoed input / rendered prompt. Scores, ids, and enums are untouched.
|
|
156
|
+
return { status: 200, body: deps.redactor(body) };
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
if (error instanceof PromptEnhancementCancelledError) {
|
|
160
|
+
return cancelledResult();
|
|
161
|
+
}
|
|
162
|
+
if (error instanceof PromptEnhancementInputError) {
|
|
163
|
+
return invalidRequest(error.errors);
|
|
164
|
+
}
|
|
165
|
+
if (error instanceof EvidenceWriteError) {
|
|
166
|
+
return {
|
|
167
|
+
status: 500,
|
|
168
|
+
body: errorBody("PROMPT_ENHANCER_EVIDENCE_WRITE", "Prompt enhancement evidence could not be recorded."),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
// Unknown failure: a safe, content-free 500 (no raw input, stack, or provider detail).
|
|
172
|
+
return {
|
|
173
|
+
status: 500,
|
|
174
|
+
body: errorBody("PROMPT_ENHANCER_INTERNAL", "Prompt enhancement failed unexpectedly."),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
export const handlePromptEnhancementEvidence = (ctx, deps) => {
|
|
179
|
+
const runId = ctx.params.runId ?? "";
|
|
180
|
+
if (deps.evidenceDir === undefined) {
|
|
181
|
+
return {
|
|
182
|
+
status: 404,
|
|
183
|
+
body: errorBody("NOT_FOUND", "No prompt enhancement evidence store is configured."),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const manifest = loadPromptEnhancementRun(runId, { evidenceDir: deps.evidenceDir });
|
|
188
|
+
if (manifest === undefined) {
|
|
189
|
+
return {
|
|
190
|
+
status: 404,
|
|
191
|
+
body: errorBody("NOT_FOUND", "No prompt enhancement evidence for that run id."),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return { status: 200, body: { manifest } };
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (error instanceof InvalidRunIdError) {
|
|
198
|
+
return { status: 400, body: errorBody("BAD_REQUEST", "The run id is not valid.") };
|
|
199
|
+
}
|
|
200
|
+
if (error instanceof EvidenceReadError) {
|
|
201
|
+
return { status: 422, body: errorBody("PROMPT_ENHANCER_EVIDENCE_READ", error.message) };
|
|
202
|
+
}
|
|
203
|
+
throw error;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { UiHandlerDeps } from "../deps.js";
|
|
2
|
+
/** One indexed document's id + full normalized text, read through the LK QI handoff seam. */
|
|
3
|
+
export interface CapsuleDocumentText {
|
|
4
|
+
readonly documentId: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the full corpus text for a connected Local Knowledge connector. `capsule` reads a single
|
|
9
|
+
* capsule; `capsuleSet` fans out over a capsule-set's members. Both share one lazily-opened store
|
|
10
|
+
* handle and return `[]` on any failure (unknown id, store-open error) so the ingestion layer maps
|
|
11
|
+
* the empty result to a coded, user-actionable QI_CAPSULE_UNAVAILABLE error.
|
|
12
|
+
*
|
|
13
|
+
* `close` releases the underlying SQLite handle; must be called once per resolver lifetime (e.g. in
|
|
14
|
+
* the finally block of executeQiRun) to prevent a handle leak per QI run.
|
|
15
|
+
*/
|
|
16
|
+
export interface CapsuleResolver {
|
|
17
|
+
readonly capsule: (capsuleId: string) => readonly CapsuleDocumentText[];
|
|
18
|
+
readonly capsuleSet: (capsuleSetId: string) => readonly CapsuleDocumentText[];
|
|
19
|
+
readonly close: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Builds a CapsuleResolver that opens the LK store ONCE (per resolver) and returns the full corpus
|
|
23
|
+
* text for any capsule or capsule-set. Returns `undefined` when `deps.uiDbPath` is not set.
|
|
24
|
+
* Store-open errors produce a resolver whose methods always return `[]`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function makeCapsuleResolver(deps: UiHandlerDeps): CapsuleResolver | undefined;
|
|
27
|
+
//# sourceMappingURL=capsuleAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capsuleAdapter.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/capsuleAdapter.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,6FAA6F;AAC7F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,SAAS,mBAAmB,EAAE,CAAC;IACxE,QAAQ,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,SAAS,mBAAmB,EAAE,CAAC;IAC9E,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,aAAa,GAAG,eAAe,GAAG,SAAS,CA6CpF"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// capsuleAdapter.ts — capsule-corpus resolver seam for QI ingestion (Epic #710, Issue #717).
|
|
2
|
+
//
|
|
3
|
+
// Opens the Local Knowledge store lazily on the first call (once per resolver lifetime),
|
|
4
|
+
// then reads the full document corpus for any capsule OR capsule-set via the approved
|
|
5
|
+
// keiko-local-knowledge QI handoff seam. Store-open failures are handled by returning an empty
|
|
6
|
+
// array — the caller maps that to QI_CAPSULE_UNAVAILABLE. When uiDbPath is not set the resolver
|
|
7
|
+
// cannot be built (returns undefined); the ingestion layer then rejects capsule sources with
|
|
8
|
+
// QI_CAPSULE_UNAVAILABLE.
|
|
9
|
+
import { dirname } from "node:path";
|
|
10
|
+
import { openKnowledgeStore, resolveKnowledgeStorePath, QualityIntelligenceHandoff, } from "@oscharko-dev/keiko-local-knowledge";
|
|
11
|
+
import { localKnowledgeProtectionOptions } from "../localKnowledgeKeyProvider.js";
|
|
12
|
+
/**
|
|
13
|
+
* Builds a CapsuleResolver that opens the LK store ONCE (per resolver) and returns the full corpus
|
|
14
|
+
* text for any capsule or capsule-set. Returns `undefined` when `deps.uiDbPath` is not set.
|
|
15
|
+
* Store-open errors produce a resolver whose methods always return `[]`.
|
|
16
|
+
*/
|
|
17
|
+
export function makeCapsuleResolver(deps) {
|
|
18
|
+
const uiDbPath = deps.uiDbPath;
|
|
19
|
+
if (uiDbPath === undefined || uiDbPath.length === 0)
|
|
20
|
+
return undefined;
|
|
21
|
+
const dbPath = resolveKnowledgeStorePath({ runtimeStateDir: dirname(uiDbPath) });
|
|
22
|
+
const protection = localKnowledgeProtectionOptions(deps.localKnowledgeKeyProvider);
|
|
23
|
+
let store = null;
|
|
24
|
+
let openFailed = false;
|
|
25
|
+
const ensureStore = () => {
|
|
26
|
+
if (openFailed)
|
|
27
|
+
return null;
|
|
28
|
+
if (store !== null)
|
|
29
|
+
return store;
|
|
30
|
+
try {
|
|
31
|
+
store = openKnowledgeStore(protection === undefined ? { dbPath } : { dbPath, protection });
|
|
32
|
+
return store;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
openFailed = true;
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const read = (id, reader) => {
|
|
40
|
+
const s = ensureStore();
|
|
41
|
+
if (s === null)
|
|
42
|
+
return [];
|
|
43
|
+
try {
|
|
44
|
+
return reader(s, id);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
return {
|
|
51
|
+
capsule: (capsuleId) => read(capsuleId, QualityIntelligenceHandoff.listCapsuleDocumentTexts),
|
|
52
|
+
capsuleSet: (capsuleSetId) => read(capsuleSetId, QualityIntelligenceHandoff.listCapsuleSetDocumentTexts),
|
|
53
|
+
close: () => {
|
|
54
|
+
store?.close();
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface QiConnectorConfig {
|
|
2
|
+
readonly figma_connector_authorized?: unknown;
|
|
3
|
+
readonly jira_connector_authorized?: unknown;
|
|
4
|
+
}
|
|
5
|
+
export interface QiConnectorCapabilities {
|
|
6
|
+
readonly figma: boolean;
|
|
7
|
+
readonly jira: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* True only when `config.figma_connector_authorized === true`. Pure.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isFigmaConnectorAuthorized: (config: QiConnectorConfig | undefined) => boolean;
|
|
13
|
+
/**
|
|
14
|
+
* True only when `config.jira_connector_authorized === true`. Pure.
|
|
15
|
+
*/
|
|
16
|
+
export declare const isJiraConnectorAuthorized: (config: QiConnectorConfig | undefined) => boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Capabilities summary suitable for the `/api/quality-intelligence/sources/capabilities`
|
|
19
|
+
* route. Carries booleans only — NEVER credentials, endpoint URLs, or raw config values.
|
|
20
|
+
*/
|
|
21
|
+
export declare const summariseQiConnectorCapabilities: (config: QiConnectorConfig | undefined) => QiConnectorCapabilities;
|
|
22
|
+
//# sourceMappingURL=connectorAuthorization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorAuthorization.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/connectorAuthorization.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAC9C,QAAQ,CAAC,yBAAyB,CAAC,EAAE,OAAO,CAAC;CAC9C;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB;AAID;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,QAAQ,iBAAiB,GAAG,SAAS,KAAG,OAGlF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,GAAI,QAAQ,iBAAiB,GAAG,SAAS,KAAG,OAGjF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gCAAgC,GAC3C,QAAQ,iBAAiB,GAAG,SAAS,KACpC,uBAGD,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Quality Intelligence connector authorisation (Epic #270, Issue #278).
|
|
2
|
+
//
|
|
3
|
+
// Typed authorisation predicates for the QI dry-run connector routes. Every
|
|
4
|
+
// authorisation DEFAULTS TO FALSE; only flips on an explicit boolean `true` config flag.
|
|
5
|
+
// No reflection, no string coercion — the boolean must be a real `true`.
|
|
6
|
+
//
|
|
7
|
+
// The config object passed to these predicates is intentionally a structural Record
|
|
8
|
+
// that the BFF resolver hydrates from the gateway-config storage layer (issue #279 will
|
|
9
|
+
// formalise this; today it is read off `env` until the gateway exposes it). The
|
|
10
|
+
// predicates themselves are pure — they do no IO and cannot construct credentials.
|
|
11
|
+
const isExplicitTrue = (value) => value === true;
|
|
12
|
+
/**
|
|
13
|
+
* True only when `config.figma_connector_authorized === true`. Pure.
|
|
14
|
+
*/
|
|
15
|
+
export const isFigmaConnectorAuthorized = (config) => {
|
|
16
|
+
if (config === undefined)
|
|
17
|
+
return false;
|
|
18
|
+
return isExplicitTrue(config.figma_connector_authorized);
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* True only when `config.jira_connector_authorized === true`. Pure.
|
|
22
|
+
*/
|
|
23
|
+
export const isJiraConnectorAuthorized = (config) => {
|
|
24
|
+
if (config === undefined)
|
|
25
|
+
return false;
|
|
26
|
+
return isExplicitTrue(config.jira_connector_authorized);
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Capabilities summary suitable for the `/api/quality-intelligence/sources/capabilities`
|
|
30
|
+
* route. Carries booleans only — NEVER credentials, endpoint URLs, or raw config values.
|
|
31
|
+
*/
|
|
32
|
+
export const summariseQiConnectorCapabilities = (config) => ({
|
|
33
|
+
figma: isFigmaConnectorAuthorized(config),
|
|
34
|
+
jira: isJiraConnectorAuthorized(config),
|
|
35
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type QiConnectorErrorCode = "QI_BAD_REQUEST" | "QI_CONNECTOR_DISABLED" | "QI_FORBIDDEN_PAYLOAD" | "QI_INVALID_ENVELOPE_SELECTION" | "QI_INTERNAL";
|
|
2
|
+
export interface QiConnectorErrorBody {
|
|
3
|
+
readonly error: {
|
|
4
|
+
readonly code: QiConnectorErrorCode;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare const qiConnectorErrorBody: (code: QiConnectorErrorCode) => QiConnectorErrorBody;
|
|
9
|
+
export declare const containsForbiddenSecretShape: (value: string) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Scan a plain-object payload's string values (one level deep) for credential-shaped
|
|
12
|
+
* substrings. Returns true if any value matches. Used by the dry-run routes BEFORE the
|
|
13
|
+
* payload is even processed so a leaky client gets a 400 with a generic message.
|
|
14
|
+
*/
|
|
15
|
+
export declare const payloadContainsForbiddenSecretShape: (payload: Readonly<Record<string, unknown>>) => boolean;
|
|
16
|
+
//# sourceMappingURL=connectorErrors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorErrors.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/connectorErrors.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,oBAAoB,GAC5B,gBAAgB,GAChB,uBAAuB,GACvB,sBAAsB,GACtB,+BAA+B,GAC/B,aAAa,CAAC;AAElB,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACnF;AAYD,eAAO,MAAM,oBAAoB,GAAI,MAAM,oBAAoB,KAAG,oBAEhE,CAAC;AAqBH,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,KAAG,OAM5D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mCAAmC,GAC9C,SAAS,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACzC,OAKF,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Quality Intelligence connector error shapes (Epic #270, Issue #278).
|
|
2
|
+
//
|
|
3
|
+
// Safe error JSON for the QI connector routes. Bodies NEVER carry credentials, raw
|
|
4
|
+
// payloads, endpoint URLs, header values, or anything that could be mistaken for a
|
|
5
|
+
// secret. Every error message is a fixed string keyed by a stable code.
|
|
6
|
+
//
|
|
7
|
+
// The shape matches the existing BFF `ApiError` envelope (`{ error: { code, message } }`)
|
|
8
|
+
// so the gateway/router serialises it consistently with the other route groups.
|
|
9
|
+
const SAFE_MESSAGES = {
|
|
10
|
+
QI_BAD_REQUEST: "The request body is not a valid Quality Intelligence connector payload.",
|
|
11
|
+
QI_CONNECTOR_DISABLED: "The requested connector is disabled. Enable it explicitly in the gateway configuration to send a dry-run.",
|
|
12
|
+
QI_FORBIDDEN_PAYLOAD: "The request body contained a forbidden field. Connector payloads may not carry credentials, headers, or URLs.",
|
|
13
|
+
QI_INVALID_ENVELOPE_SELECTION: "One or more selected envelope ids are not well-formed.",
|
|
14
|
+
QI_INTERNAL: "The Quality Intelligence connector route could not service the request.",
|
|
15
|
+
};
|
|
16
|
+
export const qiConnectorErrorBody = (code) => ({
|
|
17
|
+
error: { code, message: SAFE_MESSAGES[code] },
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Defence-in-depth scrub: detect substrings that would indicate the caller is trying to
|
|
21
|
+
* smuggle credentials or a header pair through a connector payload. Pure, no IO.
|
|
22
|
+
*
|
|
23
|
+
* Comparison is case-insensitive so that variants like "BEARER ", "API_KEY", or
|
|
24
|
+
* "AUTHORIZATION:" are detected regardless of casing (prior case-variant list was
|
|
25
|
+
* incomplete and bypassed by non-listed casings — Issue #281).
|
|
26
|
+
*/
|
|
27
|
+
const FORBIDDEN_SUBSTRINGS = [
|
|
28
|
+
"authorization:",
|
|
29
|
+
"bearer ",
|
|
30
|
+
"basic ",
|
|
31
|
+
"apikey",
|
|
32
|
+
"api_key",
|
|
33
|
+
"cookie:",
|
|
34
|
+
"set-cookie",
|
|
35
|
+
"x-api-key",
|
|
36
|
+
];
|
|
37
|
+
export const containsForbiddenSecretShape = (value) => {
|
|
38
|
+
const lower = value.toLowerCase();
|
|
39
|
+
for (const forbidden of FORBIDDEN_SUBSTRINGS) {
|
|
40
|
+
if (lower.includes(forbidden))
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Scan a plain-object payload's string values (one level deep) for credential-shaped
|
|
47
|
+
* substrings. Returns true if any value matches. Used by the dry-run routes BEFORE the
|
|
48
|
+
* payload is even processed so a leaky client gets a 400 with a generic message.
|
|
49
|
+
*/
|
|
50
|
+
export const payloadContainsForbiddenSecretShape = (payload) => {
|
|
51
|
+
for (const value of Object.values(payload)) {
|
|
52
|
+
if (typeof value === "string" && containsForbiddenSecretShape(value))
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { RouteContext, RouteResult } from "../routes.js";
|
|
2
|
+
import type { UiHandlerDeps } from "../deps.js";
|
|
3
|
+
export declare const handleQiSourceSelect: (ctx: RouteContext, _deps: UiHandlerDeps) => Promise<RouteResult>;
|
|
4
|
+
export declare const handleQiDryRunFigma: (ctx: RouteContext, deps: UiHandlerDeps) => Promise<RouteResult>;
|
|
5
|
+
export declare const handleQiDryRunJira: (ctx: RouteContext, deps: UiHandlerDeps) => Promise<RouteResult>;
|
|
6
|
+
export declare const handleQiCapabilities: (_ctx: RouteContext, deps: UiHandlerDeps) => RouteResult;
|
|
7
|
+
//# sourceMappingURL=connectorRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connectorRoutes.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/connectorRoutes.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAmIhD,eAAO,MAAM,oBAAoB,GAC/B,KAAK,YAAY,EACjB,OAAO,aAAa,KACnB,OAAO,CAAC,WAAW,CAcrB,CAAC;AAoBF,eAAO,MAAM,mBAAmB,GAC9B,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,OAAO,CAAC,WAAW,CAOrB,CAAC;AAEF,eAAO,MAAM,kBAAkB,GAC7B,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,OAAO,CAAC,WAAW,CAOrB,CAAC;AAIF,eAAO,MAAM,oBAAoB,GAAI,MAAM,YAAY,EAAE,MAAM,aAAa,KAAG,WAI9E,CAAC"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// Quality Intelligence connector BFF routes (Epic #270, Issue #278).
|
|
2
|
+
//
|
|
3
|
+
// Four additive HTTP handlers under `/api/quality-intelligence/sources/*`:
|
|
4
|
+
// * POST /api/quality-intelligence/sources/select — plan a user-selected envelope set
|
|
5
|
+
// * POST /api/quality-intelligence/sources/dryrun-figma — DRY-RUN only; disabled by default
|
|
6
|
+
// * POST /api/quality-intelligence/sources/dryrun-jira — DRY-RUN only; disabled by default
|
|
7
|
+
// * GET /api/quality-intelligence/sources/capabilities — boolean capability summary
|
|
8
|
+
//
|
|
9
|
+
// Hard constraints:
|
|
10
|
+
// * No provider SDK imports (no figma-api, no jira.js, no @atlassian/*).
|
|
11
|
+
// * No outbound network request from any handler in this file.
|
|
12
|
+
// * Authorisation defaults to FALSE — only flips on explicit `*_connector_authorized: true`.
|
|
13
|
+
// * Error JSON never carries credentials, payloads, URLs, or header pairs.
|
|
14
|
+
// * Composes existing route plumbing (RouteContext / UiHandlerDeps); does not modify
|
|
15
|
+
// any sibling handler.
|
|
16
|
+
import { QualityIntelligence } from "@oscharko-dev/keiko-contracts";
|
|
17
|
+
import { QualityIntelligenceIngestion } from "@oscharko-dev/keiko-quality-intelligence";
|
|
18
|
+
import { isFigmaConnectorAuthorized, isJiraConnectorAuthorized, summariseQiConnectorCapabilities, } from "./connectorAuthorization.js";
|
|
19
|
+
import { payloadContainsForbiddenSecretShape, qiConnectorErrorBody } from "./connectorErrors.js";
|
|
20
|
+
const MAX_BODY_BYTES = 256 * 1024;
|
|
21
|
+
class BodyTooLargeError extends Error {
|
|
22
|
+
constructor() {
|
|
23
|
+
super("Request body exceeds connector route cap");
|
|
24
|
+
this.name = "BodyTooLargeError";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const readBody = (req) => {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
const chunks = [];
|
|
30
|
+
let total = 0;
|
|
31
|
+
let capped = false;
|
|
32
|
+
req.on("data", (chunk) => {
|
|
33
|
+
total += chunk.length;
|
|
34
|
+
if (total > MAX_BODY_BYTES) {
|
|
35
|
+
if (!capped) {
|
|
36
|
+
capped = true;
|
|
37
|
+
chunks.length = 0;
|
|
38
|
+
reject(new BodyTooLargeError());
|
|
39
|
+
req.resume();
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
chunks.push(chunk);
|
|
44
|
+
});
|
|
45
|
+
req.on("end", () => {
|
|
46
|
+
if (!capped)
|
|
47
|
+
resolve(Buffer.concat(chunks).toString("utf8"));
|
|
48
|
+
});
|
|
49
|
+
req.on("error", reject);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
|
+
const parseConnectorBody = async (req) => {
|
|
54
|
+
let raw;
|
|
55
|
+
try {
|
|
56
|
+
raw = await readBody(req);
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
if (e instanceof BodyTooLargeError) {
|
|
60
|
+
return { ok: false, result: { status: 413, body: qiConnectorErrorBody("QI_BAD_REQUEST") } };
|
|
61
|
+
}
|
|
62
|
+
return { ok: false, result: { status: 400, body: qiConnectorErrorBody("QI_BAD_REQUEST") } };
|
|
63
|
+
}
|
|
64
|
+
let parsed;
|
|
65
|
+
try {
|
|
66
|
+
parsed = JSON.parse(raw);
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return { ok: false, result: { status: 400, body: qiConnectorErrorBody("QI_BAD_REQUEST") } };
|
|
70
|
+
}
|
|
71
|
+
if (!isPlainObject(parsed)) {
|
|
72
|
+
return { ok: false, result: { status: 400, body: qiConnectorErrorBody("QI_BAD_REQUEST") } };
|
|
73
|
+
}
|
|
74
|
+
if (payloadContainsForbiddenSecretShape(parsed)) {
|
|
75
|
+
return {
|
|
76
|
+
ok: false,
|
|
77
|
+
result: { status: 400, body: qiConnectorErrorBody("QI_FORBIDDEN_PAYLOAD") },
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return { ok: true, body: parsed };
|
|
81
|
+
};
|
|
82
|
+
const resolveConnectorConfig = (deps) => {
|
|
83
|
+
const env = deps.env;
|
|
84
|
+
return {
|
|
85
|
+
figma_connector_authorized: env.FIGMA_CONNECTOR_AUTHORIZED === "true",
|
|
86
|
+
jira_connector_authorized: env.JIRA_CONNECTOR_AUTHORIZED === "true",
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
// ─── /sources/select ───────────────────────────────────────────────────────────
|
|
90
|
+
const collectIds = (raw) => {
|
|
91
|
+
if (!Array.isArray(raw))
|
|
92
|
+
return null;
|
|
93
|
+
const ids = [];
|
|
94
|
+
for (const candidate of raw) {
|
|
95
|
+
if (typeof candidate !== "string")
|
|
96
|
+
return null;
|
|
97
|
+
try {
|
|
98
|
+
ids.push(QualityIntelligence.asQualityIntelligenceSourceEnvelopeId(candidate));
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return ids;
|
|
105
|
+
};
|
|
106
|
+
const buildSelectionEnvelopes = (ids, registeredAt) => {
|
|
107
|
+
// Selection routes accept opaque envelope IDS — no display label or hash is supplied
|
|
108
|
+
// by the browser tier. The planner only needs id+kind+priority, so we synthesise a
|
|
109
|
+
// minimal repository-context envelope (the default kind for selection) and let the
|
|
110
|
+
// QI domain decide what to do downstream when the real envelope catalogue is wired
|
|
111
|
+
// in #274. Hash is the zero-digest so the planner's "kind+id" stable key still works.
|
|
112
|
+
return ids.map((id) => ({
|
|
113
|
+
id,
|
|
114
|
+
kind: "repository-context",
|
|
115
|
+
displayLabel: `selected:${id}`,
|
|
116
|
+
provenance: {
|
|
117
|
+
origin: "user-selection",
|
|
118
|
+
registeredAt,
|
|
119
|
+
integrityHashSha256Hex: "0".repeat(64),
|
|
120
|
+
},
|
|
121
|
+
localRef: id,
|
|
122
|
+
}));
|
|
123
|
+
};
|
|
124
|
+
export const handleQiSourceSelect = async (ctx, _deps) => {
|
|
125
|
+
const parsed = await parseConnectorBody(ctx.req);
|
|
126
|
+
if (!parsed.ok)
|
|
127
|
+
return parsed.result;
|
|
128
|
+
const ids = collectIds(parsed.body.envelopeIds);
|
|
129
|
+
if (ids === null) {
|
|
130
|
+
return { status: 400, body: qiConnectorErrorBody("QI_INVALID_ENVELOPE_SELECTION") };
|
|
131
|
+
}
|
|
132
|
+
const registeredAt = typeof parsed.body.registeredAt === "string"
|
|
133
|
+
? parsed.body.registeredAt
|
|
134
|
+
: "1970-01-01T00:00:00Z";
|
|
135
|
+
const envelopes = buildSelectionEnvelopes(ids, registeredAt);
|
|
136
|
+
const plan = QualityIntelligenceIngestion.planSourceMix(envelopes);
|
|
137
|
+
return { status: 200, body: { plan } };
|
|
138
|
+
};
|
|
139
|
+
const buildDryRunOutcome = (connector, body, authorized) => ({
|
|
140
|
+
status: authorized ? "DRYRUN_OK" : "DISABLED",
|
|
141
|
+
connector,
|
|
142
|
+
wouldUseFieldCount: Object.keys(body).length,
|
|
143
|
+
});
|
|
144
|
+
export const handleQiDryRunFigma = async (ctx, deps) => {
|
|
145
|
+
const parsed = await parseConnectorBody(ctx.req);
|
|
146
|
+
if (!parsed.ok)
|
|
147
|
+
return parsed.result;
|
|
148
|
+
const config = resolveConnectorConfig(deps);
|
|
149
|
+
const authorized = isFigmaConnectorAuthorized(config);
|
|
150
|
+
const outcome = buildDryRunOutcome("figma", parsed.body, authorized);
|
|
151
|
+
return { status: 200, body: outcome };
|
|
152
|
+
};
|
|
153
|
+
export const handleQiDryRunJira = async (ctx, deps) => {
|
|
154
|
+
const parsed = await parseConnectorBody(ctx.req);
|
|
155
|
+
if (!parsed.ok)
|
|
156
|
+
return parsed.result;
|
|
157
|
+
const config = resolveConnectorConfig(deps);
|
|
158
|
+
const authorized = isJiraConnectorAuthorized(config);
|
|
159
|
+
const outcome = buildDryRunOutcome("jira", parsed.body, authorized);
|
|
160
|
+
return { status: 200, body: outcome };
|
|
161
|
+
};
|
|
162
|
+
// ─── /sources/capabilities ─────────────────────────────────────────────────────
|
|
163
|
+
export const handleQiCapabilities = (_ctx, deps) => {
|
|
164
|
+
const config = resolveConnectorConfig(deps);
|
|
165
|
+
const capabilities = summariseQiConnectorCapabilities(config);
|
|
166
|
+
return { status: 200, body: { capabilities } };
|
|
167
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RouteContext, RouteResult, RouteDefinition } from "../routes.js";
|
|
2
|
+
import type { UiHandlerDeps } from "../deps.js";
|
|
3
|
+
export declare function handleQiEditCandidate(ctx: RouteContext, deps: UiHandlerDeps): Promise<RouteResult>;
|
|
4
|
+
export declare const QI_EDIT_ROUTE_GROUP: readonly RouteDefinition[];
|
|
5
|
+
//# sourceMappingURL=editRoutes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editRoutes.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/editRoutes.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAwThD,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED,eAAO,MAAM,mBAAmB,EAAE,SAAS,eAAe,EAMzD,CAAC"}
|