@oscharko-dev/keiko 0.2.10 → 0.2.11

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 (194) hide show
  1. package/dist/ui/csp-hashes.json +16 -16
  2. package/dist/ui/static/404.html +1 -1
  3. package/dist/ui/static/__next.__PAGE__.txt +2 -2
  4. package/dist/ui/static/__next._full.txt +3 -3
  5. package/dist/ui/static/__next._head.txt +1 -1
  6. package/dist/ui/static/__next._index.txt +2 -2
  7. package/dist/ui/static/__next._tree.txt +2 -2
  8. package/dist/ui/static/_next/static/chunks/{8824-59a261e25fd0a5d0.js → 8824-ea9436192826dccf.js} +7 -7
  9. package/dist/ui/static/_next/static/chunks/8835-9e566b40eb4e3499.js +1 -0
  10. package/dist/ui/static/_next/static/css/157df0cf8fc82126.css +3 -0
  11. package/dist/ui/static/_not-found/__next._full.txt +2 -2
  12. package/dist/ui/static/_not-found/__next._head.txt +1 -1
  13. package/dist/ui/static/_not-found/__next._index.txt +2 -2
  14. package/dist/ui/static/_not-found/__next._not-found.__PAGE__.txt +1 -1
  15. package/dist/ui/static/_not-found/__next._not-found.txt +1 -1
  16. package/dist/ui/static/_not-found/__next._tree.txt +2 -2
  17. package/dist/ui/static/_not-found.html +1 -1
  18. package/dist/ui/static/_not-found.txt +2 -2
  19. package/dist/ui/static/index.html +1 -1
  20. package/dist/ui/static/index.txt +3 -3
  21. package/dist/ui/static/launch/__next._full.txt +3 -3
  22. package/dist/ui/static/launch/__next._head.txt +1 -1
  23. package/dist/ui/static/launch/__next._index.txt +2 -2
  24. package/dist/ui/static/launch/__next._tree.txt +2 -2
  25. package/dist/ui/static/launch/__next.launch.__PAGE__.txt +2 -2
  26. package/dist/ui/static/launch/__next.launch.txt +1 -1
  27. package/dist/ui/static/launch.html +1 -1
  28. package/dist/ui/static/launch.txt +3 -3
  29. package/dist/ui/static/local-knowledge/__next._full.txt +3 -3
  30. package/dist/ui/static/local-knowledge/__next._head.txt +1 -1
  31. package/dist/ui/static/local-knowledge/__next._index.txt +2 -2
  32. package/dist/ui/static/local-knowledge/__next._tree.txt +2 -2
  33. package/dist/ui/static/local-knowledge/__next.local-knowledge.__PAGE__.txt +2 -2
  34. package/dist/ui/static/local-knowledge/__next.local-knowledge.txt +1 -1
  35. package/dist/ui/static/local-knowledge/capsule/__next._full.txt +3 -3
  36. package/dist/ui/static/local-knowledge/capsule/__next._head.txt +1 -1
  37. package/dist/ui/static/local-knowledge/capsule/__next._index.txt +2 -2
  38. package/dist/ui/static/local-knowledge/capsule/__next._tree.txt +2 -2
  39. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.__PAGE__.txt +2 -2
  40. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.capsule.txt +1 -1
  41. package/dist/ui/static/local-knowledge/capsule/__next.local-knowledge.txt +1 -1
  42. package/dist/ui/static/local-knowledge/capsule.html +1 -1
  43. package/dist/ui/static/local-knowledge/capsule.txt +3 -3
  44. package/dist/ui/static/local-knowledge.html +1 -1
  45. package/dist/ui/static/local-knowledge.txt +3 -3
  46. package/dist/ui/static/memoriaviva/__next._full.txt +2 -2
  47. package/dist/ui/static/memoriaviva/__next._head.txt +1 -1
  48. package/dist/ui/static/memoriaviva/__next._index.txt +2 -2
  49. package/dist/ui/static/memoriaviva/__next._tree.txt +2 -2
  50. package/dist/ui/static/memoriaviva/__next.memoriaviva.__PAGE__.txt +1 -1
  51. package/dist/ui/static/memoriaviva/__next.memoriaviva.txt +1 -1
  52. package/dist/ui/static/memoriaviva/consolidation/__next._full.txt +2 -2
  53. package/dist/ui/static/memoriaviva/consolidation/__next._head.txt +1 -1
  54. package/dist/ui/static/memoriaviva/consolidation/__next._index.txt +2 -2
  55. package/dist/ui/static/memoriaviva/consolidation/__next._tree.txt +2 -2
  56. package/dist/ui/static/memoriaviva/consolidation/__next.memoriaviva.consolidation.__PAGE__.txt +1 -1
  57. package/dist/ui/static/memoriaviva/consolidation/__next.memoriaviva.consolidation.txt +1 -1
  58. package/dist/ui/static/memoriaviva/consolidation/__next.memoriaviva.txt +1 -1
  59. package/dist/ui/static/memoriaviva/consolidation.html +1 -1
  60. package/dist/ui/static/memoriaviva/consolidation.txt +2 -2
  61. package/dist/ui/static/memoriaviva/detail/__next._full.txt +2 -2
  62. package/dist/ui/static/memoriaviva/detail/__next._head.txt +1 -1
  63. package/dist/ui/static/memoriaviva/detail/__next._index.txt +2 -2
  64. package/dist/ui/static/memoriaviva/detail/__next._tree.txt +2 -2
  65. package/dist/ui/static/memoriaviva/detail/__next.memoriaviva.detail.__PAGE__.txt +1 -1
  66. package/dist/ui/static/memoriaviva/detail/__next.memoriaviva.detail.txt +1 -1
  67. package/dist/ui/static/memoriaviva/detail/__next.memoriaviva.txt +1 -1
  68. package/dist/ui/static/memoriaviva/detail.html +1 -1
  69. package/dist/ui/static/memoriaviva/detail.txt +2 -2
  70. package/dist/ui/static/memoriaviva/review-queue/__next._full.txt +2 -2
  71. package/dist/ui/static/memoriaviva/review-queue/__next._head.txt +1 -1
  72. package/dist/ui/static/memoriaviva/review-queue/__next._index.txt +2 -2
  73. package/dist/ui/static/memoriaviva/review-queue/__next._tree.txt +2 -2
  74. package/dist/ui/static/memoriaviva/review-queue/__next.memoriaviva.review-queue.__PAGE__.txt +1 -1
  75. package/dist/ui/static/memoriaviva/review-queue/__next.memoriaviva.review-queue.txt +1 -1
  76. package/dist/ui/static/memoriaviva/review-queue/__next.memoriaviva.txt +1 -1
  77. package/dist/ui/static/memoriaviva/review-queue.html +1 -1
  78. package/dist/ui/static/memoriaviva/review-queue.txt +2 -2
  79. package/dist/ui/static/memoriaviva.html +1 -1
  80. package/dist/ui/static/memoriaviva.txt +2 -2
  81. package/node_modules/@oscharko-dev/keiko-cli/dist/.tsbuildinfo +1 -1
  82. package/node_modules/@oscharko-dev/keiko-cli/dist/prompt-enhancer.d.ts +4 -2
  83. package/node_modules/@oscharko-dev/keiko-cli/dist/prompt-enhancer.d.ts.map +1 -1
  84. package/node_modules/@oscharko-dev/keiko-cli/dist/prompt-enhancer.js +51 -28
  85. package/node_modules/@oscharko-dev/keiko-cli/package.json +14 -14
  86. package/node_modules/@oscharko-dev/keiko-contracts/dist/.tsbuildinfo +1 -1
  87. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts +1 -1
  88. package/node_modules/@oscharko-dev/keiko-contracts/dist/bff-wire.d.ts.map +1 -1
  89. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts +3 -3
  90. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.d.ts.map +1 -1
  91. package/node_modules/@oscharko-dev/keiko-contracts/dist/index.js +1 -1
  92. package/node_modules/@oscharko-dev/keiko-contracts/dist/prompt-enhancer-analyzer.d.ts.map +1 -1
  93. package/node_modules/@oscharko-dev/keiko-contracts/dist/prompt-enhancer-analyzer.js +43 -1
  94. package/node_modules/@oscharko-dev/keiko-contracts/dist/prompt-enhancer-bff.d.ts +5 -1
  95. package/node_modules/@oscharko-dev/keiko-contracts/dist/prompt-enhancer-bff.d.ts.map +1 -1
  96. package/node_modules/@oscharko-dev/keiko-contracts/dist/prompt-enhancer-bff.js +6 -6
  97. package/node_modules/@oscharko-dev/keiko-contracts/dist/qualityIntelligence/bffWire.d.ts +66 -0
  98. package/node_modules/@oscharko-dev/keiko-contracts/dist/qualityIntelligence/bffWire.d.ts.map +1 -1
  99. package/node_modules/@oscharko-dev/keiko-contracts/dist/qualityIntelligence/index.d.ts +1 -1
  100. package/node_modules/@oscharko-dev/keiko-contracts/dist/qualityIntelligence/index.d.ts.map +1 -1
  101. package/node_modules/@oscharko-dev/keiko-contracts/package.json +1 -1
  102. package/node_modules/@oscharko-dev/keiko-evaluations/dist/.tsbuildinfo +1 -1
  103. package/node_modules/@oscharko-dev/keiko-evaluations/package.json +9 -9
  104. package/node_modules/@oscharko-dev/keiko-evidence/dist/.tsbuildinfo +1 -1
  105. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/manifestSchema.d.ts +3 -0
  106. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/manifestSchema.d.ts.map +1 -1
  107. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/manifestSchema.js +1 -0
  108. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/store.d.ts +2 -0
  109. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/store.d.ts.map +1 -1
  110. package/node_modules/@oscharko-dev/keiko-evidence/dist/qualityIntelligence/store.js +3 -0
  111. package/node_modules/@oscharko-dev/keiko-evidence/package.json +4 -4
  112. package/node_modules/@oscharko-dev/keiko-harness/dist/.tsbuildinfo +1 -1
  113. package/node_modules/@oscharko-dev/keiko-harness/package.json +6 -6
  114. package/node_modules/@oscharko-dev/keiko-local-knowledge/dist/.tsbuildinfo +1 -1
  115. package/node_modules/@oscharko-dev/keiko-local-knowledge/package.json +5 -5
  116. package/node_modules/@oscharko-dev/keiko-memory-capture/package.json +3 -3
  117. package/node_modules/@oscharko-dev/keiko-memory-consolidation/package.json +3 -3
  118. package/node_modules/@oscharko-dev/keiko-memory-governance/package.json +3 -3
  119. package/node_modules/@oscharko-dev/keiko-memory-retrieval/package.json +3 -3
  120. package/node_modules/@oscharko-dev/keiko-memory-vault/dist/.tsbuildinfo +1 -1
  121. package/node_modules/@oscharko-dev/keiko-memory-vault/package.json +3 -3
  122. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/.tsbuildinfo +1 -1
  123. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/index.js +2 -2
  124. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/promptEnhancer/generator.d.ts.map +1 -1
  125. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/promptEnhancer/generator.js +210 -21
  126. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/promptEnhancer/index.d.ts.map +1 -1
  127. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/promptEnhancer/index.js +2 -3
  128. package/node_modules/@oscharko-dev/keiko-model-gateway/dist/promptEnhancer/rendering.js +1 -1
  129. package/node_modules/@oscharko-dev/keiko-model-gateway/package.json +3 -3
  130. package/node_modules/@oscharko-dev/keiko-quality-intelligence/dist/.tsbuildinfo +1 -1
  131. package/node_modules/@oscharko-dev/keiko-quality-intelligence/dist/domain/testDesignModel.d.ts.map +1 -1
  132. package/node_modules/@oscharko-dev/keiko-quality-intelligence/dist/domain/testDesignModel.js +3 -0
  133. package/node_modules/@oscharko-dev/keiko-quality-intelligence/package.json +3 -3
  134. package/node_modules/@oscharko-dev/keiko-sandbox/dist/.tsbuildinfo +1 -1
  135. package/node_modules/@oscharko-dev/keiko-sandbox/package.json +2 -2
  136. package/node_modules/@oscharko-dev/keiko-sdk/dist/.tsbuildinfo +1 -1
  137. package/node_modules/@oscharko-dev/keiko-sdk/package.json +9 -9
  138. package/node_modules/@oscharko-dev/keiko-security/dist/.tsbuildinfo +1 -1
  139. package/node_modules/@oscharko-dev/keiko-security/package.json +2 -2
  140. package/node_modules/@oscharko-dev/keiko-server/dist/.tsbuildinfo +1 -1
  141. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-delivery.d.ts +11 -1
  142. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-delivery.d.ts.map +1 -1
  143. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-delivery.js +94 -18
  144. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-handlers.d.ts.map +1 -1
  145. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-handlers.js +52 -21
  146. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-service.d.ts.map +1 -1
  147. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-service.js +22 -1
  148. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-session-manager.d.ts +3 -1
  149. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-session-manager.d.ts.map +1 -1
  150. package/node_modules/@oscharko-dev/keiko-server/dist/local-knowledge-preview-session-manager.js +5 -2
  151. package/node_modules/@oscharko-dev/keiko-server/dist/promptEnhancer/routes.d.ts.map +1 -1
  152. package/node_modules/@oscharko-dev/keiko-server/dist/promptEnhancer/routes.js +4 -2
  153. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.d.ts.map +1 -1
  154. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/handoffRoutes.js +16 -9
  155. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/index.d.ts +1 -0
  156. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/index.d.ts.map +1 -1
  157. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/index.js +1 -0
  158. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.d.ts +16 -0
  159. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.d.ts.map +1 -0
  160. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelPolicyRoutes.js +368 -0
  161. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelSelection.d.ts +15 -0
  162. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelSelection.d.ts.map +1 -1
  163. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/modelSelection.js +187 -13
  164. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runExecution.d.ts +3 -0
  165. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runExecution.d.ts.map +1 -1
  166. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runExecution.js +82 -24
  167. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.d.ts +2 -2
  168. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.d.ts.map +1 -1
  169. package/node_modules/@oscharko-dev/keiko-server/dist/qualityIntelligence/runRoutes.js +53 -6
  170. package/node_modules/@oscharko-dev/keiko-server/dist/routes.d.ts.map +1 -1
  171. package/node_modules/@oscharko-dev/keiko-server/dist/routes.js +3 -1
  172. package/node_modules/@oscharko-dev/keiko-server/package.json +19 -19
  173. package/node_modules/@oscharko-dev/keiko-tools/dist/.tsbuildinfo +1 -1
  174. package/node_modules/@oscharko-dev/keiko-tools/package.json +5 -5
  175. package/node_modules/@oscharko-dev/keiko-verification/dist/.tsbuildinfo +1 -1
  176. package/node_modules/@oscharko-dev/keiko-verification/package.json +5 -5
  177. package/node_modules/@oscharko-dev/keiko-workflows/dist/.tsbuildinfo +1 -1
  178. package/node_modules/@oscharko-dev/keiko-workflows/dist/promptEnhancer/index.d.ts +3 -1
  179. package/node_modules/@oscharko-dev/keiko-workflows/dist/promptEnhancer/index.d.ts.map +1 -1
  180. package/node_modules/@oscharko-dev/keiko-workflows/dist/promptEnhancer/index.js +284 -39
  181. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/modelRoutedTestDesign.d.ts +1 -0
  182. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/modelRoutedTestDesign.d.ts.map +1 -1
  183. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/modelRoutedTestDesign.js +26 -7
  184. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/runtimeCommon.d.ts +2 -0
  185. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/runtimeCommon.d.ts.map +1 -1
  186. package/node_modules/@oscharko-dev/keiko-workflows/dist/qualityIntelligence/runtimeCommon.js +27 -1
  187. package/node_modules/@oscharko-dev/keiko-workflows/package.json +10 -10
  188. package/node_modules/@oscharko-dev/keiko-workspace/dist/.tsbuildinfo +1 -1
  189. package/node_modules/@oscharko-dev/keiko-workspace/package.json +3 -3
  190. package/package.json +22 -22
  191. package/dist/ui/static/_next/static/chunks/8835-0b991bfcb0308e77.js +0 -1
  192. package/dist/ui/static/_next/static/css/a44f4ffb37299b42.css +0 -3
  193. /package/dist/ui/static/_next/static/{WGuvz70_f_uiVSiv-B1wx → 7prMhE-UoHxL8LG_0obLN}/_buildManifest.js +0 -0
  194. /package/dist/ui/static/_next/static/{WGuvz70_f_uiVSiv-B1wx → 7prMhE-UoHxL8LG_0obLN}/_ssgManifest.js +0 -0
