@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.
Files changed (509) hide show
  1. package/dist/.tsbuildinfo +1 -0
  2. package/dist/assistant-response.d.ts +6 -0
  3. package/dist/assistant-response.d.ts.map +1 -0
  4. package/dist/assistant-response.js +12 -0
  5. package/dist/browser.d.ts +11 -0
  6. package/dist/browser.d.ts.map +1 -0
  7. package/dist/browser.js +245 -0
  8. package/dist/chat-handlers.d.ts +48 -0
  9. package/dist/chat-handlers.d.ts.map +1 -0
  10. package/dist/chat-handlers.js +821 -0
  11. package/dist/chat-stream-handlers.d.ts +4 -0
  12. package/dist/chat-stream-handlers.d.ts.map +1 -0
  13. package/dist/chat-stream-handlers.js +136 -0
  14. package/dist/conversation-prompt.d.ts +8 -0
  15. package/dist/conversation-prompt.d.ts.map +1 -0
  16. package/dist/conversation-prompt.js +36 -0
  17. package/dist/conversation-validation.d.ts +26 -0
  18. package/dist/conversation-validation.d.ts.map +1 -0
  19. package/dist/conversation-validation.js +125 -0
  20. package/dist/credentialPersistence.d.ts +23 -0
  21. package/dist/credentialPersistence.d.ts.map +1 -0
  22. package/dist/credentialPersistence.js +93 -0
  23. package/dist/credentialVault.d.ts +30 -0
  24. package/dist/credentialVault.d.ts.map +1 -0
  25. package/dist/credentialVault.js +206 -0
  26. package/dist/csp.d.ts +3 -0
  27. package/dist/csp.d.ts.map +1 -0
  28. package/dist/csp.js +75 -0
  29. package/dist/deps.d.ts +78 -0
  30. package/dist/deps.d.ts.map +1 -0
  31. package/dist/deps.js +457 -0
  32. package/dist/editor/agentRoutes.d.ts +7 -0
  33. package/dist/editor/agentRoutes.d.ts.map +1 -0
  34. package/dist/editor/agentRoutes.js +197 -0
  35. package/dist/editor/assuredGateRunner.d.ts +36 -0
  36. package/dist/editor/assuredGateRunner.d.ts.map +1 -0
  37. package/dist/editor/assuredGateRunner.js +100 -0
  38. package/dist/editor/assuredPreFilter.d.ts +34 -0
  39. package/dist/editor/assuredPreFilter.d.ts.map +1 -0
  40. package/dist/editor/assuredPreFilter.js +134 -0
  41. package/dist/editor/assuredPreFilterRunner.d.ts +31 -0
  42. package/dist/editor/assuredPreFilterRunner.d.ts.map +1 -0
  43. package/dist/editor/assuredPreFilterRunner.js +312 -0
  44. package/dist/editor/builtinLanguageProviders.d.ts +6 -0
  45. package/dist/editor/builtinLanguageProviders.d.ts.map +1 -0
  46. package/dist/editor/builtinLanguageProviders.js +221 -0
  47. package/dist/editor/codingContext.d.ts +12 -0
  48. package/dist/editor/codingContext.d.ts.map +1 -0
  49. package/dist/editor/codingContext.js +121 -0
  50. package/dist/editor/codingContextEvidence.d.ts +7 -0
  51. package/dist/editor/codingContextEvidence.d.ts.map +1 -0
  52. package/dist/editor/codingContextEvidence.js +52 -0
  53. package/dist/editor/codingContextProviders.d.ts +36 -0
  54. package/dist/editor/codingContextProviders.d.ts.map +1 -0
  55. package/dist/editor/codingContextProviders.js +348 -0
  56. package/dist/editor/completionModelEvidence.d.ts +16 -0
  57. package/dist/editor/completionModelEvidence.d.ts.map +1 -0
  58. package/dist/editor/completionModelEvidence.js +50 -0
  59. package/dist/editor/completionRoutes.d.ts +37 -0
  60. package/dist/editor/completionRoutes.d.ts.map +1 -0
  61. package/dist/editor/completionRoutes.js +411 -0
  62. package/dist/editor/contextRoutes.d.ts +6 -0
  63. package/dist/editor/contextRoutes.d.ts.map +1 -0
  64. package/dist/editor/contextRoutes.js +411 -0
  65. package/dist/editor/disposableAssuredExecution.d.ts +22 -0
  66. package/dist/editor/disposableAssuredExecution.d.ts.map +1 -0
  67. package/dist/editor/disposableAssuredExecution.js +57 -0
  68. package/dist/editor/editorCompletionModel.d.ts +47 -0
  69. package/dist/editor/editorCompletionModel.d.ts.map +1 -0
  70. package/dist/editor/editorCompletionModel.js +156 -0
  71. package/dist/editor/editorInlineCompletionModel.d.ts +34 -0
  72. package/dist/editor/editorInlineCompletionModel.d.ts.map +1 -0
  73. package/dist/editor/editorInlineCompletionModel.js +112 -0
  74. package/dist/editor/editorModelTokenBudget.d.ts +46 -0
  75. package/dist/editor/editorModelTokenBudget.d.ts.map +1 -0
  76. package/dist/editor/editorModelTokenBudget.js +121 -0
  77. package/dist/editor/inlineCompletionRateLimiter.d.ts +19 -0
  78. package/dist/editor/inlineCompletionRateLimiter.d.ts.map +1 -0
  79. package/dist/editor/inlineCompletionRateLimiter.js +46 -0
  80. package/dist/editor/inlineCompletionRoutes.d.ts +26 -0
  81. package/dist/editor/inlineCompletionRoutes.d.ts.map +1 -0
  82. package/dist/editor/inlineCompletionRoutes.js +404 -0
  83. package/dist/editor/inlineCompletionTelemetryEvidence.d.ts +5 -0
  84. package/dist/editor/inlineCompletionTelemetryEvidence.d.ts.map +1 -0
  85. package/dist/editor/inlineCompletionTelemetryEvidence.js +42 -0
  86. package/dist/editor/languageCancellation.d.ts +19 -0
  87. package/dist/editor/languageCancellation.d.ts.map +1 -0
  88. package/dist/editor/languageCancellation.js +48 -0
  89. package/dist/editor/languageProvider.d.ts +39 -0
  90. package/dist/editor/languageProvider.d.ts.map +1 -0
  91. package/dist/editor/languageProvider.js +11 -0
  92. package/dist/editor/languageRoutes.d.ts +15 -0
  93. package/dist/editor/languageRoutes.d.ts.map +1 -0
  94. package/dist/editor/languageRoutes.js +106 -0
  95. package/dist/editor/languageSanitize.d.ts +8 -0
  96. package/dist/editor/languageSanitize.d.ts.map +1 -0
  97. package/dist/editor/languageSanitize.js +101 -0
  98. package/dist/editor/languageService.d.ts +36 -0
  99. package/dist/editor/languageService.d.ts.map +1 -0
  100. package/dist/editor/languageService.js +93 -0
  101. package/dist/editor/languageServiceHost.d.ts +14 -0
  102. package/dist/editor/languageServiceHost.d.ts.map +1 -0
  103. package/dist/editor/languageServiceHost.js +242 -0
  104. package/dist/editor/localKnowledgeRetrieval.d.ts +21 -0
  105. package/dist/editor/localKnowledgeRetrieval.d.ts.map +1 -0
  106. package/dist/editor/localKnowledgeRetrieval.js +44 -0
  107. package/dist/editor/patchApplyEvidence.d.ts +21 -0
  108. package/dist/editor/patchApplyEvidence.d.ts.map +1 -0
  109. package/dist/editor/patchApplyEvidence.js +87 -0
  110. package/dist/editor/patchApplyRoutes.d.ts +16 -0
  111. package/dist/editor/patchApplyRoutes.d.ts.map +1 -0
  112. package/dist/editor/patchApplyRoutes.js +307 -0
  113. package/dist/editor/postApplyVerification.d.ts +42 -0
  114. package/dist/editor/postApplyVerification.d.ts.map +1 -0
  115. package/dist/editor/postApplyVerification.js +177 -0
  116. package/dist/editor/testGenerationEvidence.d.ts +6 -0
  117. package/dist/editor/testGenerationEvidence.d.ts.map +1 -0
  118. package/dist/editor/testGenerationEvidence.js +72 -0
  119. package/dist/editor/testGenerationPatch.d.ts +10 -0
  120. package/dist/editor/testGenerationPatch.d.ts.map +1 -0
  121. package/dist/editor/testGenerationPatch.js +66 -0
  122. package/dist/editor/testGenerationRoutes.d.ts +21 -0
  123. package/dist/editor/testGenerationRoutes.d.ts.map +1 -0
  124. package/dist/editor/testGenerationRoutes.js +254 -0
  125. package/dist/editor/testGenerationRunner.d.ts +23 -0
  126. package/dist/editor/testGenerationRunner.d.ts.map +1 -0
  127. package/dist/editor/testGenerationRunner.js +120 -0
  128. package/dist/editor/textOffsets.d.ts +6 -0
  129. package/dist/editor/textOffsets.d.ts.map +1 -0
  130. package/dist/editor/textOffsets.js +82 -0
  131. package/dist/editor/typescriptLanguageProvider.d.ts +3 -0
  132. package/dist/editor/typescriptLanguageProvider.d.ts.map +1 -0
  133. package/dist/editor/typescriptLanguageProvider.js +217 -0
  134. package/dist/evidence.d.ts +28 -0
  135. package/dist/evidence.d.ts.map +1 -0
  136. package/dist/evidence.js +145 -0
  137. package/dist/files-deny.d.ts +3 -0
  138. package/dist/files-deny.d.ts.map +1 -0
  139. package/dist/files-deny.js +12 -0
  140. package/dist/files.d.ts +97 -0
  141. package/dist/files.d.ts.map +1 -0
  142. package/dist/files.js +733 -0
  143. package/dist/gateway-setup.d.ts +10 -0
  144. package/dist/gateway-setup.d.ts.map +1 -0
  145. package/dist/gateway-setup.js +896 -0
  146. package/dist/governed-workflow.d.ts +17 -0
  147. package/dist/governed-workflow.d.ts.map +1 -0
  148. package/dist/governed-workflow.js +147 -0
  149. package/dist/grounded-answer.d.ts +12 -0
  150. package/dist/grounded-answer.d.ts.map +1 -0
  151. package/dist/grounded-answer.js +69 -0
  152. package/dist/grounded-context-index.d.ts +25 -0
  153. package/dist/grounded-context-index.d.ts.map +1 -0
  154. package/dist/grounded-context-index.js +169 -0
  155. package/dist/grounded-document-evidence.d.ts +28 -0
  156. package/dist/grounded-document-evidence.d.ts.map +1 -0
  157. package/dist/grounded-document-evidence.js +430 -0
  158. package/dist/grounded-handoff.d.ts +4 -0
  159. package/dist/grounded-handoff.d.ts.map +1 -0
  160. package/dist/grounded-handoff.js +445 -0
  161. package/dist/grounded-orchestrator.d.ts +43 -0
  162. package/dist/grounded-orchestrator.d.ts.map +1 -0
  163. package/dist/grounded-orchestrator.js +1445 -0
  164. package/dist/grounded-prompt.d.ts +2 -0
  165. package/dist/grounded-prompt.d.ts.map +1 -0
  166. package/dist/grounded-prompt.js +17 -0
  167. package/dist/grounded-qa-hybrid.d.ts +36 -0
  168. package/dist/grounded-qa-hybrid.d.ts.map +1 -0
  169. package/dist/grounded-qa-hybrid.js +762 -0
  170. package/dist/grounded-qa-multi-source.d.ts +38 -0
  171. package/dist/grounded-qa-multi-source.d.ts.map +1 -0
  172. package/dist/grounded-qa-multi-source.js +461 -0
  173. package/dist/grounded-qa.d.ts +45 -0
  174. package/dist/grounded-qa.d.ts.map +1 -0
  175. package/dist/grounded-qa.js +877 -0
  176. package/dist/grounded-rerank.d.ts +26 -0
  177. package/dist/grounded-rerank.d.ts.map +1 -0
  178. package/dist/grounded-rerank.js +72 -0
  179. package/dist/grounded-turn-registry.d.ts +23 -0
  180. package/dist/grounded-turn-registry.d.ts.map +1 -0
  181. package/dist/grounded-turn-registry.js +102 -0
  182. package/dist/headers.d.ts +3 -0
  183. package/dist/headers.d.ts.map +1 -0
  184. package/dist/headers.js +22 -0
  185. package/dist/host-check.d.ts +3 -0
  186. package/dist/host-check.d.ts.map +1 -0
  187. package/dist/host-check.js +58 -0
  188. package/dist/index.d.ts +26 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +33 -0
  191. package/dist/load-csp.d.ts +3 -0
  192. package/dist/load-csp.d.ts.map +1 -0
  193. package/dist/load-csp.js +100 -0
  194. package/dist/local-knowledge-grounded-qa.d.ts +42 -0
  195. package/dist/local-knowledge-grounded-qa.d.ts.map +1 -0
  196. package/dist/local-knowledge-grounded-qa.js +678 -0
  197. package/dist/local-knowledge-handlers.d.ts +24 -0
  198. package/dist/local-knowledge-handlers.d.ts.map +1 -0
  199. package/dist/local-knowledge-handlers.js +1285 -0
  200. package/dist/local-knowledge-indexing-registry.d.ts +13 -0
  201. package/dist/local-knowledge-indexing-registry.d.ts.map +1 -0
  202. package/dist/local-knowledge-indexing-registry.js +53 -0
  203. package/dist/localKnowledgeKeyProvider.d.ts +11 -0
  204. package/dist/localKnowledgeKeyProvider.d.ts.map +1 -0
  205. package/dist/localKnowledgeKeyProvider.js +48 -0
  206. package/dist/memory-audit-event-builders.d.ts +21 -0
  207. package/dist/memory-audit-event-builders.d.ts.map +1 -0
  208. package/dist/memory-audit-event-builders.js +187 -0
  209. package/dist/memory-audit-handler.d.ts +23 -0
  210. package/dist/memory-audit-handler.d.ts.map +1 -0
  211. package/dist/memory-audit-handler.js +191 -0
  212. package/dist/memory-capture-policy.d.ts +10 -0
  213. package/dist/memory-capture-policy.d.ts.map +1 -0
  214. package/dist/memory-capture-policy.js +44 -0
  215. package/dist/memory-consolidation-handlers.d.ts +6 -0
  216. package/dist/memory-consolidation-handlers.d.ts.map +1 -0
  217. package/dist/memory-consolidation-handlers.js +491 -0
  218. package/dist/memory-consolidation-registry.d.ts +47 -0
  219. package/dist/memory-consolidation-registry.d.ts.map +1 -0
  220. package/dist/memory-consolidation-registry.js +106 -0
  221. package/dist/memory-conv-handlers.d.ts +8 -0
  222. package/dist/memory-conv-handlers.d.ts.map +1 -0
  223. package/dist/memory-conv-handlers.js +369 -0
  224. package/dist/memory-conversation-context.d.ts +13 -0
  225. package/dist/memory-conversation-context.d.ts.map +1 -0
  226. package/dist/memory-conversation-context.js +22 -0
  227. package/dist/memory-diagnostics.d.ts +29 -0
  228. package/dist/memory-diagnostics.d.ts.map +1 -0
  229. package/dist/memory-diagnostics.js +122 -0
  230. package/dist/memory-embedding.d.ts +21 -0
  231. package/dist/memory-embedding.d.ts.map +1 -0
  232. package/dist/memory-embedding.js +264 -0
  233. package/dist/memory-handlers.d.ts +19 -0
  234. package/dist/memory-handlers.d.ts.map +1 -0
  235. package/dist/memory-handlers.js +1204 -0
  236. package/dist/memory-maintenance-handlers.d.ts +35 -0
  237. package/dist/memory-maintenance-handlers.d.ts.map +1 -0
  238. package/dist/memory-maintenance-handlers.js +219 -0
  239. package/dist/memory-record-builders.d.ts +4 -0
  240. package/dist/memory-record-builders.d.ts.map +1 -0
  241. package/dist/memory-record-builders.js +19 -0
  242. package/dist/memory-retention.d.ts +31 -0
  243. package/dist/memory-retention.d.ts.map +1 -0
  244. package/dist/memory-retention.js +151 -0
  245. package/dist/memory-retrieval-signals.d.ts +12 -0
  246. package/dist/memory-retrieval-signals.d.ts.map +1 -0
  247. package/dist/memory-retrieval-signals.js +100 -0
  248. package/dist/memory-salience.d.ts +12 -0
  249. package/dist/memory-salience.d.ts.map +1 -0
  250. package/dist/memory-salience.js +154 -0
  251. package/dist/memory-scope-sanitizer.d.ts +6 -0
  252. package/dist/memory-scope-sanitizer.d.ts.map +1 -0
  253. package/dist/memory-scope-sanitizer.js +106 -0
  254. package/dist/memory-target-resolver.d.ts +4 -0
  255. package/dist/memory-target-resolver.d.ts.map +1 -0
  256. package/dist/memory-target-resolver.js +73 -0
  257. package/dist/memory-workflow-port.d.ts +14 -0
  258. package/dist/memory-workflow-port.d.ts.map +1 -0
  259. package/dist/memory-workflow-port.js +186 -0
  260. package/dist/private-json.d.ts +3 -0
  261. package/dist/private-json.d.ts.map +1 -0
  262. package/dist/private-json.js +62 -0
  263. package/dist/promptEnhancer/index.d.ts +3 -0
  264. package/dist/promptEnhancer/index.d.ts.map +1 -0
  265. package/dist/promptEnhancer/index.js +5 -0
  266. package/dist/promptEnhancer/orchestrate.d.ts +2 -0
  267. package/dist/promptEnhancer/orchestrate.d.ts.map +1 -0
  268. package/dist/promptEnhancer/orchestrate.js +5 -0
  269. package/dist/promptEnhancer/routes.d.ts +9 -0
  270. package/dist/promptEnhancer/routes.d.ts.map +1 -0
  271. package/dist/promptEnhancer/routes.js +205 -0
  272. package/dist/qualityIntelligence/capsuleAdapter.d.ts +27 -0
  273. package/dist/qualityIntelligence/capsuleAdapter.d.ts.map +1 -0
  274. package/dist/qualityIntelligence/capsuleAdapter.js +57 -0
  275. package/dist/qualityIntelligence/connectorAuthorization.d.ts +22 -0
  276. package/dist/qualityIntelligence/connectorAuthorization.d.ts.map +1 -0
  277. package/dist/qualityIntelligence/connectorAuthorization.js +35 -0
  278. package/dist/qualityIntelligence/connectorErrors.d.ts +16 -0
  279. package/dist/qualityIntelligence/connectorErrors.d.ts.map +1 -0
  280. package/dist/qualityIntelligence/connectorErrors.js +56 -0
  281. package/dist/qualityIntelligence/connectorRoutes.d.ts +7 -0
  282. package/dist/qualityIntelligence/connectorRoutes.d.ts.map +1 -0
  283. package/dist/qualityIntelligence/connectorRoutes.js +167 -0
  284. package/dist/qualityIntelligence/editRoutes.d.ts +5 -0
  285. package/dist/qualityIntelligence/editRoutes.d.ts.map +1 -0
  286. package/dist/qualityIntelligence/editRoutes.js +293 -0
  287. package/dist/qualityIntelligence/exportAssembly.d.ts +22 -0
  288. package/dist/qualityIntelligence/exportAssembly.d.ts.map +1 -0
  289. package/dist/qualityIntelligence/exportAssembly.js +352 -0
  290. package/dist/qualityIntelligence/exportRoutes.d.ts +5 -0
  291. package/dist/qualityIntelligence/exportRoutes.d.ts.map +1 -0
  292. package/dist/qualityIntelligence/exportRoutes.js +320 -0
  293. package/dist/qualityIntelligence/figma/figmaConcurrency.d.ts +8 -0
  294. package/dist/qualityIntelligence/figma/figmaConcurrency.d.ts.map +1 -0
  295. package/dist/qualityIntelligence/figma/figmaConcurrency.js +34 -0
  296. package/dist/qualityIntelligence/figma/figmaConnector.d.ts +65 -0
  297. package/dist/qualityIntelligence/figma/figmaConnector.d.ts.map +1 -0
  298. package/dist/qualityIntelligence/figma/figmaConnector.js +184 -0
  299. package/dist/qualityIntelligence/figma/figmaConnectorAudit.d.ts +52 -0
  300. package/dist/qualityIntelligence/figma/figmaConnectorAudit.d.ts.map +1 -0
  301. package/dist/qualityIntelligence/figma/figmaConnectorAudit.js +63 -0
  302. package/dist/qualityIntelligence/figma/figmaConnectorErrors.d.ts +31 -0
  303. package/dist/qualityIntelligence/figma/figmaConnectorErrors.d.ts.map +1 -0
  304. package/dist/qualityIntelligence/figma/figmaConnectorErrors.js +220 -0
  305. package/dist/qualityIntelligence/figma/figmaConnectorMetrics.d.ts +44 -0
  306. package/dist/qualityIntelligence/figma/figmaConnectorMetrics.d.ts.map +1 -0
  307. package/dist/qualityIntelligence/figma/figmaConnectorMetrics.js +49 -0
  308. package/dist/qualityIntelligence/figma/figmaConsent.d.ts +39 -0
  309. package/dist/qualityIntelligence/figma/figmaConsent.d.ts.map +1 -0
  310. package/dist/qualityIntelligence/figma/figmaConsent.js +62 -0
  311. package/dist/qualityIntelligence/figma/figmaHttpPort.d.ts +28 -0
  312. package/dist/qualityIntelligence/figma/figmaHttpPort.d.ts.map +1 -0
  313. package/dist/qualityIntelligence/figma/figmaHttpPort.js +70 -0
  314. package/dist/qualityIntelligence/figma/figmaObservedActions.d.ts +49 -0
  315. package/dist/qualityIntelligence/figma/figmaObservedActions.d.ts.map +1 -0
  316. package/dist/qualityIntelligence/figma/figmaObservedActions.js +89 -0
  317. package/dist/qualityIntelligence/figma/figmaReadiness.d.ts +32 -0
  318. package/dist/qualityIntelligence/figma/figmaReadiness.d.ts.map +1 -0
  319. package/dist/qualityIntelligence/figma/figmaReadiness.js +67 -0
  320. package/dist/qualityIntelligence/figma/figmaRenderPort.d.ts +29 -0
  321. package/dist/qualityIntelligence/figma/figmaRenderPort.d.ts.map +1 -0
  322. package/dist/qualityIntelligence/figma/figmaRenderPort.js +93 -0
  323. package/dist/qualityIntelligence/figma/figmaResnapshot.d.ts +28 -0
  324. package/dist/qualityIntelligence/figma/figmaResnapshot.d.ts.map +1 -0
  325. package/dist/qualityIntelligence/figma/figmaResnapshot.js +38 -0
  326. package/dist/qualityIntelligence/figma/figmaRetry.d.ts +31 -0
  327. package/dist/qualityIntelligence/figma/figmaRetry.d.ts.map +1 -0
  328. package/dist/qualityIntelligence/figma/figmaRetry.js +62 -0
  329. package/dist/qualityIntelligence/figma/figmaScopeRef.d.ts +9 -0
  330. package/dist/qualityIntelligence/figma/figmaScopeRef.d.ts.map +1 -0
  331. package/dist/qualityIntelligence/figma/figmaScopeRef.js +18 -0
  332. package/dist/qualityIntelligence/figma/figmaScopedPagination.d.ts +86 -0
  333. package/dist/qualityIntelligence/figma/figmaScopedPagination.d.ts.map +1 -0
  334. package/dist/qualityIntelligence/figma/figmaScopedPagination.js +308 -0
  335. package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.d.ts +31 -0
  336. package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.d.ts.map +1 -0
  337. package/dist/qualityIntelligence/figma/figmaSnapshotBuilder.js +314 -0
  338. package/dist/qualityIntelligence/figma/figmaSnapshotHash.d.ts +18 -0
  339. package/dist/qualityIntelligence/figma/figmaSnapshotHash.d.ts.map +1 -0
  340. package/dist/qualityIntelligence/figma/figmaSnapshotHash.js +63 -0
  341. package/dist/qualityIntelligence/figma/figmaSnapshotTypes.d.ts +65 -0
  342. package/dist/qualityIntelligence/figma/figmaSnapshotTypes.d.ts.map +1 -0
  343. package/dist/qualityIntelligence/figma/figmaSnapshotTypes.js +13 -0
  344. package/dist/qualityIntelligence/figma/figmaTokenSource.d.ts +9 -0
  345. package/dist/qualityIntelligence/figma/figmaTokenSource.d.ts.map +1 -0
  346. package/dist/qualityIntelligence/figma/figmaTokenSource.js +61 -0
  347. package/dist/qualityIntelligence/figma/figmaTokenStore.d.ts +19 -0
  348. package/dist/qualityIntelligence/figma/figmaTokenStore.d.ts.map +1 -0
  349. package/dist/qualityIntelligence/figma/figmaTokenStore.js +156 -0
  350. package/dist/qualityIntelligence/figma/figmaUrl.d.ts +6 -0
  351. package/dist/qualityIntelligence/figma/figmaUrl.d.ts.map +1 -0
  352. package/dist/qualityIntelligence/figma/figmaUrl.js +36 -0
  353. package/dist/qualityIntelligence/figma/index.d.ts +20 -0
  354. package/dist/qualityIntelligence/figma/index.d.ts.map +1 -0
  355. package/dist/qualityIntelligence/figma/index.js +26 -0
  356. package/dist/qualityIntelligence/figmaCodegenRoutes.d.ts +28 -0
  357. package/dist/qualityIntelligence/figmaCodegenRoutes.d.ts.map +1 -0
  358. package/dist/qualityIntelligence/figmaCodegenRoutes.js +165 -0
  359. package/dist/qualityIntelligence/figmaSnapshotAdapter.d.ts +55 -0
  360. package/dist/qualityIntelligence/figmaSnapshotAdapter.d.ts.map +1 -0
  361. package/dist/qualityIntelligence/figmaSnapshotAdapter.js +219 -0
  362. package/dist/qualityIntelligence/figmaSnapshotOrchestration.d.ts +64 -0
  363. package/dist/qualityIntelligence/figmaSnapshotOrchestration.d.ts.map +1 -0
  364. package/dist/qualityIntelligence/figmaSnapshotOrchestration.js +203 -0
  365. package/dist/qualityIntelligence/figmaSnapshotRoutes.d.ts +112 -0
  366. package/dist/qualityIntelligence/figmaSnapshotRoutes.d.ts.map +1 -0
  367. package/dist/qualityIntelligence/figmaSnapshotRoutes.js +1063 -0
  368. package/dist/qualityIntelligence/figmaSnapshotScreenIds.d.ts +19 -0
  369. package/dist/qualityIntelligence/figmaSnapshotScreenIds.d.ts.map +1 -0
  370. package/dist/qualityIntelligence/figmaSnapshotScreenIds.js +75 -0
  371. package/dist/qualityIntelligence/generationPort.d.ts +15 -0
  372. package/dist/qualityIntelligence/generationPort.d.ts.map +1 -0
  373. package/dist/qualityIntelligence/generationPort.js +185 -0
  374. package/dist/qualityIntelligence/handoffErrors.d.ts +9 -0
  375. package/dist/qualityIntelligence/handoffErrors.d.ts.map +1 -0
  376. package/dist/qualityIntelligence/handoffErrors.js +21 -0
  377. package/dist/qualityIntelligence/handoffRoutes.d.ts +15 -0
  378. package/dist/qualityIntelligence/handoffRoutes.d.ts.map +1 -0
  379. package/dist/qualityIntelligence/handoffRoutes.js +341 -0
  380. package/dist/qualityIntelligence/index.d.ts +17 -0
  381. package/dist/qualityIntelligence/index.d.ts.map +1 -0
  382. package/dist/qualityIntelligence/index.js +36 -0
  383. package/dist/qualityIntelligence/judgePort.d.ts +30 -0
  384. package/dist/qualityIntelligence/judgePort.d.ts.map +1 -0
  385. package/dist/qualityIntelligence/judgePort.js +326 -0
  386. package/dist/qualityIntelligence/modelSelection.d.ts +58 -0
  387. package/dist/qualityIntelligence/modelSelection.d.ts.map +1 -0
  388. package/dist/qualityIntelligence/modelSelection.js +148 -0
  389. package/dist/qualityIntelligence/reCheckRoutes.d.ts +6 -0
  390. package/dist/qualityIntelligence/reCheckRoutes.d.ts.map +1 -0
  391. package/dist/qualityIntelligence/reCheckRoutes.js +1157 -0
  392. package/dist/qualityIntelligence/retentionEnforcement.d.ts +13 -0
  393. package/dist/qualityIntelligence/retentionEnforcement.d.ts.map +1 -0
  394. package/dist/qualityIntelligence/retentionEnforcement.js +47 -0
  395. package/dist/qualityIntelligence/retentionRoutes.d.ts +8 -0
  396. package/dist/qualityIntelligence/retentionRoutes.d.ts.map +1 -0
  397. package/dist/qualityIntelligence/retentionRoutes.js +74 -0
  398. package/dist/qualityIntelligence/reviewRoutes.d.ts +5 -0
  399. package/dist/qualityIntelligence/reviewRoutes.d.ts.map +1 -0
  400. package/dist/qualityIntelligence/reviewRoutes.js +145 -0
  401. package/dist/qualityIntelligence/reviewStore.d.ts +75 -0
  402. package/dist/qualityIntelligence/reviewStore.d.ts.map +1 -0
  403. package/dist/qualityIntelligence/reviewStore.js +170 -0
  404. package/dist/qualityIntelligence/runExecution.d.ts +36 -0
  405. package/dist/qualityIntelligence/runExecution.d.ts.map +1 -0
  406. package/dist/qualityIntelligence/runExecution.js +180 -0
  407. package/dist/qualityIntelligence/runIngestion.d.ts +70 -0
  408. package/dist/qualityIntelligence/runIngestion.d.ts.map +1 -0
  409. package/dist/qualityIntelligence/runIngestion.js +1235 -0
  410. package/dist/qualityIntelligence/runRegistry.d.ts +31 -0
  411. package/dist/qualityIntelligence/runRegistry.d.ts.map +1 -0
  412. package/dist/qualityIntelligence/runRegistry.js +66 -0
  413. package/dist/qualityIntelligence/runRoutes.d.ts +16 -0
  414. package/dist/qualityIntelligence/runRoutes.d.ts.map +1 -0
  415. package/dist/qualityIntelligence/runRoutes.js +357 -0
  416. package/dist/qualityIntelligence/traceabilityRoutes.d.ts +5 -0
  417. package/dist/qualityIntelligence/traceabilityRoutes.d.ts.map +1 -0
  418. package/dist/qualityIntelligence/traceabilityRoutes.js +173 -0
  419. package/dist/qualityIntelligence/uiRoutes.d.ts +7 -0
  420. package/dist/qualityIntelligence/uiRoutes.d.ts.map +1 -0
  421. package/dist/qualityIntelligence/uiRoutes.js +336 -0
  422. package/dist/read-handlers.d.ts +9 -0
  423. package/dist/read-handlers.d.ts.map +1 -0
  424. package/dist/read-handlers.js +265 -0
  425. package/dist/relationship-handlers.d.ts +191 -0
  426. package/dist/relationship-handlers.d.ts.map +1 -0
  427. package/dist/relationship-handlers.js +0 -0
  428. package/dist/routes.d.ts +37 -0
  429. package/dist/routes.d.ts.map +1 -0
  430. package/dist/routes.js +507 -0
  431. package/dist/run-engine.d.ts +25 -0
  432. package/dist/run-engine.d.ts.map +1 -0
  433. package/dist/run-engine.js +385 -0
  434. package/dist/run-handlers.d.ts +9 -0
  435. package/dist/run-handlers.d.ts.map +1 -0
  436. package/dist/run-handlers.js +465 -0
  437. package/dist/run-request.d.ts +17 -0
  438. package/dist/run-request.d.ts.map +1 -0
  439. package/dist/run-request.js +219 -0
  440. package/dist/runs.d.ts +47 -0
  441. package/dist/runs.d.ts.map +1 -0
  442. package/dist/runs.js +100 -0
  443. package/dist/server.d.ts +13 -0
  444. package/dist/server.d.ts.map +1 -0
  445. package/dist/server.js +152 -0
  446. package/dist/sink.d.ts +28 -0
  447. package/dist/sink.d.ts.map +1 -0
  448. package/dist/sink.js +80 -0
  449. package/dist/sse-write.d.ts +9 -0
  450. package/dist/sse-write.d.ts.map +1 -0
  451. package/dist/sse-write.js +26 -0
  452. package/dist/sse.d.ts +8 -0
  453. package/dist/sse.d.ts.map +1 -0
  454. package/dist/sse.js +27 -0
  455. package/dist/static.d.ts +5 -0
  456. package/dist/static.d.ts.map +1 -0
  457. package/dist/static.js +76 -0
  458. package/dist/store/chats.d.ts +17 -0
  459. package/dist/store/chats.d.ts.map +1 -0
  460. package/dist/store/chats.js +624 -0
  461. package/dist/store/db.d.ts +11 -0
  462. package/dist/store/db.d.ts.map +1 -0
  463. package/dist/store/db.js +203 -0
  464. package/dist/store/errors.d.ts +13 -0
  465. package/dist/store/errors.d.ts.map +1 -0
  466. package/dist/store/errors.js +30 -0
  467. package/dist/store/index.d.ts +7 -0
  468. package/dist/store/index.d.ts.map +1 -0
  469. package/dist/store/index.js +6 -0
  470. package/dist/store/messages.d.ts +8 -0
  471. package/dist/store/messages.d.ts.map +1 -0
  472. package/dist/store/messages.js +149 -0
  473. package/dist/store/paths.d.ts +5 -0
  474. package/dist/store/paths.d.ts.map +1 -0
  475. package/dist/store/paths.js +84 -0
  476. package/dist/store/projects.d.ts +8 -0
  477. package/dist/store/projects.d.ts.map +1 -0
  478. package/dist/store/projects.js +59 -0
  479. package/dist/store/relationship-audit.d.ts +42 -0
  480. package/dist/store/relationship-audit.d.ts.map +1 -0
  481. package/dist/store/relationship-audit.js +155 -0
  482. package/dist/store/relationships.d.ts +191 -0
  483. package/dist/store/relationships.d.ts.map +1 -0
  484. package/dist/store/relationships.js +724 -0
  485. package/dist/store/schema.d.ts +4 -0
  486. package/dist/store/schema.d.ts.map +1 -0
  487. package/dist/store/schema.js +220 -0
  488. package/dist/store/types.d.ts +29 -0
  489. package/dist/store/types.d.ts.map +1 -0
  490. package/dist/store/types.js +8 -0
  491. package/dist/store/validation.d.ts +7 -0
  492. package/dist/store/validation.d.ts.map +1 -0
  493. package/dist/store/validation.js +117 -0
  494. package/dist/store-handlers.d.ts +17 -0
  495. package/dist/store-handlers.d.ts.map +1 -0
  496. package/dist/store-handlers.js +872 -0
  497. package/dist/terminal-errors.d.ts +22 -0
  498. package/dist/terminal-errors.d.ts.map +1 -0
  499. package/dist/terminal-errors.js +45 -0
  500. package/dist/terminal-evidence.d.ts +21 -0
  501. package/dist/terminal-evidence.d.ts.map +1 -0
  502. package/dist/terminal-evidence.js +65 -0
  503. package/dist/terminal-routes.d.ts +10 -0
  504. package/dist/terminal-routes.d.ts.map +1 -0
  505. package/dist/terminal-routes.js +219 -0
  506. package/dist/terminal.d.ts +68 -0
  507. package/dist/terminal.d.ts.map +1 -0
  508. package/dist/terminal.js +855 -0
  509. package/package.json +52 -0
