@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,203 @@
1
+ // ADR-0013 D3/D8/D9 — DB lifecycle, factories, and the public UiStore wiring. The synchronous
2
+ // `node:sqlite` DatabaseSync drives both factories; the node adapter adds directory creation,
3
+ // 0o700/0o600 permission hardening (Unix), and reopen-safe migrations.
4
+ import { DatabaseSync } from "node:sqlite";
5
+ import { chmodSync, existsSync, mkdirSync, renameSync, statSync } from "node:fs";
6
+ import { dirname } from "node:path";
7
+ import { randomUUID } from "node:crypto";
8
+ import { runMigrations } from "./schema.js";
9
+ import { deleteProject as sqlDeleteProject, getProject as sqlGetProject, listProjects as sqlListProjects, updateProject as sqlUpdateProject, upsertProject as sqlUpsertProject, } from "./projects.js";
10
+ import { deleteChat as sqlDeleteChat, findChatById as sqlFindChatById, insertChat as sqlInsertChat, listChats as sqlListChats, listChatsLimited as sqlListChatsLimited, touchChat as sqlTouchChat, updateChat as sqlUpdateChat, } from "./chats.js";
11
+ import { findMessageById as sqlFindMessageById, insertMessage as sqlInsertMessage, listMessages as sqlListMessages, listMessagesLimited as sqlListMessagesLimited, updateMessage as sqlUpdateMessage, } from "./messages.js";
12
+ import { validateProjectPath } from "./validation.js";
13
+ import { basename } from "node:path";
14
+ import { invalidRequest } from "./errors.js";
15
+ const DEFAULT_REDACT = (s) => s;
16
+ // Returns whether a project's directory currently exists and is a directory. Derived availability
17
+ // (ADR-0013 D5): the store never deletes a row because the path went missing; the UI surfaces this.
18
+ export function isProjectAvailable(project) {
19
+ try {
20
+ return statSync(project.path).isDirectory();
21
+ }
22
+ catch {
23
+ return false;
24
+ }
25
+ }
26
+ function resolveOptions(opts) {
27
+ return {
28
+ now: opts?.now ?? (() => Date.now()),
29
+ newId: opts?.newId ?? randomUUID,
30
+ redactString: opts?.redactString ?? DEFAULT_REDACT,
31
+ };
32
+ }
33
+ function deriveProjectName(explicit, path) {
34
+ if (explicit === undefined)
35
+ return basename(path);
36
+ if (explicit.length === 0)
37
+ throw invalidRequest("Name must not be empty.");
38
+ return explicit;
39
+ }
40
+ function createChatRecord(db, options, projectPath, title, selectedModel, opts) {
41
+ const project = sqlGetProject(db, projectPath);
42
+ if (project !== undefined && !isProjectAvailable(project)) {
43
+ throw invalidRequest("Project path is unavailable.");
44
+ }
45
+ return sqlInsertChat(db, {
46
+ id: options.newId(),
47
+ projectPath,
48
+ title,
49
+ selectedModel,
50
+ opts,
51
+ now: options.now(),
52
+ });
53
+ }
54
+ function createMessageRecord(db, options, msg) {
55
+ return sqlInsertMessage(db, options.newId(), msg, options.redactString);
56
+ }
57
+ function createProjectRecord(db, options, path, name) {
58
+ const normalized = validateProjectPath(path, { mustExist: true });
59
+ const resolvedName = deriveProjectName(name, normalized);
60
+ return sqlUpsertProject(db, normalized, resolvedName, name !== undefined, options.now());
61
+ }
62
+ function updateProjectRecord(db, options, path, patch) {
63
+ const normalized = validateProjectPath(path, { mustExist: false });
64
+ return sqlUpdateProject(db, normalized, patch, options.now());
65
+ }
66
+ function deleteProjectRecord(db, path) {
67
+ const normalized = validateProjectPath(path, { mustExist: false });
68
+ sqlDeleteProject(db, normalized);
69
+ }
70
+ function createMessageBatch(db, options, messages) {
71
+ if (messages.length === 0) {
72
+ throw invalidRequest("At least one message is required.");
73
+ }
74
+ db.exec("BEGIN");
75
+ try {
76
+ const created = messages.map((msg) => createMessageRecord(db, options, msg));
77
+ for (const chatId of new Set(messages.map((msg) => msg.chatId))) {
78
+ sqlTouchChat(db, chatId, options.now());
79
+ }
80
+ db.exec("COMMIT");
81
+ return created;
82
+ }
83
+ catch (error) {
84
+ db.exec("ROLLBACK");
85
+ throw error;
86
+ }
87
+ }
88
+ function buildStore(db, options) {
89
+ return {
90
+ listProjects: () => sqlListProjects(db),
91
+ createProject: (path, name) => createProjectRecord(db, options, path, name),
92
+ updateProject: (path, patch) => updateProjectRecord(db, options, path, patch),
93
+ deleteProject: (path) => {
94
+ deleteProjectRecord(db, path);
95
+ },
96
+ listChats: (projectPath, limit) => limit === undefined
97
+ ? sqlListChats(db, projectPath)
98
+ : sqlListChatsLimited(db, projectPath, limit),
99
+ findChatById: (id) => sqlFindChatById(db, id),
100
+ createChat: (projectPath, title, selectedModel, opts) => createChatRecord(db, options, projectPath, title, selectedModel, opts),
101
+ updateChat: (id, patch, updateOptions) => sqlUpdateChat(db, id, patch, options.now(), updateOptions),
102
+ deleteChat: (id) => {
103
+ sqlDeleteChat(db, id);
104
+ },
105
+ listMessages: (chatId, limit) => limit === undefined ? sqlListMessages(db, chatId) : sqlListMessagesLimited(db, chatId, limit),
106
+ findMessageById: (id) => sqlFindMessageById(db, id),
107
+ createMessage: (msg) => {
108
+ const message = createMessageRecord(db, options, msg);
109
+ sqlTouchChat(db, msg.chatId, options.now());
110
+ return message;
111
+ },
112
+ createMessages: (messages) => createMessageBatch(db, options, messages),
113
+ updateMessage: (id, patch) => sqlUpdateMessage(db, id, patch, options.redactString),
114
+ close: () => {
115
+ db.close();
116
+ },
117
+ };
118
+ }
119
+ function quarantineCorruptDb(target) {
120
+ const ts = new Date().toISOString().replace(/[:.]/g, "-");
121
+ renameSync(target, `${target}.corrupt.${ts}`);
122
+ for (const sidecar of [`${target}-wal`, `${target}-shm`]) {
123
+ if (existsSync(sidecar)) {
124
+ renameSync(sidecar, `${sidecar}.corrupt.${ts}`);
125
+ }
126
+ }
127
+ }
128
+ // Issue #639 — bound the SQLITE_BUSY window so concurrent UI/BFF writers (chat writes,
129
+ // relationship writes, evidence-adjacent updates) wait for the writer lock for a short, bounded
130
+ // interval instead of failing immediately. 5_000ms matches the conservative default we want for
131
+ // the local single-writer desktop pattern; exported so the regression test can assert the value
132
+ // without re-deriving it.
133
+ export const UI_DB_BUSY_TIMEOUT_MS = 5_000;
134
+ function preparedDatabase(target) {
135
+ const db = new DatabaseSync(target);
136
+ db.exec("PRAGMA foreign_keys = ON");
137
+ db.exec(`PRAGMA busy_timeout = ${String(UI_DB_BUSY_TIMEOUT_MS)}`);
138
+ return db;
139
+ }
140
+ // ────────────────────────────────────────────────────────────────────────────
141
+ // In-memory factory (tests)
142
+ // ────────────────────────────────────────────────────────────────────────────
143
+ export function createInMemoryUiStore(opts) {
144
+ const db = preparedDatabase(":memory:");
145
+ runMigrations(db);
146
+ return buildStore(db, resolveOptions(opts));
147
+ }
148
+ // ────────────────────────────────────────────────────────────────────────────
149
+ // Node on-disk factory
150
+ // ────────────────────────────────────────────────────────────────────────────
151
+ function ensureDirHardened(dir) {
152
+ if (!existsSync(dir)) {
153
+ mkdirSync(dir, { recursive: true, mode: 0o700 });
154
+ }
155
+ if (process.platform !== "win32") {
156
+ try {
157
+ chmodSync(dir, 0o700);
158
+ }
159
+ catch {
160
+ // best-effort; leave existing perms if owner change is unavailable
161
+ }
162
+ }
163
+ }
164
+ function chmodIfPresent(path, mode) {
165
+ if (process.platform === "win32")
166
+ return;
167
+ try {
168
+ chmodSync(path, mode);
169
+ }
170
+ catch {
171
+ // file may not exist yet (WAL/-shm sidecars); best-effort
172
+ }
173
+ }
174
+ // Issue #539: deps.ts needs the raw DatabaseSync to compose the relationship-engine store on
175
+ // the same UI database file. The relationship V5 schema lives in this DB (schema.ts §V5);
176
+ // keeping a single connection avoids WAL-coordination overhead. `createNodeUiStore` stays a
177
+ // one-shot convenience for callers that do not need the underlying handle.
178
+ export function openNodeUiDatabase(dbPath) {
179
+ ensureDirHardened(dirname(dbPath));
180
+ let db = preparedDatabase(dbPath);
181
+ try {
182
+ db.exec("PRAGMA journal_mode = WAL");
183
+ runMigrations(db);
184
+ }
185
+ catch {
186
+ // Corrupt DB: quarantine (rename to .corrupt.<iso>) and open a fresh one.
187
+ db.close();
188
+ quarantineCorruptDb(dbPath);
189
+ db = preparedDatabase(dbPath);
190
+ db.exec("PRAGMA journal_mode = WAL");
191
+ runMigrations(db);
192
+ }
193
+ chmodIfPresent(dbPath, 0o600);
194
+ chmodIfPresent(`${dbPath}-wal`, 0o600);
195
+ chmodIfPresent(`${dbPath}-shm`, 0o600);
196
+ return db;
197
+ }
198
+ export function buildUiStoreOverDatabase(db, opts) {
199
+ return buildStore(db, resolveOptions(opts));
200
+ }
201
+ export function createNodeUiStore(dbPath, opts) {
202
+ return buildUiStoreOverDatabase(openNodeUiDatabase(dbPath), opts);
203
+ }
@@ -0,0 +1,13 @@
1
+ export type UiStoreErrorCode = "invalid_path" | "path_not_directory" | "path_not_found" | "project_exists" | "not_found" | "invalid_request" | "internal";
2
+ export declare class UiStoreError extends Error {
3
+ readonly code: UiStoreErrorCode;
4
+ readonly status: number;
5
+ constructor(code: UiStoreErrorCode, message: string, status: number);
6
+ }
7
+ export declare function invalidPath(message: string): UiStoreError;
8
+ export declare function pathNotDirectory(): UiStoreError;
9
+ export declare function pathNotFound(): UiStoreError;
10
+ export declare function notFound(entity: string): UiStoreError;
11
+ export declare function invalidRequest(message: string): UiStoreError;
12
+ export declare function projectExists(): UiStoreError;
13
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/store/errors.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,gBAAgB,GACxB,cAAc,GACd,oBAAoB,GACpB,gBAAgB,GAChB,gBAAgB,GAChB,WAAW,GACX,iBAAiB,GACjB,UAAU,CAAC;AAEf,qBAAa,YAAa,SAAQ,KAAK;IACrC,SAAgB,IAAI,EAAE,gBAAgB,CAAC;IACvC,SAAgB,MAAM,EAAE,MAAM,CAAC;gBAEZ,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAM3E;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAEzD;AAED,wBAAgB,gBAAgB,IAAI,YAAY,CAE/C;AAED,wBAAgB,YAAY,IAAI,YAAY,CAE3C;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAErD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,YAAY,CAE5D;AAED,wBAAgB,aAAa,IAAI,YAAY,CAE5C"}
@@ -0,0 +1,30 @@
1
+ // ADR-0013 — Typed errors with stable codes. NEVER include the raw path, SQL text, or system error
2
+ // strings in `.message` — these surface to the BFF error envelope and must be safe to log/expose.
3
+ export class UiStoreError extends Error {
4
+ code;
5
+ status;
6
+ constructor(code, message, status) {
7
+ super(message);
8
+ this.name = "UiStoreError";
9
+ this.code = code;
10
+ this.status = status;
11
+ }
12
+ }
13
+ export function invalidPath(message) {
14
+ return new UiStoreError("invalid_path", message, 400);
15
+ }
16
+ export function pathNotDirectory() {
17
+ return new UiStoreError("path_not_directory", "The path is not a directory.", 400);
18
+ }
19
+ export function pathNotFound() {
20
+ return new UiStoreError("path_not_found", "The path does not exist.", 400);
21
+ }
22
+ export function notFound(entity) {
23
+ return new UiStoreError("not_found", `${entity} not found.`, 404);
24
+ }
25
+ export function invalidRequest(message) {
26
+ return new UiStoreError("invalid_request", message, 400);
27
+ }
28
+ export function projectExists() {
29
+ return new UiStoreError("project_exists", "Project already registered.", 409);
30
+ }
@@ -0,0 +1,7 @@
1
+ export type { Chat, ChatConnectedScope, ChatLocalKnowledgeScope, ChatMessage, ChatRole, CreateChatOptions, NewChatMessage, Project, UiStore, UiStoreFactoryOptions, UpdateChatOptions, UpdateChatMessagePatch, UpdateChatPatch, UpdateProjectPatch, WorkflowStatus, } from "./types.js";
2
+ export { UiStoreError, type UiStoreErrorCode, invalidPath, invalidRequest, notFound, pathNotDirectory, pathNotFound, projectExists, } from "./errors.js";
3
+ export { classifyPathShape, validateProjectPath, type PathShape, type ValidateProjectPathOptions, } from "./validation.js";
4
+ export { assertUiDbOutsideProject, resolveUiDbPath, UI_DB_FILENAME, UI_DB_DIRNAME, } from "./paths.js";
5
+ export { runMigrations, SCHEMA_VERSION } from "./schema.js";
6
+ export { buildUiStoreOverDatabase, createInMemoryUiStore, createNodeUiStore, isProjectAvailable, openNodeUiDatabase, UI_DB_BUSY_TIMEOUT_MS, } from "./db.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/store/index.ts"],"names":[],"mappings":"AAEA,YAAY,EACV,IAAI,EACJ,kBAAkB,EAClB,uBAAuB,EACvB,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,OAAO,EACP,OAAO,EACP,qBAAqB,EACrB,iBAAiB,EACjB,sBAAsB,EACtB,eAAe,EACf,kBAAkB,EAClB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,YAAY,EACZ,KAAK,gBAAgB,EACrB,WAAW,EACX,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,KAAK,SAAS,EACd,KAAK,0BAA0B,GAChC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,wBAAwB,EACxB,eAAe,EACf,cAAc,EACd,aAAa,GACd,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,6 @@
1
+ // ADR-0013 — UI-local SQLite persistence layer. Barrel re-exporting the public seams.
2
+ export { UiStoreError, invalidPath, invalidRequest, notFound, pathNotDirectory, pathNotFound, projectExists, } from "./errors.js";
3
+ export { classifyPathShape, validateProjectPath, } from "./validation.js";
4
+ export { assertUiDbOutsideProject, resolveUiDbPath, UI_DB_FILENAME, UI_DB_DIRNAME, } from "./paths.js";
5
+ export { runMigrations, SCHEMA_VERSION } from "./schema.js";
6
+ export { buildUiStoreOverDatabase, createInMemoryUiStore, createNodeUiStore, isProjectAvailable, openNodeUiDatabase, UI_DB_BUSY_TIMEOUT_MS, } from "./db.js";
@@ -0,0 +1,8 @@
1
+ import type { DatabaseSync } from "node:sqlite";
2
+ import type { ChatMessage, NewChatMessage, UpdateChatMessagePatch } from "./types.js";
3
+ export declare function listMessages(db: DatabaseSync, chatId: string): readonly ChatMessage[];
4
+ export declare function listMessagesLimited(db: DatabaseSync, chatId: string, limit: number): readonly ChatMessage[];
5
+ export declare function findMessageById(db: DatabaseSync, id: string): ChatMessage | undefined;
6
+ export declare function insertMessage(db: DatabaseSync, id: string, msg: NewChatMessage, redactString: (s: string) => string): ChatMessage;
7
+ export declare function updateMessage(db: DatabaseSync, id: string, patch: UpdateChatMessagePatch, redactString: (s: string) => string): ChatMessage;
8
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/store/messages.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EACV,WAAW,EAEX,cAAc,EACd,sBAAsB,EAEvB,MAAM,YAAY,CAAC;AA+GpB,wBAAgB,YAAY,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,WAAW,EAAE,CAErF;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,SAAS,WAAW,EAAE,CAOxB;AAED,wBAAgB,eAAe,CAAC,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAGrF;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,cAAc,EACnB,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAClC,WAAW,CAoBb;AAOD,wBAAgB,aAAa,CAC3B,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,sBAAsB,EAC7B,YAAY,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,GAClC,WAAW,CA6Bb"}
@@ -0,0 +1,149 @@
1
+ // ADR-0013 — chat_messages CRUD. shortResult is redacted+truncated to ≤ MAX_SHORT_RESULT before persist.
2
+ // Issue #66 adds:
3
+ // - `cancelled` to the accepted workflow status set (parity with src/ui/runs.ts RunStatus).
4
+ // - `task_type` column read/write so non-workflow runs (verify/explain-plan) can be labelled.
5
+ // - updateMessage(): partial PATCH on the row, re-using the existing redact+truncate path.
6
+ import { invalidRequest, notFound } from "./errors.js";
7
+ const MAX_SHORT_RESULT = 200;
8
+ const MAX_TASK_TYPE = 64;
9
+ // Constrained to a-z, digits, and a single inner `-` so the label remains URL-safe and survives
10
+ // a SQL round-trip. Identical to the rule the BFF descriptors use for taskType identifiers.
11
+ const TASK_TYPE_RE = /^[a-z][a-z0-9-]*$/;
12
+ const ROLES = new Set(["user", "assistant", "system"]);
13
+ const STATUSES = new Set([
14
+ "pending",
15
+ "running",
16
+ "completed",
17
+ "failed",
18
+ "cancelled",
19
+ ]);
20
+ function rowToMessage(row) {
21
+ return {
22
+ id: row.id,
23
+ chatId: row.chat_id,
24
+ role: row.role,
25
+ content: row.content,
26
+ timestamp: row.timestamp,
27
+ runId: row.run_id ?? undefined,
28
+ workflowId: row.workflow_id ?? undefined,
29
+ workflowStatus: (row.workflow_status ?? undefined),
30
+ shortResult: row.short_result ?? undefined,
31
+ taskType: row.task_type ?? undefined,
32
+ };
33
+ }
34
+ const COLUMNS = "id, chat_id, role, content, timestamp, run_id, workflow_id, workflow_status, short_result, task_type";
35
+ const SQL_LIST = `SELECT ${COLUMNS} FROM chat_messages WHERE chat_id = ? ORDER BY timestamp ASC, rowid ASC`;
36
+ const SQL_LIST_LIMITED = `${SQL_LIST} LIMIT ?`;
37
+ const SQL_FIND_BY_ID = `SELECT ${COLUMNS} FROM chat_messages WHERE id = ? LIMIT 1`;
38
+ const SQL_CHAT_EXISTS = "SELECT 1 FROM chats WHERE id = ?";
39
+ const SQL_INSERT = `
40
+ INSERT INTO chat_messages
41
+ (id, chat_id, role, content, timestamp, run_id, workflow_id, workflow_status, short_result, task_type)
42
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
43
+ RETURNING ${COLUMNS}
44
+ `;
45
+ function validateTaskType(value) {
46
+ if (value.length === 0 || value.length > MAX_TASK_TYPE || !TASK_TYPE_RE.test(value)) {
47
+ throw invalidRequest("Invalid taskType.");
48
+ }
49
+ }
50
+ function hasRunSummaryFields(msg) {
51
+ return (msg.runId !== undefined ||
52
+ msg.workflowId !== undefined ||
53
+ msg.workflowStatus !== undefined ||
54
+ msg.shortResult !== undefined ||
55
+ msg.taskType !== undefined);
56
+ }
57
+ function validateRunIdentifiers(msg) {
58
+ if (msg.runId?.length === 0) {
59
+ throw invalidRequest("runId is required for run summaries.");
60
+ }
61
+ if (msg.workflowId?.length === 0) {
62
+ throw invalidRequest("workflowId must be non-empty.");
63
+ }
64
+ }
65
+ function validateRunSummaryScope(msg) {
66
+ if (hasRunSummaryFields(msg) && (msg.role !== "system" || msg.runId === undefined)) {
67
+ throw invalidRequest("Run summary fields require a system message with runId.");
68
+ }
69
+ }
70
+ function validateMessage(msg) {
71
+ if (!ROLES.has(msg.role))
72
+ throw invalidRequest("Invalid role.");
73
+ if (msg.content.length === 0)
74
+ throw invalidRequest("Content is required.");
75
+ validateRunIdentifiers(msg);
76
+ validateRunSummaryScope(msg);
77
+ if (msg.workflowStatus !== undefined && !STATUSES.has(msg.workflowStatus)) {
78
+ throw invalidRequest("Invalid workflowStatus.");
79
+ }
80
+ if (msg.taskType !== undefined)
81
+ validateTaskType(msg.taskType);
82
+ }
83
+ function processShortResult(raw, redactString) {
84
+ if (raw === undefined)
85
+ return null;
86
+ const redacted = redactString(raw);
87
+ return redacted.length > MAX_SHORT_RESULT ? redacted.slice(0, MAX_SHORT_RESULT) : redacted;
88
+ }
89
+ export function listMessages(db, chatId) {
90
+ return db.prepare(SQL_LIST).all(chatId).map(rowToMessage);
91
+ }
92
+ export function listMessagesLimited(db, chatId, limit) {
93
+ if (!Number.isInteger(limit) || limit <= 0) {
94
+ throw invalidRequest("limit must be a positive integer.");
95
+ }
96
+ return db.prepare(SQL_LIST_LIMITED).all(chatId, limit).map(rowToMessage);
97
+ }
98
+ export function findMessageById(db, id) {
99
+ const row = db.prepare(SQL_FIND_BY_ID).get(id);
100
+ return row === undefined ? undefined : rowToMessage(row);
101
+ }
102
+ export function insertMessage(db, id, msg, redactString) {
103
+ validateMessage(msg);
104
+ const chatExists = db.prepare(SQL_CHAT_EXISTS).get(msg.chatId) !== undefined;
105
+ if (!chatExists)
106
+ throw notFound("Chat");
107
+ const shortResult = processShortResult(msg.shortResult, redactString);
108
+ const row = db
109
+ .prepare(SQL_INSERT)
110
+ .get(id, msg.chatId, msg.role, msg.content, msg.timestamp, msg.runId ?? null, msg.workflowId ?? null, msg.workflowStatus ?? null, shortResult, msg.taskType ?? null);
111
+ return rowToMessage(row);
112
+ }
113
+ // Issue #66 — Partial PATCH on a system run-summary message. Builds a dynamic SET clause from the
114
+ // supplied fields so absent fields are not overwritten. shortResult goes through the existing
115
+ // redact+truncate pipeline. workflowStatus and taskType are validated before SQL is built. An
116
+ // empty patch is an invalid_request — the route surface guards this earlier, but the store layer
117
+ // also fails-closed.
118
+ export function updateMessage(db, id, patch, redactString) {
119
+ const sets = [];
120
+ const args = [];
121
+ if (patch.workflowStatus !== undefined) {
122
+ if (!STATUSES.has(patch.workflowStatus))
123
+ throw invalidRequest("Invalid workflowStatus.");
124
+ sets.push("workflow_status = ?");
125
+ args.push(patch.workflowStatus);
126
+ }
127
+ if (patch.shortResult !== undefined) {
128
+ sets.push("short_result = ?");
129
+ args.push(processShortResult(patch.shortResult, redactString));
130
+ }
131
+ if (patch.taskType !== undefined) {
132
+ validateTaskType(patch.taskType);
133
+ sets.push("task_type = ?");
134
+ args.push(patch.taskType);
135
+ }
136
+ if (sets.length === 0) {
137
+ throw invalidRequest("PATCH body must include at least one updatable field.");
138
+ }
139
+ const sql = `
140
+ UPDATE chat_messages
141
+ SET ${sets.join(", ")}
142
+ WHERE id = ? AND role = 'system' AND run_id IS NOT NULL AND length(run_id) > 0
143
+ RETURNING ${COLUMNS}
144
+ `;
145
+ const row = db.prepare(sql).get(...args, id);
146
+ if (row === undefined)
147
+ throw notFound("Message");
148
+ return rowToMessage(row);
149
+ }
@@ -0,0 +1,5 @@
1
+ export declare const UI_DB_FILENAME = "keiko-ui.db";
2
+ export declare const UI_DB_DIRNAME = ".keiko";
3
+ export declare function resolveUiDbPath(explicit: string | undefined, env: Readonly<Record<string, string | undefined>>): string;
4
+ export declare function assertUiDbOutsideProject(uiDbPath: string | undefined, projectPath: string): void;
5
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/store/paths.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,cAAc,gBAAgB,CAAC;AAC5C,eAAO,MAAM,aAAa,WAAW,CAAC;AA4DtC,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAChD,MAAM,CASR;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAgBhG"}
@@ -0,0 +1,84 @@
1
+ // ADR-0013 D4 — resolveUiDbPath precedence (mirrors resolveEvidenceDir):
2
+ // explicit option → KEIKO_UI_DATA_DIR/keiko-ui.db → homedir()/.keiko/keiko-ui.db.
3
+ import { homedir } from "node:os";
4
+ import { existsSync, lstatSync } from "node:fs";
5
+ import { dirname, isAbsolute, join, normalize, parse, resolve, sep } from "node:path";
6
+ import { invalidRequest } from "./errors.js";
7
+ export const UI_DB_FILENAME = "keiko-ui.db";
8
+ export const UI_DB_DIRNAME = ".keiko";
9
+ function isInsideCurrentWorkingDirectory(path) {
10
+ const cwd = resolve(process.cwd());
11
+ const resolved = resolve(path);
12
+ return resolved === cwd || resolved.startsWith(`${cwd}${sep}`);
13
+ }
14
+ function isInsideRuntimeStateRoot(path, workspaceRoot) {
15
+ const runtimeRoot = resolve(workspaceRoot, UI_DB_DIRNAME);
16
+ const resolved = resolve(path);
17
+ return resolved === runtimeRoot || resolved.startsWith(`${runtimeRoot}${sep}`);
18
+ }
19
+ function hasSymlinkAncestor(path) {
20
+ let current = dirname(path);
21
+ const root = parse(current).root;
22
+ while (current !== root) {
23
+ if (existsSync(current)) {
24
+ return lstatSync(current).isSymbolicLink();
25
+ }
26
+ current = dirname(current);
27
+ }
28
+ return false;
29
+ }
30
+ function resolveConfiguredPath(path, label) {
31
+ // NUL bypass (CWE-22): path.normalize() leaves NUL bytes intact, so a string like
32
+ // "/safe/path\0/etc/passwd" satisfies the CWD-containment check but open(2) truncates
33
+ // at the NUL and lands on a completely different file. Reject NUL bytes first so the
34
+ // downstream guards reason about the same string the kernel will syscall on. Parity
35
+ // with the fix landed in packages/keiko-memory-vault/src/paths.ts (commit fbb90a88).
36
+ if (path.includes("\0")) {
37
+ throw invalidRequest(`${label} must not contain NUL bytes.`);
38
+ }
39
+ if (!isAbsolute(path)) {
40
+ throw invalidRequest(`${label} must be absolute.`);
41
+ }
42
+ const resolved = normalize(path);
43
+ if (isInsideCurrentWorkingDirectory(resolved) &&
44
+ !isInsideRuntimeStateRoot(resolved, process.cwd())) {
45
+ throw invalidRequest(`${label} must not be inside the current workspace.`);
46
+ }
47
+ if (existsSync(resolved) && lstatSync(resolved).isSymbolicLink()) {
48
+ throw invalidRequest(`${label} must not be a symlink.`);
49
+ }
50
+ if (hasSymlinkAncestor(resolved)) {
51
+ throw invalidRequest(`${label} must not be inside a symlinked directory.`);
52
+ }
53
+ return resolved;
54
+ }
55
+ function containsPath(parent, child) {
56
+ const resolvedParent = resolve(parent);
57
+ const resolvedChild = resolve(child);
58
+ return resolvedChild === resolvedParent || resolvedChild.startsWith(`${resolvedParent}${sep}`);
59
+ }
60
+ export function resolveUiDbPath(explicit, env) {
61
+ if (explicit !== undefined && explicit.length > 0) {
62
+ return resolveConfiguredPath(explicit, "UI database path");
63
+ }
64
+ const dir = env.KEIKO_UI_DATA_DIR;
65
+ if (dir !== undefined && dir.length > 0) {
66
+ return join(resolveConfiguredPath(dir, "KEIKO_UI_DATA_DIR"), UI_DB_FILENAME);
67
+ }
68
+ return join(homedir(), UI_DB_DIRNAME, UI_DB_FILENAME);
69
+ }
70
+ export function assertUiDbOutsideProject(uiDbPath, projectPath) {
71
+ if (uiDbPath === undefined || uiDbPath.length === 0) {
72
+ return;
73
+ }
74
+ const resolvedDbPath = resolve(uiDbPath);
75
+ const resolvedDbDir = dirname(resolvedDbPath);
76
+ const resolvedProject = resolve(projectPath);
77
+ if (containsPath(resolvedProject, resolvedDbPath) &&
78
+ !isInsideRuntimeStateRoot(resolvedDbPath, resolvedProject)) {
79
+ throw invalidRequest("UI database path must not be inside a selected project.");
80
+ }
81
+ if (containsPath(resolvedDbDir, resolvedProject)) {
82
+ throw invalidRequest("Selected projects must not be inside the UI database directory.");
83
+ }
84
+ }
@@ -0,0 +1,8 @@
1
+ import type { DatabaseSync } from "node:sqlite";
2
+ import type { Project, UpdateProjectPatch } from "./types.js";
3
+ export declare function listProjects(db: DatabaseSync): readonly Project[];
4
+ export declare function getProject(db: DatabaseSync, path: string): Project | undefined;
5
+ export declare function upsertProject(db: DatabaseSync, normalizedPath: string, name: string, hasExplicitName: boolean, now: number): Project;
6
+ export declare function updateProject(db: DatabaseSync, path: string, patch: UpdateProjectPatch, now: number): Project;
7
+ export declare function deleteProject(db: DatabaseSync, path: string): void;
8
+ //# sourceMappingURL=projects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"projects.d.ts","sourceRoot":"","sources":["../../src/store/projects.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA8C9D,wBAAgB,YAAY,CAAC,EAAE,EAAE,YAAY,GAAG,SAAS,OAAO,EAAE,CAEjE;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAG9E;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,YAAY,EAChB,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,MAAM,EACZ,eAAe,EAAE,OAAO,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAKT;AAED,wBAAgB,aAAa,CAC3B,EAAE,EAAE,YAAY,EAChB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,kBAAkB,EACzB,GAAG,EAAE,MAAM,GACV,OAAO,CAQT;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGlE"}
@@ -0,0 +1,59 @@
1
+ // ADR-0013 — projects CRUD. All SQL is module-scope constants; no string-interpolation into SQL.
2
+ import { notFound } from "./errors.js";
3
+ function rowToProject(row) {
4
+ return {
5
+ path: row.path,
6
+ name: row.name,
7
+ favorite: row.favorite !== 0,
8
+ createdAt: row.created_at,
9
+ lastOpenedAt: row.last_opened_at,
10
+ };
11
+ }
12
+ const SQL_LIST = "SELECT path, name, favorite, created_at, last_opened_at FROM projects ORDER BY path";
13
+ const SQL_GET = "SELECT path, name, favorite, created_at, last_opened_at FROM projects WHERE path = ?";
14
+ // UPSERT: if path already exists, bump last_opened_at; createdAt is preserved by ON CONFLICT DO UPDATE.
15
+ // A re-add with an explicit name repairs the display name; implicit basename derivation never
16
+ // overwrites a user-chosen existing name.
17
+ const SQL_UPSERT = `
18
+ INSERT INTO projects (path, name, favorite, created_at, last_opened_at)
19
+ VALUES (?, ?, 0, ?, ?)
20
+ ON CONFLICT(path) DO UPDATE SET
21
+ name = CASE WHEN ? THEN excluded.name ELSE name END,
22
+ last_opened_at = excluded.last_opened_at
23
+ RETURNING path, name, favorite, created_at, last_opened_at
24
+ `;
25
+ const SQL_UPDATE = `
26
+ UPDATE projects
27
+ SET name = COALESCE(?, name),
28
+ favorite = COALESCE(?, favorite),
29
+ last_opened_at = ?
30
+ WHERE path = ?
31
+ RETURNING path, name, favorite, created_at, last_opened_at
32
+ `;
33
+ const SQL_DELETE = "DELETE FROM projects WHERE path = ?";
34
+ export function listProjects(db) {
35
+ return db.prepare(SQL_LIST).all().map(rowToProject);
36
+ }
37
+ export function getProject(db, path) {
38
+ const row = db.prepare(SQL_GET).get(path);
39
+ return row === undefined ? undefined : rowToProject(row);
40
+ }
41
+ export function upsertProject(db, normalizedPath, name, hasExplicitName, now) {
42
+ const row = db
43
+ .prepare(SQL_UPSERT)
44
+ .get(normalizedPath, name, now, now, hasExplicitName ? 1 : 0);
45
+ return rowToProject(row);
46
+ }
47
+ export function updateProject(db, path, patch, now) {
48
+ const nameParam = patch.name ?? null;
49
+ const favoriteParam = patch.favorite === undefined ? null : patch.favorite ? 1 : 0;
50
+ const row = db.prepare(SQL_UPDATE).get(nameParam, favoriteParam, now, path);
51
+ if (row === undefined)
52
+ throw notFound("Project");
53
+ return rowToProject(row);
54
+ }
55
+ export function deleteProject(db, path) {
56
+ const info = db.prepare(SQL_DELETE).run(path);
57
+ if (info.changes === 0)
58
+ throw notFound("Project");
59
+ }
@@ -0,0 +1,42 @@
1
+ import type { DatabaseSync } from "node:sqlite";
2
+ export declare const RELATIONSHIP_AUDIT_SCHEMA_VERSION: "1";
3
+ export declare const RELATIONSHIP_AUDIT_SUMMARY_MAX_CHARS = 240;
4
+ export type RelationshipAuditKind = "relationship.created" | "relationship.updated" | "relationship.deleted" | "relationship.reconnected" | "relationship.validation-denied" | "relationship.policy-denied" | "relationship.activity-transitioned" | "relationship.impact-analysis-bounded" | "relationship.health-finding";
5
+ export type RelationshipAuditActorSurface = "chat" | "inspector" | "workflow" | "health-check" | "system";
6
+ export type RelationshipAuditPlacement = "sibling-table" | "evidence-manifest";
7
+ export interface RelationshipAuditEntryInput {
8
+ readonly eventId: string;
9
+ readonly workspaceId: string;
10
+ readonly occurredAt: number;
11
+ readonly kind: RelationshipAuditKind;
12
+ readonly relationshipId?: string | undefined;
13
+ readonly actor: {
14
+ readonly surface: RelationshipAuditActorSurface;
15
+ readonly redactedActorId: string;
16
+ };
17
+ readonly summary: string;
18
+ readonly payload: Readonly<Record<string, unknown>>;
19
+ }
20
+ export interface RelationshipAuditEntryRow {
21
+ readonly eventId: string;
22
+ readonly workspaceId: string;
23
+ readonly sequence: number;
24
+ readonly occurredAt: number;
25
+ readonly kind: RelationshipAuditKind;
26
+ readonly relationshipId: string | undefined;
27
+ readonly actorSurface: RelationshipAuditActorSurface;
28
+ readonly redactedActorId: string;
29
+ readonly redactionState: "redacted-on-write" | "redacted-on-write-and-persist";
30
+ readonly summary: string;
31
+ readonly payload: Readonly<Record<string, unknown>>;
32
+ }
33
+ export declare function resolveAuditPlacement(input: {
34
+ readonly kind: RelationshipAuditKind;
35
+ readonly sourceKind?: string | undefined;
36
+ }): RelationshipAuditPlacement;
37
+ export declare const MAX_AUDIT_LIST_LIMIT = 256;
38
+ export declare const DEFAULT_AUDIT_LIST_LIMIT = 64;
39
+ export declare function insertRelationshipAuditEntry(db: DatabaseSync, entry: RelationshipAuditEntryInput, redactString: (value: string) => string): RelationshipAuditEntryRow;
40
+ export declare function listRelationshipAuditEntries(db: DatabaseSync, workspaceId: string, limit?: number): readonly RelationshipAuditEntryRow[];
41
+ export declare function listRelationshipAuditEntriesForRelationship(db: DatabaseSync, workspaceId: string, relationshipId: string, limit?: number): readonly RelationshipAuditEntryRow[];
42
+ //# sourceMappingURL=relationship-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship-audit.d.ts","sourceRoot":"","sources":["../../src/store/relationship-audit.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAKhD,eAAO,MAAM,iCAAiC,EAAG,GAAY,CAAC;AAC9D,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAC7B,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,0BAA0B,GAC1B,gCAAgC,GAChC,4BAA4B,GAC5B,oCAAoC,GACpC,sCAAsC,GACtC,6BAA6B,CAAC;AAElC,MAAM,MAAM,6BAA6B,GACrC,MAAM,GACN,WAAW,GACX,UAAU,GACV,cAAc,GACd,QAAQ,CAAC;AAEb,MAAM,MAAM,0BAA0B,GAAG,eAAe,GAAG,mBAAmB,CAAC;AAE/E,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7C,QAAQ,CAAC,KAAK,EAAE;QACd,QAAQ,CAAC,OAAO,EAAE,6BAA6B,CAAC;QAChD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;KAClC,CAAC;IACF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,YAAY,EAAE,6BAA6B,CAAC;IACrD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,cAAc,EAAE,mBAAmB,GAAG,+BAA+B,CAAC;IAC/E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACrD;AAKD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE;IAC3C,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC1C,GAAG,0BAA0B,CAM7B;AAsCD,eAAO,MAAM,oBAAoB,MAAM,CAAC;AACxC,eAAO,MAAM,wBAAwB,KAAK,CAAC;AA2B3C,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,YAAY,EAChB,KAAK,EAAE,2BAA2B,EAClC,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACtC,yBAAyB,CA4C3B;AAoCD,wBAAgB,4BAA4B,CAC1C,EAAE,EAAE,YAAY,EAChB,WAAW,EAAE,MAAM,EACnB,KAAK,GAAE,MAAiC,GACvC,SAAS,yBAAyB,EAAE,CAMtC;AAED,wBAAgB,2CAA2C,CACzD,EAAE,EAAE,YAAY,EAChB,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,KAAK,GAAE,MAAiC,GACvC,SAAS,yBAAyB,EAAE,CAQtC"}