@@ -5,12 +5,22 @@ export declare const MAX_PDF_PREVIEW_BYTES: number;
5
5
  export declare const MAX_PDF_PREVIEW_RANGE_BYTES: number;
6
6
  type PreviewSourceResult = {
7
7
  readonly kind: "ok";
8
- readonly bytes: Uint8Array;
9
8
  readonly fileName: string;
9
+ readonly source: PdfCitationPreviewSource;
10
10
  } | {
11
11
  readonly kind: "rejected";
12
12
  readonly reason: PdfCitationPreviewReasonCode;
13
13
  };
14
+ export interface PdfCitationPreviewSource {
15
+ readonly absolutePath: string;
16
+ readonly byteLength: number;
17
+ readonly contentHash: string;
18
+ readonly fileName: string;
19
+ readonly mtimeMs?: number | undefined;
20
+ }
14
21
  export declare function loadVerifiedPdfPreviewSource(deps: UiHandlerDeps, authority: PdfCitationPreviewAuthority): Promise<PreviewSourceResult>;
22
+ export declare function loadPdfPreviewSourceForSession(deps: UiHandlerDeps, authority: PdfCitationPreviewAuthority, expected: PdfCitationPreviewSource): PreviewSourceResult;
23
+ export declare function readPdfPreviewSourceRange(source: PdfCitationPreviewSource, start: number, length: number): Promise<Uint8Array | undefined>;
24
+ export declare function pdfPreviewStreamChunkBytes(): number;
15
25
  export {};