@@ -0,0 +1,19 @@
1
+ /** Upper bound on the number of scoped screen ids in one figma-snapshot source (DoS / payload guard). */
2
+ export declare const MAX_FIGMA_SCREEN_IDS = 200;
3
+ /** Upper bound on a single screen id's length (mirrors the UI persistence reference-value cap). */
4
+ export declare const MAX_FIGMA_SCREEN_ID_LENGTH = 256;
5
+ export type FigmaScreenIdsResult = {
6
+ readonly ok: true;
7
+ readonly screenIds: readonly string[] | undefined;
8
+ } | {
9
+ readonly ok: false;
10
+ readonly reason: string;
11
+ };
12
+ /**
13
+ * Validate and canonicalise the optional `screenIds` field of an incoming figma-snapshot source.
14
+ * Returns `{ ok: true, screenIds: undefined }` when the field is absent (whole-snapshot source),
15
+ * `{ ok: true, screenIds }` with a deduplicated, sorted, bounded list when it is a valid scope, or
16
+ * `{ ok: false, reason }` with a user-actionable message when it is malformed / empty / oversized.
17
+ */
18
+ export declare function parseFigmaSnapshotScreenIds(raw: unknown): FigmaScreenIdsResult;
19
+ //# sourceMappingURL=figmaSnapshotScreenIds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"figmaSnapshotScreenIds.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/figmaSnapshotScreenIds.ts"],"names":[],"mappings":"AAkBA,yGAAyG;AACzG,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAExC,mGAAmG;AACnG,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,MAAM,MAAM,oBAAoB,GAC5B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,GAAG,SAAS,CAAA;CAAE,GACxE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,OAAO,GAAG,oBAAoB,CA+C9E"}
@@ -0,0 +1,75 @@
1
+ // Shared validation + canonicalisation for figma-snapshot `screenIds` scoping (Epic #750, Issue #754).
2
+ //
3
+ // Both the start-run route (runRoutes.ts) and the drift re-check / regenerate route (reCheckRoutes.ts)
4
+ // accept figma-snapshot sources that MAY carry an optional `screenIds` array scoping ingestion to
5
+ // specific masks of a large board. This module is the SINGLE source of truth so the two routes can
6
+ // never diverge on what they accept — the audit's run/recheck-parity requirement.
7
+ //
8
+ // Invariants enforced here:
9
+ // - `screenIds` ABSENT → whole-snapshot source (returns `undefined`; the contract's "absent = whole").
10
+ // - `screenIds` PRESENT → must be a NON-EMPTY array of non-empty, bounded, string ids. An explicit
11
+ // empty array is REJECTED: a scoped source with zero screens is meaningless, and left unchecked the
12
+ // server's `scopedParsedScreens` treats an empty screen list as "all screens" — silently widening a
13
+ // scoped request to the whole board (the scoped-snapshot leak this guard closes).
14
+ // - Each id is trimmed, must be non-empty and within the length cap; the array count is capped.
15
+ // - The result is CANONICAL (deduplicated + sorted) so the derived envelope id / provenance ref is
16
+ // stable regardless of the order or duplicates the client sent, and dedupe across reconnections and
17
+ // re-check is exact.
18
+ /** Upper bound on the number of scoped screen ids in one figma-snapshot source (DoS / payload guard). */
19
+ export const MAX_FIGMA_SCREEN_IDS = 200;
20
+ /** Upper bound on a single screen id's length (mirrors the UI persistence reference-value cap). */
21
+ export const MAX_FIGMA_SCREEN_ID_LENGTH = 256;
22
+ /**
23
+ * Validate and canonicalise the optional `screenIds` field of an incoming figma-snapshot source.
24
+ * Returns `{ ok: true, screenIds: undefined }` when the field is absent (whole-snapshot source),
25
+ * `{ ok: true, screenIds }` with a deduplicated, sorted, bounded list when it is a valid scope, or
26
+ * `{ ok: false, reason }` with a user-actionable message when it is malformed / empty / oversized.
27
+ */
28
+ export function parseFigmaSnapshotScreenIds(raw) {
29
+ if (raw === undefined)
30
+ return { ok: true, screenIds: undefined };
31
+ if (!Array.isArray(raw)) {
32
+ return {
33
+ ok: false,
34
+ reason: "A figma-snapshot source screenIds field must be an array of screen ids.",
35
+ };
36
+ }
37
+ if (raw.length === 0) {
38
+ return {
39
+ ok: false,
40
+ reason: "A figma-snapshot source screenIds field, when present, must list at least one screen id.",
41
+ };
42
+ }
43
+ if (raw.length > MAX_FIGMA_SCREEN_IDS) {
44
+ return {
45
+ ok: false,
46
+ reason: `A figma-snapshot source may scope at most ${String(MAX_FIGMA_SCREEN_IDS)} screen ids.`,
47
+ };
48
+ }
49
+ const seen = new Set();
50
+ for (const item of raw) {
51
+ if (typeof item !== "string") {
52
+ return {
53
+ ok: false,
54
+ reason: "A figma-snapshot source screenIds field must contain non-empty strings.",
55
+ };
56
+ }
57
+ const screenId = item.trim();
58
+ if (screenId.length === 0) {
59
+ return {
60
+ ok: false,
61
+ reason: "A figma-snapshot source screenIds field must contain non-empty strings.",
62
+ };
63
+ }
64
+ if (screenId.length > MAX_FIGMA_SCREEN_ID_LENGTH) {
65
+ return {
66
+ ok: false,
67
+ reason: `A figma-snapshot source screen id exceeds the ${String(MAX_FIGMA_SCREEN_ID_LENGTH)}-character limit.`,
68
+ };
69
+ }
70
+ seen.add(screenId);
71
+ }
72
+ // Canonical: dedupe (Set) + sort so the derived envelope id / provenance ref is order- and
73
+ // duplicate-stable, and dedupe across reconnections / re-check is exact.
74
+ return { ok: true, screenIds: [...seen].sort() };
75
+ }
@@ -0,0 +1,15 @@
1
+ import type { QualityIntelligenceGenerationPort } from "@oscharko-dev/keiko-workflows";
2
+ import type { UiHandlerDeps } from "../deps.js";
3
+ export declare class QiGenerationError extends Error {
4
+ readonly code: string;
5
+ constructor(code: string, message: string);
6
+ }
7
+ export type QiGenerationTarget = string | {
8
+ readonly kind: "baseline";
9
+ } | {
10
+ readonly kind: "model";
11
+ readonly modelId: string;
12
+ readonly requestedSeed?: number | undefined;
13
+ };
14
+ export declare function createQiGenerationPort(deps: UiHandlerDeps, target: QiGenerationTarget): QualityIntelligenceGenerationPort;
15
+ //# sourceMappingURL=generationPort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generationPort.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/generationPort.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EACV,iCAAiC,EAGlC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAIhD,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAgB,IAAI,EAAE,MAAM,CAAC;gBACjB,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAmGD,MAAM,MAAM,kBAAkB,GAC1B,MAAM,GACN;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAC7B;IACE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7C,CAAC;AAsHN,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,kBAAkB,GACzB,iCAAiC,CAMnC"}
@@ -0,0 +1,185 @@
1
+ // Quality Intelligence generation port (Epic #270, Issue #279).
2
+ //
3
+ // Backs the abstract `QualityIntelligenceGenerationPort` (consumed by the model-routed workflow run
4
+ // entry) with the REAL Keiko Model Gateway via `deps.modelPortFactory` — the same seam the
5
+ // Conversation Center / grounded-QA path uses. Applies the #279 capability gate before any request
6
+ // is built (unsupported models fail before a network call), assembles trusted system + instruction
7
+ // segments separately from `<qi-evidence>`-delimited untrusted source text, and scrubs evidence so
8
+ // it cannot break the delimiter or smuggle control characters (Issue #284). No provider SDK import.
9
+ import { QualityIntelligence as MgQI, findCapability, findConfiguredCapability, QualityIntelligenceSafeErrorException, } from "@oscharko-dev/keiko-model-gateway";
10
+ import { QualityIntelligenceHardening, QualityIntelligenceGeneration, } from "@oscharko-dev/keiko-quality-intelligence";
11
+ const BASELINE_GENERATION_OUTPUT = JSON.stringify({ testCases: [] });
12
+ export class QiGenerationError extends Error {
13
+ code;
14
+ constructor(code, message) {
15
+ super(message);
16
+ this.code = code;
17
+ this.name = "QiGenerationError";
18
+ }
19
+ }
20
+ function capabilityFor(deps, modelId) {
21
+ return deps.config === undefined
22
+ ? findCapability(modelId)
23
+ : findConfiguredCapability(deps.config, modelId);
24
+ }
25
+ // Invisible / directional format controls that NFKC does NOT remove: zero-width characters
26
+ // (ZWSP/ZWNJ/ZWJ and the BOM/ZWNBSP) and bidirectional controls (LRM/RLM, the LRE…RLO embedding/
27
+ // override block, and the isolate block). They carry no legitimate meaning in untrusted source
28
+ // evidence but can smuggle homoglyph/bidi deception into the model prompt — and into any candidate
29
+ // rendered or exported from it. Stripping them is content-preserving for real text (#278 Audit
30
+ // Addendum: normalise untrusted content before model prompt construction, rendering, or export).
31
+ function isInvisibleFormatControl(cp) {
32
+ return ((cp >= 0x200b && cp <= 0x200f) || // ZWSP, ZWNJ, ZWJ, LRM, RLM
33
+ (cp >= 0x202a && cp <= 0x202e) || // LRE, RLE, PDF, LRO, RLO
34
+ (cp >= 0x2066 && cp <= 0x2069) || // LRI, RLI, FSI, PDI
35
+ cp === 0xfeff // BOM / ZWNBSP
36
+ );
37
+ }
38
+ // A code point that must be stripped from evidence text: C0 controls (except tab/LF/CR), DEL, C1
39
+ // controls, or an invisible zero-width/bidi format control. Tab/LF/CR survive as legitimate text
40
+ // whitespace so multi-line evidence keeps its structure.
41
+ function isStrippableEvidenceCodePoint(cp) {
42
+ return ((cp <= 0x1f && cp !== 0x09 && cp !== 0x0a && cp !== 0x0d) ||
43
+ cp === 0x7f ||
44
+ (cp >= 0x80 && cp <= 0x9f) ||
45
+ isInvisibleFormatControl(cp));
46
+ }
47
+ // Strip control / invisible format characters via a code-point scan so the `no-control-regex` rule
48
+ // stays satisfied; then neutralise any literal evidence delimiter so untrusted text cannot close the
49
+ // <qi-evidence> block early.
50
+ function scrubEvidenceText(text) {
51
+ const normalised = text.normalize("NFKC");
52
+ let out = "";
53
+ for (const ch of normalised) {
54
+ const cp = ch.codePointAt(0);
55
+ if (cp === undefined)
56
+ continue;
57
+ if (!isStrippableEvidenceCodePoint(cp))
58
+ out += ch;
59
+ }
60
+ return out.replace(/<\/?qi-evidence/giu, "[evidence]");
61
+ }
62
+ // Second line of defence behind the structural fence (Issue #284 AC1: "Untrusted content cannot
63
+ // override system or workflow instructions"). After scrubbing, run the natural-language
64
+ // prompt-injection scanner on each evidence block: a detected imperative ("ignore previous
65
+ // instructions", a `system:` role line, a jailbreak token, …) is NOT silently passed through — the
66
+ // block is tagged with the matched pattern names so the model sees the evidence is suspect (it is
67
+ // already DATA, never instructions, per the system prompt). Non-blocking by design: a requirement
68
+ // that legitimately quotes such a phrase must still produce a run, so detection annotates the block
69
+ // rather than failing the run. The pattern names are corpus slugs (`[a-z-]`), inert in an attribute.
70
+ function buildEvidenceBlocks(evidence) {
71
+ return evidence
72
+ .map((e) => {
73
+ const kind = e.kind.replace(/[^a-z0-9-]/giu, "");
74
+ const scrubbed = scrubEvidenceText(e.text);
75
+ const scan = QualityIntelligenceHardening.scanForPromptInjections(scrubbed);
76
+ const flagged = scan.safe ? "" : ` flagged="prompt-injection:${scan.injections.join(",")}"`;
77
+ return `<qi-evidence index="${String(e.index)}" kind="${kind}"${flagged}>\n${scrubbed}\n</qi-evidence>`;
78
+ })
79
+ .join("\n");
80
+ }
81
+ function buildMessages(args) {
82
+ const blocks = buildEvidenceBlocks(args.evidence);
83
+ const userContent = `${args.instruction}\n\n${blocks}`;
84
+ const size = QualityIntelligenceHardening.assertPromptSize(userContent);
85
+ if (!size.ok) {
86
+ throw new QiGenerationError("QI_PROMPT_TOO_LARGE", "The assembled prompt exceeds the model token budget; reduce the source size.");
87
+ }
88
+ return Object.freeze([
89
+ Object.freeze({ role: "system", content: args.systemPrompt }),
90
+ Object.freeze({ role: "user", content: userContent }),
91
+ ]);
92
+ }
93
+ /** Apply the qi:test-design capability gate and resolve the model port (Epic #761 / #279). */
94
+ function resolveGenerationModel(deps, target) {
95
+ const { modelId } = target;
96
+ const capability = capabilityFor(deps, modelId);
97
+ if (capability === undefined) {
98
+ throw new QiGenerationError("QI_MODEL_NOT_CONFIGURED", "The selected model is not configured.");
99
+ }
100
+ const profile = MgQI.getQualityIntelligenceTaskProfile("qi:test-design");
101
+ try {
102
+ MgQI.assertProfileCompatibleWithModel(profile, capability);
103
+ }
104
+ catch (error) {
105
+ if (error instanceof QualityIntelligenceSafeErrorException) {
106
+ throw new QiGenerationError("QI_MODEL_INCOMPATIBLE", "The selected model cannot generate test cases because it is not a compatible chat model.");
107
+ }
108
+ throw error;
109
+ }
110
+ const model = deps.modelPortFactory(modelId);
111
+ if (model === undefined) {
112
+ throw new QiGenerationError("QI_MODEL_UNAVAILABLE", "The model gateway is not available.");
113
+ }
114
+ return {
115
+ model,
116
+ modelId,
117
+ useResponseFormat: capability.supportsResponseFormat === true,
118
+ useSeed: capability.supportsSeeding === true && target.requestedSeed !== undefined,
119
+ requestedSeed: target.requestedSeed,
120
+ };
121
+ }
122
+ function normalizeTarget(target) {
123
+ if (typeof target === "string") {
124
+ return { kind: "model", modelId: target };
125
+ }
126
+ return target;
127
+ }
128
+ function createBaselineGenerationPort() {
129
+ return {
130
+ generate: () => Promise.resolve({
131
+ rawText: BASELINE_GENERATION_OUTPUT,
132
+ modelCallCount: 0,
133
+ }),
134
+ };
135
+ }
136
+ function buildGenerationRequest(modelId, messages, useResponseFormat, useSeed, requestedSeed) {
137
+ return {
138
+ modelId,
139
+ messages,
140
+ stream: false,
141
+ ...(useSeed && requestedSeed !== undefined ? { seed: requestedSeed } : {}),
142
+ ...(useResponseFormat
143
+ ? {
144
+ responseFormat: {
145
+ type: "json_schema",
146
+ schema: { ...QualityIntelligenceGeneration.QI_TEST_DESIGN_RESPONSE_SCHEMA },
147
+ },
148
+ }
149
+ : {}),
150
+ };
151
+ }
152
+ function buildModelParameters(useResponseFormat, useSeed, requestedSeed) {
153
+ const modelParameters = {};
154
+ if (useResponseFormat)
155
+ modelParameters.responseFormat = "json_schema";
156
+ if (useSeed && requestedSeed !== undefined)
157
+ modelParameters.seed = requestedSeed;
158
+ return Object.keys(modelParameters).length > 0 ? modelParameters : undefined;
159
+ }
160
+ function createModelGenerationPort(resolved) {
161
+ const { model, modelId, useResponseFormat, useSeed, requestedSeed } = resolved;
162
+ return {
163
+ generate: async (args) => {
164
+ const messages = buildMessages(args);
165
+ const signal = args.signal ?? new AbortController().signal;
166
+ const request = buildGenerationRequest(modelId, messages, useResponseFormat, useSeed, requestedSeed);
167
+ const response = await model.call(request, signal);
168
+ const modelParameters = buildModelParameters(useResponseFormat, useSeed, requestedSeed);
169
+ return {
170
+ rawText: response.content,
171
+ modelCallCount: 1,
172
+ modelId,
173
+ seedUsed: useSeed && requestedSeed !== undefined ? requestedSeed : null,
174
+ ...(modelParameters !== undefined ? { modelParameters } : {}),
175
+ };
176
+ },
177
+ };
178
+ }
179
+ export function createQiGenerationPort(deps, target) {
180
+ const normalized = normalizeTarget(target);
181
+ if (normalized.kind === "baseline") {
182
+ return createBaselineGenerationPort();
183
+ }
184
+ return createModelGenerationPort(resolveGenerationModel(deps, normalized));
185
+ }
@@ -0,0 +1,9 @@
1
+ export type QiHandoffErrorCode = "QI_HANDOFF_BAD_REQUEST" | "QI_HANDOFF_PAYLOAD_TOO_LARGE" | "QI_HANDOFF_UNKNOWN_CHAT_MESSAGE" | "QI_HANDOFF_FORBIDDEN_PAYLOAD" | "QI_HANDOFF_INTERNAL";
2
+ export interface QiHandoffErrorBody {
3
+ readonly error: {
4
+ readonly code: QiHandoffErrorCode;
5
+ readonly message: string;
6
+ };
7
+ }
8
+ export declare const qiHandoffErrorBody: (code: QiHandoffErrorCode) => QiHandoffErrorBody;
9
+ //# sourceMappingURL=handoffErrors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoffErrors.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/handoffErrors.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,kBAAkB,GAC1B,wBAAwB,GACxB,8BAA8B,GAC9B,iCAAiC,GACjC,8BAA8B,GAC9B,qBAAqB,CAAC;AAE1B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACjF;AAaD,eAAO,MAAM,kBAAkB,GAAI,MAAM,kBAAkB,KAAG,kBAE5D,CAAC"}
@@ -0,0 +1,21 @@
1
+ // Quality Intelligence handoff route error shapes (Epic #270, Issue #281).
2
+ //
3
+ // Safe error JSON for the Conversation Center → QI workflow handoff route. Error bodies
4
+ // NEVER carry credentials, raw payloads, chat content, envelope ids, header values, or
5
+ // anything that could be mistaken for a secret. Every error message is a fixed string
6
+ // keyed by a stable code. Mirrors the existing connector error envelope shape so the
7
+ // dispatcher serialises it identically (`{ error: { code, message } }`).
8
+ //
9
+ // Note: kept separate from `connectorErrors.ts` to keep route-group code paths cleanly
10
+ // addressable for review and to avoid widening that file's error-code union with handoff
11
+ // concerns. Test parity with the connector error tests is enforced in `__tests__/`.
12
+ const SAFE_MESSAGES = {
13
+ QI_HANDOFF_BAD_REQUEST: "The request body is not a valid Quality Intelligence handoff envelope.",
14
+ QI_HANDOFF_PAYLOAD_TOO_LARGE: "The Quality Intelligence handoff envelope exceeds the maximum permitted size.",
15
+ QI_HANDOFF_UNKNOWN_CHAT_MESSAGE: "The referenced Conversation Center chat message could not be located.",
16
+ QI_HANDOFF_FORBIDDEN_PAYLOAD: "The handoff envelope contained a forbidden field. Handoff envelopes may not carry chat content, credentials, headers, or URLs.",
17
+ QI_HANDOFF_INTERNAL: "The Quality Intelligence handoff route could not service the request.",
18
+ };
19
+ export const qiHandoffErrorBody = (code) => ({
20
+ error: { code, message: SAFE_MESSAGES[code] },
21
+ });
@@ -0,0 +1,15 @@
1
+ import type { RouteContext, RouteDefinition, RouteResult } from "../routes.js";
2
+ import type { UiHandlerDeps } from "../deps.js";
3
+ export interface QiHandoffSuccessBody {
4
+ readonly handoffId: string;
5
+ readonly chatId: string;
6
+ readonly persistedMessageId: string;
7
+ readonly runId?: string;
8
+ }
9
+ export interface QiHandoffRouteOptions {
10
+ readonly now?: () => number;
11
+ }
12
+ export declare const createHandleQiHandoff: (options?: QiHandoffRouteOptions) => ((ctx: RouteContext, deps: UiHandlerDeps) => Promise<RouteResult>);
13
+ export declare const handleQiHandoff: (ctx: RouteContext, deps: UiHandlerDeps) => Promise<RouteResult>;
14
+ export declare const QI_HANDOFF_ROUTE_GROUP: readonly RouteDefinition[];
15
+ //# sourceMappingURL=handoffRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoffRoutes.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/handoffRoutes.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAiUhD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,qBAAqB,GAChC,UAAS,qBAA0B,KAClC,CAAC,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,WAAW,CAAC,CAwCnE,CAAC;AAEF,eAAO,MAAM,eAAe,QA1ClB,YAAY,QAAQ,aAAa,KAAK,OAAO,CAAC,WAAW,CA0Cb,CAAC;AAKvD,eAAO,MAAM,sBAAsB,EAAE,SAAS,eAAe,EAM5D,CAAC"}