16
26
  //# sourceMappingURL=local-knowledge-preview-delivery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"local-knowledge-preview-delivery.d.ts","sourceRoot":"","sources":["../src/local-knowledge-preview-delivery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,+BAA+B,CAAC;AAKvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE/C,OAAO,KAAK,EAAE,2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AM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC;AA0LD,wBAAsB,4BAA4B,CAChD,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,2BAA2B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAc9B;AAcD,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,aAAa,EACnB,SAAS,EAAE,2BAA2B,EACtC,QAAQ,EAAE,wBAAwB,GACjC,mBAAmB,CAmBrB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,wBAAwB,EAChC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAOjC;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAEnD"}
@@ -4,11 +4,10 @@ import { listCapsuleSources } from "@oscharko-dev/keiko-local-knowledge";
4
4
  import { containedRealPathInfo, isDenied } from "@oscharko-dev/keiko-workspace";
5
5
  import { nodeWorkspaceFs } from "@oscharko-dev/keiko-workspace/internal/fs";
6
6
  import { openStoreForDeps } from "./local-knowledge-grounded-qa.js";
7
- export const MAX_PDF_PREVIEW_BYTES = 32 * 1024 * 1024;
7
+ export const MAX_PDF_PREVIEW_BYTES = 1024 * 1024 * 1024;
8
8
  export const MAX_PDF_PREVIEW_RANGE_BYTES = 4 * 1024 * 1024;
9
- function sha256Hex(bytes) {
10
- return createHash("sha256").update(bytes).digest("hex");
11
- }
9
+ const PDF_PREVIEW_HASH_CHUNK_BYTES = 8 * 1024 * 1024;
10
+ const PDF_PREVIEW_STREAM_CHUNK_BYTES = 512 * 1024;
12
11
  function sourceRoot(scope) {
13
12
  return scope.kind === "folder" || scope.kind === "files" ? scope.rootPath : scope.repositoryRoot;
14
13
  }
@@ -44,7 +43,7 @@ function verifySourcePath(source, documentPath) {
44
43
  }
45
44
  return contained.path;
46
45
  }
47
- async function readSourceBytes(absolutePath, maxBytes) {
46
+ function statSafeSource(absolutePath) {
48
47
  let stat;
49
48
  try {
50
49
  stat = nodeWorkspaceFs.stat(absolutePath);
@@ -55,11 +54,21 @@ async function readSourceBytes(absolutePath, maxBytes) {
55
54
  if (!stat.isFile || stat.isSymbolicLink || (stat.hardLinkCount ?? 1) > 1) {
56
55
  return undefined;
57
56
  }
58
- if (stat.size > maxBytes) {
59
- return new Uint8Array(maxBytes + 1);
60
- }
61
- const bytes = await nodeWorkspaceFs.readFileBytes?.(absolutePath, stat.size);
62
- return bytes;
57
+ return stat;
58
+ }
59
+ async function sha256SourceHex(absolutePath, byteLength) {
60
+ const readRange = nodeWorkspaceFs.readFileRange;
61
+ if (readRange === undefined)
62
+ return undefined;
63
+ const hash = createHash("sha256");
64
+ for (let offset = 0; offset < byteLength; offset += PDF_PREVIEW_HASH_CHUNK_BYTES) {
65
+ const length = Math.min(PDF_PREVIEW_HASH_CHUNK_BYTES, byteLength - offset);
66
+ const bytes = await readRange(absolutePath, offset, length);
67
+ if (bytes.byteLength !== length)
68
+ return undefined;
69
+ hash.update(bytes);
70
+ }
71
+ return hash.digest("hex");
63
72
  }
64
73
  function loadCurrentDocument(deps, authority) {
65
74
  const session = openStoreForDeps(deps);
@@ -89,9 +98,15 @@ function validateDocumentMetadata(authority, document) {
89
98
  if (document.media_type !== "application/pdf") {
90
99
  return "document-not-pdf";
91
100
  }
101
+ if (document.content_hash !== citation.documentContentHash) {
102
+ return "document-content-mismatch";
103
+ }
104
+ if (document.size_bytes > MAX_PDF_PREVIEW_BYTES) {
105
+ return "preview-source-oversized";
106
+ }
92
107
  return undefined;
93
108
  }
94
- async function loadVerifiedSourceBytes(authority, document, sources) {
109
+ function resolveCurrentSource(authority, document, sources) {
95
110
  const source = resolveSource(sources, authority.citation.lineage.sourceId);
96
111
  if (source === undefined) {
97
112
  return { kind: "rejected", reason: "preview-source-missing" };
@@ -100,18 +115,40 @@ async function loadVerifiedSourceBytes(authority, document, sources) {
100
115
  if (absolutePath === undefined || !nodeWorkspaceFs.exists(absolutePath)) {
101
116
  return { kind: "rejected", reason: "preview-source-missing" };
102
117
  }
103
- const bytes = await readSourceBytes(absolutePath, MAX_PDF_PREVIEW_BYTES);
104
- if (bytes === undefined) {
118
+ const stat = statSafeSource(absolutePath);
119
+ if (stat === undefined) {
105
120
  return { kind: "rejected", reason: "preview-source-unreadable" };
106
121
  }
107
- if (bytes.byteLength > MAX_PDF_PREVIEW_BYTES) {
122
+ if (stat.size > MAX_PDF_PREVIEW_BYTES) {
108
123
  return { kind: "rejected", reason: "preview-source-oversized" };
109
124
  }
110
- const expectedHash = authority.citation.documentContentHash;
111
- if (document.content_hash !== expectedHash || sha256Hex(bytes) !== expectedHash) {
125
+ if (stat.size !== document.size_bytes) {
126
+ return { kind: "rejected", reason: "document-content-mismatch" };
127
+ }
128
+ return {
129
+ kind: "ok",
130
+ fileName: document.safe_display_name,
131
+ source: {
132
+ absolutePath,
133
+ byteLength: stat.size,
134
+ contentHash: document.content_hash,
135
+ fileName: document.safe_display_name,
136
+ ...(stat.mtimeMs === undefined ? {} : { mtimeMs: stat.mtimeMs }),
137
+ },
138
+ };
139
+ }
140
+ async function loadVerifiedSource(authority, document, sources) {
141
+ const resolved = resolveCurrentSource(authority, document, sources);
142
+ if (resolved.kind !== "ok")
143
+ return resolved;
144
+ const actualHash = await sha256SourceHex(resolved.source.absolutePath, resolved.source.byteLength);
145
+ if (actualHash === undefined) {
146
+ return { kind: "rejected", reason: "preview-source-unreadable" };
147
+ }
148
+ if (actualHash !== resolved.source.contentHash) {
112
149
  return { kind: "rejected", reason: "document-content-mismatch" };
113
150
  }
114
- return { kind: "ok", bytes, fileName: document.safe_display_name };
151
+ return resolved;
115
152
  }
116
153
  export async function loadVerifiedPdfPreviewSource(deps, authority) {
117
154
  const current = loadCurrentDocument(deps, authority);
@@ -123,9 +160,48 @@ export async function loadVerifiedPdfPreviewSource(deps, authority) {
123
160
  if (current.document === undefined) {
124
161
  return { kind: "rejected", reason: "preview-source-missing" };
125
162
  }
126
- return await loadVerifiedSourceBytes(authority, current.document, current.sources);
163
+ return await loadVerifiedSource(authority, current.document, current.sources);
164
+ }
165
+ finally {
166
+ current.close();
167
+ }
168
+ }
169
+ function sourceMatchesSession(current, expected) {
170
+ return (current.absolutePath === expected.absolutePath &&
171
+ current.byteLength === expected.byteLength &&
172
+ current.contentHash === expected.contentHash &&
173
+ current.mtimeMs === expected.mtimeMs);
174
+ }
175
+ export function loadPdfPreviewSourceForSession(deps, authority, expected) {
176
+ const current = loadCurrentDocument(deps, authority);
177
+ try {
178
+ const metadataFailure = validateDocumentMetadata(authority, current.document);
179
+ if (metadataFailure !== undefined) {
180
+ return { kind: "rejected", reason: metadataFailure };
181
+ }
182
+ if (current.document === undefined) {
183
+ return { kind: "rejected", reason: "preview-source-missing" };
184
+ }
185
+ const resolved = resolveCurrentSource(authority, current.document, current.sources);
186
+ if (resolved.kind !== "ok")
187
+ return resolved;
188
+ if (!sourceMatchesSession(resolved.source, expected)) {
189
+ return { kind: "rejected", reason: "document-content-mismatch" };
190
+ }
191
+ return resolved;
127
192
  }
128
193
  finally {
129
194
  current.close();
130
195
  }
131
196
  }
197
+ export async function readPdfPreviewSourceRange(source, start, length) {
198
+ const boundedLength = Math.min(length, PDF_PREVIEW_STREAM_CHUNK_BYTES);
199
+ const bytes = await nodeWorkspaceFs.readFileRange?.(source.absolutePath, start, boundedLength);
200
+ if (bytes?.byteLength !== boundedLength) {
201
+ return undefined;
202
+ }
203
+ return bytes;
204
+ }
205
+ export function pdfPreviewStreamChunkBytes() {
206
+ return PDF_PREVIEW_STREAM_CHUNK_BYTES;
207
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"local-knowledge-preview-handlers.d.ts","sourceRoot":"","sources":["../src/local-knowledge-preview-handlers.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA2O7E,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAsGD,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,CAsBzB;AAED,wBAAgB,oCAAoC,CAClD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,WAAW,CAOb"}
1
+ {"version":3,"file":"local-knowledge-preview-handlers.d.ts","sourceRoot":"","sources":["../src/local-knowledge-preview-handlers.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AA0Q7E,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAgBtB;AAED,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,WAAW,CAAC,CAsBtB;AA8HD,wBAAsB,mCAAmC,CACvD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,OAAO,CAAC,cAAc,CAAC,CA0BzB;AAED,wBAAgB,oCAAoC,CAClD,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,aAAa,GAClB,WAAW,CAOb"}
@@ -2,7 +2,7 @@ import { pdfCitationPreviewFailureState } from "@oscharko-dev/keiko-contracts";
2
2
  import { STREAMING, errorBody } from "./routes.js";
3
3
  import { authorizePdfCitationPreview, getPdfCitationPreviewStatus, projectPdfCitationPreviewAuthorizationResponse, } from "./local-knowledge-preview-service.js";
4
4
  import { normalizePreviewMarkerIndex } from "./local-knowledge-preview-authority.js";
5
- import { loadVerifiedPdfPreviewSource, MAX_PDF_PREVIEW_RANGE_BYTES } from "./local-knowledge-preview-delivery.js";
5
+ import { loadPdfPreviewSourceForSession, loadVerifiedPdfPreviewSource, MAX_PDF_PREVIEW_RANGE_BYTES, pdfPreviewStreamChunkBytes, readPdfPreviewSourceRange, } from "./local-knowledge-preview-delivery.js";
6
6
  import { previewSessionManagerFor } from "./local-knowledge-preview-session-manager.js";
7
7
  const MAX_BODY_BYTES = 16_000;
8
8
  class InvalidRequest extends Error {
@@ -46,14 +46,13 @@ async function readJsonObject(req) {
46
46
  }
47
47
  function parseBaseBody(body) {
48
48
  if (typeof body.chatId !== "string" || body.chatId.trim().length === 0) {
49
- throw new InvalidRequest("Field \"chatId\" must be a non-empty string.");
49
+ throw new InvalidRequest('Field "chatId" must be a non-empty string.');
50
50
  }
51
- if (typeof body.assistantMessageId !== "string" ||
52
- body.assistantMessageId.trim().length === 0) {
53
- throw new InvalidRequest("Field \"assistantMessageId\" must be a non-empty string.");
51
+ if (typeof body.assistantMessageId !== "string" || body.assistantMessageId.trim().length === 0) {
52
+ throw new InvalidRequest('Field "assistantMessageId" must be a non-empty string.');
54
53
  }
55
54
  if (body.stableId !== undefined && typeof body.stableId !== "string") {
56
- throw new InvalidRequest("Field \"stableId\" must be a string when present.");
55
+ throw new InvalidRequest('Field "stableId" must be a string when present.');
57
56
  }
58
57
  return {
59
58
  chatId: body.chatId,
@@ -64,16 +63,16 @@ function parseBaseBody(body) {
64
63
  function parseMarker(body, required) {
65
64
  if (!("marker" in body)) {
66
65
  if (required) {
67
- throw new InvalidRequest("Field \"marker\" is required.");
66
+ throw new InvalidRequest('Field "marker" is required.');
68
67
  }
69
68
  return undefined;
70
69
  }
71
70
  const marker = body.marker;
72
71
  if (typeof marker !== "string" && typeof marker !== "number") {
73
- throw new InvalidRequest("Field \"marker\" must be a string or number.");
72
+ throw new InvalidRequest('Field "marker" must be a string or number.');
74
73
  }
75
74
  if (normalizePreviewMarkerIndex(marker) === undefined) {
76
- throw new InvalidRequest("Field \"marker\" must resolve to a positive citation index.");
75
+ throw new InvalidRequest('Field "marker" must resolve to a positive citation index.');
77
76
  }
78
77
  return marker;
79
78
  }
@@ -165,7 +164,11 @@ function parsedRangeValues(startRaw, endRaw, totalBytes) {
165
164
  parseSuffixRange(endRaw, totalBytes));
166
165
  }
167
166
  function validatedRange(start, end, totalBytes) {
168
- if (!Number.isInteger(start) || !Number.isInteger(end) || start < 0 || end < start || start >= totalBytes) {
167
+ if (!Number.isInteger(start) ||
168
+ !Number.isInteger(end) ||
169
+ start < 0 ||
170
+ end < start ||
171
+ start >= totalBytes) {
169
172
  return invalidRangeResult("The requested byte range is invalid.");
170
173
  }
171
174
  const boundedEnd = Math.min(end, totalBytes - 1);
@@ -176,6 +179,9 @@ function validatedRange(start, end, totalBytes) {
176
179
  }
177
180
  function parseRangeHeader(header, totalBytes) {
178
181
  if (header === undefined) {
182
+ if (totalBytes <= 0) {
183
+ return invalidRangeResult("The requested byte range is invalid.");
184
+ }
179
185
  return { start: 0, end: totalBytes - 1 };
180
186
  }
181
187
  const match = /^bytes=(\d*)-(\d*)$/u.exec(header.trim());
@@ -234,8 +240,8 @@ export async function handleOpenPdfCitationPreviewSession(ctx, deps) {
234
240
  if (verified.kind !== "ok") {
235
241
  return rejectedOpenResult(verified.reason, authorized.display);
236
242
  }
237
- const opened = previewSessionManagerFor(deps).openSession(authorized.authority);
238
- return openSessionResult(authorized.display, opened, verified.bytes.byteLength);
243
+ const opened = previewSessionManagerFor(deps).openSession(authorized.authority, verified.source);
244
+ return openSessionResult(authorized.display, opened, verified.source.byteLength);
239
245
  }
240
246
  catch (error) {
241
247
  if (error instanceof InvalidRequest) {
@@ -303,20 +309,45 @@ function sessionLookupResult(deps, sessionHandle) {
303
309
  function isRouteResult(value) {
304
310
  return typeof value === "object" && value !== null && "status" in value;
305
311
  }
306
- function streamPdfPreview(ctx, bytes, range) {
307
- const isPartial = range.start !== 0 || range.end !== bytes.byteLength - 1;
308
- const chunk = bytes.subarray(range.start, range.end + 1);
312
+ async function writeResponseChunk(ctx, chunk) {
313
+ const isConnectionDestroyed = () => ctx.res.destroyed || ctx.req.destroyed;
314
+ if (isConnectionDestroyed())
315
+ return false;
316
+ if (ctx.res.write(Buffer.from(chunk))) {
317
+ return true;
318
+ }
319
+ await new Promise((resolve) => {
320
+ ctx.res.once("drain", resolve);
321
+ });
322
+ return !isConnectionDestroyed();
323
+ }
324
+ async function streamPdfPreview(ctx, source, range) {
325
+ const isPartial = range.start !== 0 || range.end !== source.byteLength - 1;
326
+ const contentLength = range.end - range.start + 1;
309
327
  ctx.res.writeHead(isPartial ? 206 : 200, {
310
328
  "Accept-Ranges": "bytes",
311
329
  "Cache-Control": "no-store",
312
- "Content-Length": String(chunk.byteLength),
330
+ "Content-Length": String(contentLength),
313
331
  "Content-Type": "application/pdf",
314
332
  ...(isPartial
315
- ? { "Content-Range": `bytes ${String(range.start)}-${String(range.end)}/${String(bytes.byteLength)}` }
333
+ ? {
334
+ "Content-Range": `bytes ${String(range.start)}-${String(range.end)}/${String(source.byteLength)}`,
335
+ }
316
336
  : {}),
317
337
  "X-Content-Type-Options": "nosniff",
318
338
  });
319
- ctx.res.end(Buffer.from(chunk));
339
+ for (let offset = range.start; offset <= range.end; offset += pdfPreviewStreamChunkBytes()) {
340
+ const length = Math.min(pdfPreviewStreamChunkBytes(), range.end - offset + 1);
341
+ const chunk = await readPdfPreviewSourceRange(source, offset, length);
342
+ if (chunk === undefined) {
343
+ ctx.res.destroy(new Error("Verified PDF preview source could not be read."));
344
+ return STREAMING;
345
+ }
346
+ const keepGoing = await writeResponseChunk(ctx, chunk);
347
+ if (!keepGoing)
348
+ return STREAMING;
349
+ }
350
+ ctx.res.end();
320
351
  return STREAMING;
321
352
  }
322
353
  export async function handleGetPdfCitationPreviewDocument(ctx, deps) {
@@ -328,16 +359,16 @@ export async function handleGetPdfCitationPreviewDocument(ctx, deps) {
328
359
  if (isRouteResult(lookup)) {
329
360
  return lookup;
330
361
  }
331
- const verified = await loadVerifiedPdfPreviewSource(deps, lookup.session.authority);
362
+ const verified = loadPdfPreviewSourceForSession(deps, lookup.session.authority, lookup.session.source);
332
363
  if (verified.kind !== "ok") {
333
364
  return previewSourceError(verified.reason);
334
365
  }
335
366
  const rangeHeader = ctx.req.headers.range;
336
- const parsedRange = parseRangeHeader(typeof rangeHeader === "string" ? rangeHeader : rangeHeader?.[0], verified.bytes.byteLength);
367
+ const parsedRange = parseRangeHeader(typeof rangeHeader === "string" ? rangeHeader : rangeHeader?.[0], verified.source.byteLength);
337
368
  if ("status" in parsedRange) {
338
369
  return parsedRange;
339
370
  }
340
- return streamPdfPreview(ctx, verified.bytes, parsedRange);
371
+ return streamPdfPreview(ctx, verified.source, parsedRange);
341
372
  }
342
373
  export function handleClosePdfCitationPreviewSession(ctx, deps) {
343
374
  const sessionHandle = sessionHandleFromContext(ctx);
@@ -1 +1 @@
1
- {"version":3,"file":"local-knowledge-preview-service.d.ts","sourceRoot":"","sources":["../src/local-knowledge-preview-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iCAAiC,EACjC,uCAAuC,EAEvC,yBAAyB,EACzB,4BAA4B,EAC5B,2BAA2B,EAC3B,+BAA+B,EAC/B,gCAAgC,EAChC,gCAAgC,EAEjC,MAAM,+BAA+B,CAAC;AAQvC,OAAO,KAAK,E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uCvC;AAED,wBAAgB,8CAA8C,CAC5D,MAAM,EAAE,qCAAqC,GAC5C,uCAAuC,CAKzC"}
@@ -46,15 +46,36 @@ function selectedCitations(citations, marker, stableId) {
46
46
  return reject("citation-not-found");
47
47
  }
48
48
  }
49
- if (stableId !== undefined && selected.length === 1) {
49
+ selected = uniqueSelectedCitations(selected);
50
+ if (stableId !== undefined) {
50
51
  const stableMatches = selected.filter((citation) => citation.stableId === stableId);
51
52
  if (stableMatches.length === 0) {
53
+ if (selected.length === 1) {
54
+ return { kind: "selected", citations: selected };
55
+ }
52
56
  return reject("stable-id-mismatch", selected[0] === undefined ? undefined : citationDisplay(selected[0]), selected);
53
57
  }
54
58
  selected = stableMatches;
55
59
  }
56
60
  return { kind: "selected", citations: selected };
57
61
  }
62
+ function citationSelectionKey(citation) {
63
+ return JSON.stringify({
64
+ stableId: citation.stableId,
65
+ markerIndex: citation.markerIndex,
66
+ capsuleId: citation.lineage.capsuleId,
67
+ sourceId: citation.lineage.sourceId,
68
+ documentId: citation.lineage.documentId,
69
+ chunkId: citation.lineage.chunkId,
70
+ });
71
+ }
72
+ function uniqueSelectedCitations(citations) {
73
+ const byKey = new Map();
74
+ for (const citation of citations) {
75
+ byKey.set(citationSelectionKey(citation), citation);
76
+ }
77
+ return Array.from(byKey.values());
78
+ }
58
79
  function currentDisplayForLookup(stored, lookup) {
59
80
  return lookup.kind === "ok" ? citationDisplay(stored, lookup.snapshot) : citationDisplay(stored);
60
81
  }
@@ -1,5 +1,6 @@
1
1
  import type { UiHandlerDeps } from "./deps.js";
2
2
  import type { PdfCitationPreviewAuthority } from "./local-knowledge-preview-service.js";
3
+ import type { PdfCitationPreviewSource } from "./local-knowledge-preview-delivery.js";
3
4
  export interface PdfCitationPreviewSessionManagerOptions {
4
5
  readonly autoSweep?: boolean;
5
6
  readonly now?: () => number;
@@ -11,6 +12,7 @@ export interface PdfCitationPreviewSession {
11
12
  readonly documentKey: string;
12
13
  readonly expiresAt: string;
13
14
  readonly handle: string;
15
+ readonly source: PdfCitationPreviewSource;
14
16
  readonly state: "closed" | "expired" | "open";
15
17
  }
16
18
  export interface OpenPdfCitationPreviewSessionResult {
@@ -33,7 +35,7 @@ export interface PdfCitationPreviewSessionManager {
33
35
  closeSession(handle: string): boolean;
34
36
  dispose(): void;
35
37
  lookupSession(handle: string): PdfCitationPreviewSessionLookup;
36
- openSession(authority: PdfCitationPreviewAuthority): OpenPdfCitationPreviewSessionResult;
38
+ openSession(authority: PdfCitationPreviewAuthority, source: PdfCitationPreviewSource): OpenPdfCitationPreviewSessionResult;
37
39
  sweep(): void;
38
40
  }
39
41
  export declare function createPdfCitationPreviewSessionManager(options?: PdfCitationPreviewSessionManagerOptions): PdfCitationPreviewSessionManager;
@@ -1 +1 @@
1
- {"version":3,"file":"local-knowledge-preview-session-manager.d.ts","sourceRoot":"","sources":["../src/local-knowledge-preview-session-manager.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAMxF,MAAM,WAAW,uCAAuC;IACtD,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IAC5B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,SAAS,EAAE,2BAA2B,CAAC;IAChD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;CAC/C;AAED,MAAM,WAAW,mCAAmC;IAClD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EAAE,wBAAwB,GAC/B,mCAAmC,CAAC;IACvC,KAAK,IAAI,IAAI,CAAC;CACf;AA4JD,wBAAgB,sCAAsC,CACpD,OAAO,GAAE,uCAA4C,GACpD,gCAAgC,CAmBlC;AAID,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,aAAa,GAAG,gCAAgC,CAQ9F"}
@@ -22,6 +22,7 @@ function toSession(record) {
22
22
  documentKey: record.documentKey,
23
23
  expiresAt: new Date(record.expiresAtMs).toISOString(),
24
24
  handle: record.handle,
25
+ source: record.source,
25
26
  state: record.state,
26
27
  };
27
28
  }
@@ -82,13 +83,14 @@ function closeSessionRecord(state, handle) {
82
83
  settleRecord(state, record, "closed");
83
84
  return true;
84
85
  }
85
- function openSessionRecord(state, authority) {
86
+ function openSessionRecord(state, authority, source) {
86
87
  sweepRecords(state);
87
88
  const existing = lookupOpenRecord(state, authority);
88
89
  const expiresAtMs = state.now() + state.ttlMs;
89
90
  if (existing !== undefined) {
90
91
  existing.authority = authority;
91
92
  existing.expiresAtMs = expiresAtMs;
93
+ existing.source = source;
92
94
  return { reused: true, session: toSession(existing) };
93
95
  }
94
96
  const record = {
@@ -96,6 +98,7 @@ function openSessionRecord(state, authority) {
96
98
  documentKey: documentKey(authority),
97
99
  expiresAtMs,
98
100
  handle: randomUUID(),
101
+ source,
99
102
  state: "open",
100
103
  };
101
104
  state.byHandle.set(record.handle, record);
@@ -125,7 +128,7 @@ export function createPdfCitationPreviewSessionManager(options = {}) {
125
128
  state.byHandle.clear();
126
129
  },
127
130
  lookupSession: (handle) => lookupSessionResult(state, handle),
128
- openSession: (authority) => openSessionRecord(state, authority),
131
+ openSession: (authority, source) => openSessionRecord(state, authority, source),
129
132
  sweep() {
130
133
  sweepRecords(state);
131
134
  },
@@ -1 +1 @@
1
- {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/promptEnhancer/routes.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+JhD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,OAAO,CAAC,WAAW,CAwCrB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,WA0BF,CAAC"}
1
+ {"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/promptEnhancer/routes.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA+JhD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,OAAO,CAAC,WAAW,CAyCrB,CAAC;AAEF,eAAO,MAAM,+BAA+B,GAC1C,KAAK,YAAY,EACjB,MAAM,aAAa,KAClB,WA0BF,CAAC"}
@@ -5,7 +5,8 @@
5
5
  // and does not modify any sibling handler. The deterministic enhancement is assembled by
6
6
  // `runPromptEnhancement` (orchestrate.ts); this file owns only the HTTP envelope: bounded body read,
7
7
  // JSON parsing, wire validation, cancellation, Model-Gateway config hand-off, redaction, and safe error
8
- // shaping. No provider SDK import, no outbound network request, no model dispatch.
8
+ // shaping. No provider SDK import lives here; optional model-assisted enhancement routes through the
9
+ // existing ModelPort factory so provider credentials stay behind the server boundary.
9
10
  import { validatePromptEnhancementWireRequest } from "@oscharko-dev/keiko-contracts";
10
11
  import { EvidenceReadError, EvidenceWriteError, InvalidRunIdError, loadPromptEnhancementRun, recordPromptEnhancementRun, } from "@oscharko-dev/keiko-evidence";
11
12
  import { errorBody } from "../routes.js";
@@ -142,8 +143,9 @@ export const handlePromptEnhancement = async (ctx, deps) => {
142
143
  if (!validated.ok)
143
144
  return validated.result;
144
145
  try {
145
- const result = runPromptEnhancement(validated.value, {
146
+ const result = await runPromptEnhancement(validated.value, {
146
147
  gatewayRoutingConfig: promptEnhancementGatewayRoutingConfig(currentGatewayConfig(deps)),
148
+ modelPortFactory: deps.modelPortFactory,
147
149
  signal,
148
150
  });
149
151
  const body = {
@@ -1 +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"}
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;AA4UhD,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"}
@@ -32,6 +32,7 @@ import { qiHandoffErrorBody, } from "./handoffErrors.js";
32
32
  import { containsForbiddenSecretShape } from "./connectorErrors.js";
33
33
  import { executeQiRun } from "./runExecution.js";
34
34
  import { qiRunRegistry } from "./runRegistry.js";
35
+ import { buildQiModelRoutingForRun } from "./modelPolicyRoutes.js";
35
36
  // ─── Body reading ──────────────────────────────────────────────────────────────
36
37
  const MAX_BODY_BYTES = 64 * 1024;
37
38
  class BodyTooLargeError extends Error {
@@ -233,14 +234,16 @@ const startHandoffRun = (deps, roots) => {
233
234
  const registeredAt = new Date().toISOString();
234
235
  const controller = qiRunRegistry.register(runId, registeredAt);
235
236
  const totals = { candidates: 0, findings: 0, exports: 0 };
236
- void executeQiRun({
237
- request: {
238
- sources: roots.map((path) => ({
239
- kind: "workspace",
240
- label: "Conversation Center",
241
- path,
242
- })),
243
- },
237
+ const request = {
238
+ sources: roots.map((path) => ({
239
+ kind: "workspace",
240
+ label: "Conversation Center",
241
+ path,
242
+ })),
243
+ };
244
+ const execute = (modelRouting) => executeQiRun({
245
+ request,
246
+ ...(modelRouting !== undefined ? { modelRouting } : {}),
244
247
  runId,
245
248
  deps,
246
249
  registeredAt,
@@ -253,7 +256,11 @@ const startHandoffRun = (deps, roots) => {
253
256
  totals.findings += 1;
254
257
  qiRunRegistry.updateTotals(runId, totals);
255
258
  },
256
- })
259
+ });
260
+ const runPromise = deps.config === undefined
261
+ ? execute()
262
+ : buildQiModelRoutingForRun(deps, {}).then((modelRouting) => execute(modelRouting));
263
+ void runPromise
257
264
  .then((summary) => {
258
265
  qiRunRegistry.complete(runId, summary.status);
259
266
  })
@@ -7,6 +7,7 @@ export { qiHandoffErrorBody, type QiHandoffErrorBody, type QiHandoffErrorCode, }
7
7
  export { QI_RUN_EXECUTION_ROUTE_GROUP, handleStartQiRun, handleCancelQiRun } from "./runRoutes.js";
8
8
  export { qiRunRegistry, QiRunRegistry } from "./runRegistry.js";
9
9
  export { executeQiRun, QiIngestionError, QiGenerationError } from "./runExecution.js";
10
+ export { QI_MODEL_POLICY_ROUTE_GROUP, handleGetQiModelPolicy, handlePutQiModelPolicy, handlePreflightQiModelPolicy, } from "./modelPolicyRoutes.js";
10
11
  export { applyReviewDecision, appendEditAudit, loadRunReviewState, runReviewStateOf, candidateReviewStateOf, type QiReviewAction, type QiAuditAction, type QiReviewStateArtifact, } from "./reviewStore.js";
11
12
  export { QI_REVIEW_ROUTE_GROUP, handleQiReview } from "./reviewRoutes.js";
12
13
  export { QI_EXPORT_ROUTE_GROUP, handleQiExport } from "./exportRoutes.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/index.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,gCAAgC,EAChC,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,mCAAmC,EACnC,oBAA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c,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEnF,OAAO,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAElG,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,uBAAuB,GACxB,MAAM,oBAAoB,CAAC"}
@@ -20,6 +20,7 @@ export { qiHandoffErrorBody, } from "./handoffErrors.js";
20
20
  export { QI_RUN_EXECUTION_ROUTE_GROUP, handleStartQiRun, handleCancelQiRun } from "./runRoutes.js";
21
21
  export { qiRunRegistry, QiRunRegistry } from "./runRegistry.js";
22
22
  export { executeQiRun, QiIngestionError, QiGenerationError } from "./runExecution.js";
23
+ export { QI_MODEL_POLICY_ROUTE_GROUP, handleGetQiModelPolicy, handlePutQiModelPolicy, handlePreflightQiModelPolicy, } from "./modelPolicyRoutes.js";
23
24
  // Issue #282 — review-state companion store (read + mutation seams).
24
25
  export { applyReviewDecision, appendEditAudit, loadRunReviewState, runReviewStateOf, candidateReviewStateOf, } from "./reviewStore.js";
25
26
  // Issue #282 — review-action route group.
@@ -0,0 +1,16 @@
1
+ import type { QualityIntelligenceModelPolicyResponse, QualityIntelligenceModelRouting, QualityIntelligenceStartRunRequest } from "@oscharko-dev/keiko-contracts";
2
+ import type { RouteContext, RouteDefinition, RouteResult } from "../routes.js";
3
+ import type { UiHandlerDeps } from "../deps.js";
4
+ export declare class QiModelPolicyError extends Error {
5
+ readonly code: string;
6
+ constructor(code: string, message: string);
7
+ }
8
+ export declare function resolveQiPolicyPath(evidenceDir: string): string;
9
+ export declare function getQiModelPolicyResponse(deps: UiHandlerDeps): QualityIntelligenceModelPolicyResponse;
10
+ export declare function buildQiModelRouting(deps: UiHandlerDeps, request: Pick<QualityIntelligenceStartRunRequest, "modelId" | "modelPolicy">): Promise<QualityIntelligenceModelRouting>;
11
+ export declare function buildQiModelRoutingForRun(deps: UiHandlerDeps, request: Pick<QualityIntelligenceStartRunRequest, "modelId" | "modelPolicy">): Promise<QualityIntelligenceModelRouting>;
12
+ export declare function handleGetQiModelPolicy(_ctx: RouteContext, deps: UiHandlerDeps): RouteResult;
13
+ export declare function handlePutQiModelPolicy(ctx: RouteContext, deps: UiHandlerDeps): Promise<RouteResult>;
14
+ export declare function handlePreflightQiModelPolicy(ctx: RouteContext, deps: UiHandlerDeps): Promise<RouteResult>;
15
+ export declare const QI_MODEL_POLICY_ROUTE_GROUP: readonly RouteDefinition[];
16
+ //# sourceMappingURL=modelPolicyRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelPolicyRoutes.d.ts","sourceRoot":"","sources":["../../src/qualityIntelligence/modelPolicyRoutes.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAGV,sCAAsC,EAItC,+BAA+B,EAC/B,kCAAkC,EACnC,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA0BhD,qBAAa,kBAAmB,SAAQ,KAAK;IAEzC,QAAQ,CAAC,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM;CAKlB;AASD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AAqGD,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,aAAa,GAClB,sCAAsC,CAiBxC;AAoJD,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,IAAI,CAAC,kCAAkC,EAAE,SAAS,GAAG,aAAa,CAAC,GAC3E,OAAO,CA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