@absolutejs/rag 0.0.26 → 0.0.28

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 (97) hide show
  1. package/dist/adapter-kit/index.js +122 -6
  2. package/dist/adapter-kit/index.js.map +14 -14
  3. package/dist/angular/index.js.map +6 -6
  4. package/dist/client/index.js.map +6 -6
  5. package/dist/client/ui.js.map +4 -4
  6. package/dist/index.js +124 -6
  7. package/dist/index.js.map +29 -29
  8. package/dist/presentation/ui.js.map +6 -6
  9. package/dist/quality/quality.js.map +4 -4
  10. package/dist/react/index.js.map +14 -14
  11. package/dist/src/adapter-kit/index.d.ts +1 -1
  12. package/dist/src/adapters/inMemory.d.ts +1 -1
  13. package/dist/src/adapters/sync.d.ts +1 -1
  14. package/dist/src/angular/ai-rag-stream.service.d.ts +9 -9
  15. package/dist/src/angular/ai-rag-workflow.service.d.ts +10 -10
  16. package/dist/src/angular/rag-client.service.d.ts +68 -68
  17. package/dist/src/chat/chat.d.ts +1 -1
  18. package/dist/src/client/createRAGAnswerWorkflow.d.ts +10 -9
  19. package/dist/src/client/ragClient.d.ts +41 -40
  20. package/dist/src/client/ui.d.ts +1 -1
  21. package/dist/src/index.d.ts +3 -2
  22. package/dist/src/ingestion/ingestion.d.ts +1 -1
  23. package/dist/src/internal/accessControl.d.ts +1 -1
  24. package/dist/src/internal/jobState.d.ts +1 -1
  25. package/dist/src/presentation/htmxCitationFragments.d.ts +1 -1
  26. package/dist/src/presentation/htmxConfig.d.ts +1 -1
  27. package/dist/src/presentation/htmxRenderers.d.ts +2 -1
  28. package/dist/src/presentation/htmxWorkflowRenderers.d.ts +1 -1
  29. package/dist/src/presentation/presentation.d.ts +5 -4
  30. package/dist/src/providers/contactProviders.d.ts +1 -1
  31. package/dist/src/providers/emailProviders.d.ts +1 -1
  32. package/dist/src/providers/embeddingProviders.d.ts +1 -1
  33. package/dist/src/providers/extractorProviders.d.ts +1 -1
  34. package/dist/src/providers/rerankerProviders.d.ts +1 -1
  35. package/dist/src/providers/socialProviders.d.ts +1 -1
  36. package/dist/src/quality/quality.d.ts +2 -1
  37. package/dist/src/react/useRAG.d.ts +117 -117
  38. package/dist/src/react/useRAGChunkPreview.d.ts +5 -5
  39. package/dist/src/react/useRAGCitations.d.ts +4 -4
  40. package/dist/src/react/useRAGDocuments.d.ts +1 -1
  41. package/dist/src/react/useRAGEvaluate.d.ts +4 -4
  42. package/dist/src/react/useRAGGrounding.d.ts +3 -3
  43. package/dist/src/react/useRAGIndexAdmin.d.ts +5 -5
  44. package/dist/src/react/useRAGIngest.d.ts +1 -1
  45. package/dist/src/react/useRAGOps.d.ts +1 -1
  46. package/dist/src/react/useRAGSearch.d.ts +2 -1
  47. package/dist/src/react/useRAGSources.d.ts +6 -6
  48. package/dist/src/react/useRAGStatus.d.ts +2 -2
  49. package/dist/src/react/useRAGStream.d.ts +11 -11
  50. package/dist/src/react/useRAGWorkflow.d.ts +12 -12
  51. package/dist/src/retrieval/collection.d.ts +3 -1
  52. package/dist/src/retrieval/context.d.ts +1 -1
  53. package/dist/src/retrieval/embedding.d.ts +1 -1
  54. package/dist/src/retrieval/grounding.d.ts +2 -1
  55. package/dist/src/retrieval/lexical.d.ts +2 -1
  56. package/dist/src/retrieval/queryTransforms.d.ts +1 -1
  57. package/dist/src/retrieval/reranking.d.ts +1 -1
  58. package/dist/src/retrieval/retrievalStrategies.d.ts +1 -1
  59. package/dist/src/svelte/createRAG.d.ts +109 -109
  60. package/dist/src/svelte/createRAGChunkPreview.d.ts +5 -5
  61. package/dist/src/svelte/createRAGCitations.d.ts +4 -4
  62. package/dist/src/svelte/createRAGDocuments.d.ts +1 -1
  63. package/dist/src/svelte/createRAGEvaluate.d.ts +4 -4
  64. package/dist/src/svelte/createRAGGrounding.d.ts +3 -3
  65. package/dist/src/svelte/createRAGIndexAdmin.d.ts +5 -5
  66. package/dist/src/svelte/createRAGIngest.d.ts +1 -1
  67. package/dist/src/svelte/createRAGOps.d.ts +1 -1
  68. package/dist/src/svelte/createRAGSearch.d.ts +2 -1
  69. package/dist/src/svelte/createRAGSources.d.ts +6 -6
  70. package/dist/src/svelte/createRAGStatus.d.ts +2 -2
  71. package/dist/src/svelte/createRAGStream.d.ts +8 -8
  72. package/dist/src/svelte/createRAGWorkflow.d.ts +9 -9
  73. package/dist/src/sync/sync.d.ts +2 -2
  74. package/dist/src/vue/useRAG.d.ts +257 -257
  75. package/dist/src/vue/useRAGChunkPreview.d.ts +25 -25
  76. package/dist/src/vue/useRAGCitations.d.ts +4 -4
  77. package/dist/src/vue/useRAGDocuments.d.ts +9 -9
  78. package/dist/src/vue/useRAGEvaluate.d.ts +50 -50
  79. package/dist/src/vue/useRAGGrounding.d.ts +3 -3
  80. package/dist/src/vue/useRAGIndexAdmin.d.ts +35 -35
  81. package/dist/src/vue/useRAGIngest.d.ts +1 -1
  82. package/dist/src/vue/useRAGOps.d.ts +9 -9
  83. package/dist/src/vue/useRAGSearch.d.ts +30 -29
  84. package/dist/src/vue/useRAGSources.d.ts +6 -6
  85. package/dist/src/vue/useRAGStatus.d.ts +2 -2
  86. package/dist/src/vue/useRAGStream.d.ts +10 -10
  87. package/dist/src/vue/useRAGWorkflow.d.ts +11 -11
  88. package/dist/svelte/index.js.map +13 -13
  89. package/dist/types/adapters.d.ts +1 -1
  90. package/dist/types/client.d.ts +2 -1
  91. package/dist/types/core.d.ts +1 -1
  92. package/dist/types/engine.d.ts +4407 -0
  93. package/dist/types/index.d.ts +1 -0
  94. package/dist/types/presentation.d.ts +2 -1
  95. package/dist/types/retrieval.d.ts +1 -1
  96. package/dist/vue/index.js.map +13 -13
  97. package/package.json +6 -2
@@ -0,0 +1,4407 @@
1
+ import type { LinkedConnectorProvider, LinkedProviderAccessTokenLease, LinkedProviderAccountType, LinkedProviderBinding, LinkedProviderBindingStatus, LinkedProviderCredentialFailureReport, LinkedProviderCredentialResolver, LinkedProviderFailureCode, LinkedProviderFamily, LinkedProviderResolutionPurpose, ResolveLinkedProviderCredentialInput, ResolvedLinkedProviderCredential } from "@absolutejs/linked-providers";
2
+ import type { AIChatPluginConfig, AIHTMXRenderConfig, AIMessage, AIUsage, RAGChunkStructure, RAGDiversityStrategy, RAGHybridRetrievalMode, RAGRetrievalTrace, RAGRetrievalTraceStage, RAGSource, RAGSourceBalanceStrategy, RAGSourceLabels } from "@absolutejs/ai";
3
+ export type RAGExcerptMode = "chunk" | "window" | "section";
4
+ export type RAGExcerptPromotionReason = "single_chunk" | "chunk_too_narrow" | "section_small_enough" | "section_too_large_use_window";
5
+ export type RAGExcerptSelection = {
6
+ mode: RAGExcerptMode;
7
+ reason: RAGExcerptPromotionReason;
8
+ };
9
+ export type RAGExcerptModeCounts = Record<RAGExcerptMode, number>;
10
+ export type RAGSourceGroup = {
11
+ key: string;
12
+ label: string;
13
+ source?: string;
14
+ title?: string;
15
+ bestScore: number;
16
+ count: number;
17
+ chunks: RAGSource[];
18
+ labels?: RAGSourceLabels;
19
+ structure?: RAGChunkStructure;
20
+ };
21
+ export type RAGCitation = {
22
+ key: string;
23
+ label: string;
24
+ chunkId: string;
25
+ score: number;
26
+ text: string;
27
+ excerpt?: string;
28
+ excerpts?: RAGChunkExcerpts;
29
+ excerptSelection?: RAGExcerptSelection;
30
+ source?: string;
31
+ title?: string;
32
+ contextLabel?: string;
33
+ provenanceLabel?: string;
34
+ locatorLabel?: string;
35
+ metadata?: Record<string, unknown>;
36
+ };
37
+ export type RAGCitationReferenceMap = Record<string, number>;
38
+ export type RAGSourceSummary = {
39
+ key: string;
40
+ label: string;
41
+ source?: string;
42
+ title?: string;
43
+ bestScore: number;
44
+ count: number;
45
+ excerpt: string;
46
+ excerpts?: RAGChunkExcerpts;
47
+ excerptSelection?: RAGExcerptSelection;
48
+ chunkIds: string[];
49
+ citationNumbers: number[];
50
+ citations: RAGCitation[];
51
+ contextLabel?: string;
52
+ locatorLabel?: string;
53
+ provenanceLabel?: string;
54
+ structure?: RAGChunkStructure;
55
+ };
56
+ export type RAGSectionRetrievalReason = "best_hit" | "multi_hit_section" | "dominant_within_parent" | "only_section_in_parent" | "concentrated_evidence";
57
+ export type RAGSectionTraceWeightReason = "rerank_preserved_lead" | "final_stage_concentration" | "final_stage_dominant_within_parent" | "stage_runner_up_pressure" | "stage_expanded" | "stage_held" | "stage_narrowed";
58
+ export type RAGSectionQueryAttributionReason = "base_query_only" | "transformed_query_only" | "variant_only" | "transform_introduced" | "variant_supported" | "mixed_query_sources";
59
+ export type RAGSectionRetrievalDiagnostic = {
60
+ key: string;
61
+ label: string;
62
+ path?: string[];
63
+ parentLabel?: string;
64
+ count: number;
65
+ sourceCount: number;
66
+ bestScore: number;
67
+ averageScore: number;
68
+ totalScore: number;
69
+ scoreShare: number;
70
+ parentShare?: number;
71
+ parentShareGap?: number;
72
+ siblingCount: number;
73
+ strongestSiblingLabel?: string;
74
+ strongestSiblingScore?: number;
75
+ siblingScoreGap?: number;
76
+ topChunkId?: string;
77
+ topSource?: string;
78
+ topContextLabel?: string;
79
+ topLocatorLabel?: string;
80
+ sourceAwareChunkReasonLabel?: string;
81
+ sourceAwareUnitScopeLabel?: string;
82
+ vectorHits: number;
83
+ lexicalHits: number;
84
+ hybridHits: number;
85
+ stageCounts: Array<{
86
+ stage: RAGRetrievalTraceStage;
87
+ count: number;
88
+ }>;
89
+ stageWeights: Array<{
90
+ stage: RAGRetrievalTraceStage;
91
+ count: number;
92
+ previousStage?: RAGRetrievalTraceStage;
93
+ previousCount?: number;
94
+ countDelta?: number;
95
+ retentionRate?: number;
96
+ totalScore?: number;
97
+ stageScoreShare?: number;
98
+ parentStageScoreShare?: number;
99
+ stageScoreShareGap?: number;
100
+ parentStageScoreShareGap?: number;
101
+ stageShare: number;
102
+ parentStageShare?: number;
103
+ stageShareGap?: number;
104
+ parentStageShareGap?: number;
105
+ strongestSiblingLabel?: string;
106
+ strongestSiblingCount?: number;
107
+ reasons: RAGSectionTraceWeightReason[];
108
+ }>;
109
+ firstSeenStage?: RAGRetrievalTraceStage;
110
+ lastSeenStage?: RAGRetrievalTraceStage;
111
+ peakStage?: RAGRetrievalTraceStage;
112
+ peakCount: number;
113
+ finalCount?: number;
114
+ finalRetentionRate?: number;
115
+ dropFromPeak?: number;
116
+ queryAttribution: {
117
+ primaryHits: number;
118
+ transformedHits: number;
119
+ variantHits: number;
120
+ mode: "primary" | "transformed" | "variant" | "mixed";
121
+ reasons: RAGSectionQueryAttributionReason[];
122
+ };
123
+ requestedMode?: RAGHybridRetrievalMode;
124
+ retrievalMode?: RAGHybridRetrievalMode;
125
+ routingProvider?: string;
126
+ routingLabel?: string;
127
+ routingReason?: string;
128
+ queryTransformProvider?: string;
129
+ queryTransformLabel?: string;
130
+ queryTransformReason?: string;
131
+ evidenceReconcileApplied?: boolean;
132
+ rerankApplied?: boolean;
133
+ sourceBalanceApplied?: boolean;
134
+ scoreThresholdApplied?: boolean;
135
+ parentDistribution: Array<{
136
+ key: string;
137
+ label: string;
138
+ count: number;
139
+ totalScore: number;
140
+ parentShare: number;
141
+ isActive: boolean;
142
+ }>;
143
+ reasons: RAGSectionRetrievalReason[];
144
+ summary: string;
145
+ };
146
+ export type RAGGroundingReference = {
147
+ number: number;
148
+ chunkId: string;
149
+ label: string;
150
+ source?: string;
151
+ title?: string;
152
+ score: number;
153
+ text: string;
154
+ excerpt: string;
155
+ excerpts?: RAGChunkExcerpts;
156
+ excerptSelection?: RAGExcerptSelection;
157
+ contextLabel?: string;
158
+ provenanceLabel?: string;
159
+ locatorLabel?: string;
160
+ metadata?: Record<string, unknown>;
161
+ };
162
+ export type RAGGroundedAnswerCitationDetail = {
163
+ number: number;
164
+ label: string;
165
+ source?: string;
166
+ title?: string;
167
+ excerpt: string;
168
+ excerpts?: RAGChunkExcerpts;
169
+ excerptSelection?: RAGExcerptSelection;
170
+ contextLabel?: string;
171
+ provenanceLabel?: string;
172
+ locatorLabel?: string;
173
+ evidenceLabel: string;
174
+ evidenceSummary: string;
175
+ };
176
+ export type RAGGroundedAnswerSectionSummary = {
177
+ key: string;
178
+ label: string;
179
+ summary: string;
180
+ count: number;
181
+ excerpt?: string;
182
+ excerpts?: RAGChunkExcerpts;
183
+ excerptSelection?: RAGExcerptSelection;
184
+ chunkIds: string[];
185
+ referenceNumbers: number[];
186
+ references: RAGGroundingReference[];
187
+ contextLabel?: string;
188
+ locatorLabel?: string;
189
+ provenanceLabel?: string;
190
+ };
191
+ export type RAGGroundedAnswerPart = {
192
+ type: "text";
193
+ text: string;
194
+ } | {
195
+ type: "citation";
196
+ text: string;
197
+ referenceNumbers: number[];
198
+ references: RAGGroundingReference[];
199
+ referenceDetails: RAGGroundedAnswerCitationDetail[];
200
+ unresolvedReferenceNumbers: number[];
201
+ };
202
+ export type RAGGroundedAnswer = {
203
+ content: string;
204
+ hasCitations: boolean;
205
+ coverage: "grounded" | "partial" | "ungrounded";
206
+ parts: RAGGroundedAnswerPart[];
207
+ references: RAGGroundingReference[];
208
+ sectionSummaries: RAGGroundedAnswerSectionSummary[];
209
+ excerptModeCounts: RAGExcerptModeCounts;
210
+ ungroundedReferenceNumbers: number[];
211
+ };
212
+ export type RAGRetrievedState = {
213
+ conversationId: string;
214
+ messageId: string;
215
+ retrievalStartedAt?: number;
216
+ retrievedAt?: number;
217
+ retrievalDurationMs?: number;
218
+ trace?: RAGRetrievalTrace;
219
+ sources: RAGSource[];
220
+ sourceGroups: RAGSourceGroup[];
221
+ sourceSummaries: RAGSourceSummary[];
222
+ sectionDiagnostics: RAGSectionRetrievalDiagnostic[];
223
+ citations: RAGCitation[];
224
+ citationReferenceMap: RAGCitationReferenceMap;
225
+ excerptModeCounts: RAGExcerptModeCounts;
226
+ groundedAnswer: RAGGroundedAnswer;
227
+ };
228
+ export type RAGAnswerWorkflowState = {
229
+ stage: RAGStreamStage;
230
+ error: string | null;
231
+ messages: AIMessage[];
232
+ latestAssistantMessage?: AIMessage;
233
+ retrieval: RAGRetrievedState | null;
234
+ sources: RAGSource[];
235
+ sourceGroups: RAGSourceGroup[];
236
+ sourceSummaries: RAGSourceSummary[];
237
+ sectionDiagnostics: RAGSectionRetrievalDiagnostic[];
238
+ citations: RAGCitation[];
239
+ citationReferenceMap: RAGCitationReferenceMap;
240
+ groundingReferences: RAGGroundingReference[];
241
+ groundedAnswer: RAGGroundedAnswer;
242
+ excerptModeCounts: RAGExcerptModeCounts;
243
+ isIdle: boolean;
244
+ isRunning: boolean;
245
+ isSubmitting: boolean;
246
+ isRetrieving: boolean;
247
+ isRetrieved: boolean;
248
+ isAnswerStreaming: boolean;
249
+ isComplete: boolean;
250
+ isError: boolean;
251
+ hasSources: boolean;
252
+ hasRetrieved: boolean;
253
+ hasGrounding: boolean;
254
+ hasCitations: boolean;
255
+ coverage: RAGGroundedAnswer["coverage"];
256
+ ungroundedReferenceNumbers: number[];
257
+ retrievalDurationMs?: number;
258
+ retrievalStartedAt?: number;
259
+ retrievedAt?: number;
260
+ };
261
+ export type RAGStreamStage = "idle" | "submitting" | "retrieving" | "retrieved" | "streaming" | "complete" | "error";
262
+ export type RAGDocumentChunk = {
263
+ chunkId: string;
264
+ corpusKey?: string;
265
+ text: string;
266
+ title?: string;
267
+ source?: string;
268
+ metadata?: Record<string, unknown>;
269
+ embedding?: number[];
270
+ embeddingVariants?: RAGDocumentChunkEmbeddingVariant[];
271
+ structure?: RAGChunkStructure;
272
+ };
273
+ export type RAGDocumentChunkEmbeddingVariant = {
274
+ id: string;
275
+ label?: string;
276
+ text?: string;
277
+ metadata?: Record<string, unknown>;
278
+ embedding?: number[];
279
+ };
280
+ export type RAGEmbeddingKind = "query" | "passage";
281
+ export type RAGEmbeddingInput = {
282
+ text: string;
283
+ model?: string;
284
+ signal?: AbortSignal;
285
+ /**
286
+ * Asymmetric-embedding hint for providers that distinguish how the input is
287
+ * used (e.g. Pinecone Inference `input_type`, Cohere `input_type`, voyage
288
+ * `input_type`). The collection passes `"query"` when embedding a search
289
+ * query and `"passage"` when embedding a chunk/document for ingestion.
290
+ * Providers that do not support asymmetric embedding ignore this field.
291
+ */
292
+ kind?: RAGEmbeddingKind;
293
+ };
294
+ export type RAGEmbeddingFunction = (input: RAGEmbeddingInput) => Promise<number[]>;
295
+ export type RAGEmbeddingProvider = {
296
+ embed: RAGEmbeddingFunction;
297
+ dimensions?: number;
298
+ defaultModel?: string;
299
+ };
300
+ export type RAGEmbeddingProviderLike = RAGEmbeddingFunction | RAGEmbeddingProvider;
301
+ export type RAGContentFormat = "text" | "markdown" | "html" | "jsonl" | "tsv" | "csv" | "xml" | "yaml";
302
+ export type RAGFileExtractionInput = {
303
+ data: Uint8Array;
304
+ path?: string;
305
+ name?: string;
306
+ source?: string;
307
+ title?: string;
308
+ format?: RAGContentFormat;
309
+ contentType?: string;
310
+ metadata?: Record<string, unknown>;
311
+ chunking?: RAGChunkingOptions;
312
+ extractorRegistry?: RAGFileExtractorRegistryLike;
313
+ };
314
+ export type RAGExtractedFileDocument = RAGIngestDocument & {
315
+ contentType?: string;
316
+ extractor?: string;
317
+ };
318
+ export type RAGFileExtractor = {
319
+ name: string;
320
+ supports: (input: RAGFileExtractionInput) => boolean | Promise<boolean>;
321
+ extract: (input: RAGFileExtractionInput) => RAGExtractedFileDocument | RAGExtractedFileDocument[] | Promise<RAGExtractedFileDocument | RAGExtractedFileDocument[]>;
322
+ };
323
+ export type RAGFileExtractorRegistryInput = RAGFileExtractionInput & {
324
+ inferredContentType?: string | null;
325
+ inferredExtension?: string | null;
326
+ inferredFormat?: RAGContentFormat;
327
+ };
328
+ export type RAGFileExtractorRegistration = {
329
+ extractor: RAGFileExtractor;
330
+ name?: string;
331
+ priority?: number;
332
+ contentTypes?: string[];
333
+ extensions?: string[];
334
+ formats?: RAGContentFormat[];
335
+ names?: string[];
336
+ match?: (input: RAGFileExtractorRegistryInput) => boolean | Promise<boolean>;
337
+ };
338
+ export type RAGFileExtractorRegistry = {
339
+ registrations: RAGFileExtractorRegistration[];
340
+ includeDefaults?: boolean;
341
+ defaultOrder?: "registry_first" | "defaults_first";
342
+ };
343
+ export type RAGFileExtractorRegistryLike = RAGFileExtractorRegistry | RAGFileExtractorRegistration[];
344
+ export type RAGMediaTranscriptSegment = {
345
+ text: string;
346
+ startMs?: number;
347
+ endMs?: number;
348
+ speaker?: string;
349
+ channel?: string;
350
+ };
351
+ export type RAGMediaTranscriptionResult = {
352
+ text: string;
353
+ title?: string;
354
+ metadata?: Record<string, unknown>;
355
+ segments?: RAGMediaTranscriptSegment[];
356
+ };
357
+ export type RAGMediaTranscriber = {
358
+ name: string;
359
+ transcribe: (input: RAGFileExtractionInput) => RAGMediaTranscriptionResult | Promise<RAGMediaTranscriptionResult>;
360
+ };
361
+ export type RAGOCRRegion = {
362
+ text: string;
363
+ confidence?: number;
364
+ page?: number;
365
+ x?: number;
366
+ y?: number;
367
+ width?: number;
368
+ height?: number;
369
+ };
370
+ export type RAGOCRResult = {
371
+ text: string;
372
+ title?: string;
373
+ metadata?: Record<string, unknown>;
374
+ confidence?: number;
375
+ regions?: RAGOCRRegion[];
376
+ };
377
+ export type RAGOCRProvider = {
378
+ name: string;
379
+ extractText: (input: RAGFileExtractionInput) => RAGOCRResult | Promise<RAGOCRResult>;
380
+ };
381
+ export type RAGPDFOCRExtractorOptions = {
382
+ provider: RAGOCRProvider;
383
+ alwaysOCR?: boolean;
384
+ minExtractedTextLength?: number;
385
+ };
386
+ export type RAGArchiveEntry = {
387
+ data: Uint8Array;
388
+ path: string;
389
+ contentType?: string;
390
+ format?: RAGContentFormat;
391
+ metadata?: Record<string, unknown>;
392
+ };
393
+ export type RAGArchiveExpansionResult = {
394
+ entries: RAGArchiveEntry[];
395
+ metadata?: Record<string, unknown>;
396
+ };
397
+ export type RAGArchiveExpander = {
398
+ name: string;
399
+ expand: (input: RAGFileExtractionInput) => RAGArchiveExpansionResult | Promise<RAGArchiveExpansionResult>;
400
+ };
401
+ export type RAGChunkingStrategy = "paragraphs" | "sentences" | "fixed" | "source_aware";
402
+ export type RAGChunkingOptions = {
403
+ maxChunkLength?: number;
404
+ chunkOverlap?: number;
405
+ minChunkLength?: number;
406
+ strategy?: RAGChunkingStrategy;
407
+ };
408
+ export type RAGChunkingProfileInput = {
409
+ document: RAGIngestDocument;
410
+ format: RAGContentFormat;
411
+ normalizedText: string;
412
+ metadata: Record<string, unknown>;
413
+ sourceNativeKind?: string;
414
+ defaults?: RAGChunkingOptions;
415
+ };
416
+ export type RAGChunkingProfile = {
417
+ name: string;
418
+ resolve: (input: RAGChunkingProfileInput) => Partial<RAGChunkingOptions> | undefined;
419
+ };
420
+ export type RAGChunkingProfileRegistration = {
421
+ name?: string;
422
+ documentIds?: string[];
423
+ formats?: RAGContentFormat[];
424
+ priority?: number;
425
+ profile: Partial<RAGChunkingOptions> | {
426
+ options?: Partial<RAGChunkingOptions>;
427
+ };
428
+ sourceNativeKinds?: string[];
429
+ sources?: string[];
430
+ };
431
+ export type RAGChunkingRegistry = {
432
+ profiles: Array<RAGChunkingProfile | RAGChunkingProfileRegistration>;
433
+ };
434
+ export type RAGChunkingRegistryLike = RAGChunkingRegistry | Array<RAGChunkingProfile | RAGChunkingProfileRegistration>;
435
+ export type RAGIngestDocument = {
436
+ text: string;
437
+ corpusKey?: string;
438
+ id?: string;
439
+ title?: string;
440
+ source?: string;
441
+ format?: RAGContentFormat;
442
+ metadata?: Record<string, unknown>;
443
+ chunking?: RAGChunkingOptions;
444
+ };
445
+ export type RAGDocumentUrlInput = {
446
+ url: string;
447
+ title?: string;
448
+ source?: string;
449
+ format?: RAGContentFormat;
450
+ contentType?: string;
451
+ metadata?: Record<string, unknown>;
452
+ chunking?: RAGChunkingOptions;
453
+ extractors?: RAGFileExtractor[];
454
+ extractorRegistry?: RAGFileExtractorRegistryLike;
455
+ };
456
+ export type RAGDocumentUrlIngestInput = {
457
+ baseMetadata?: Record<string, unknown>;
458
+ defaultChunking?: RAGChunkingOptions;
459
+ chunkingRegistry?: RAGChunkingRegistryLike;
460
+ extractors?: RAGFileExtractor[];
461
+ extractorRegistry?: RAGFileExtractorRegistryLike;
462
+ urls: RAGDocumentUrlInput[];
463
+ };
464
+ export type RAGPreparedDocument = {
465
+ corpusKey?: string;
466
+ documentId: string;
467
+ title: string;
468
+ source: string;
469
+ format: RAGContentFormat;
470
+ metadata: Record<string, unknown>;
471
+ normalizedText: string;
472
+ chunks: RAGDocumentChunk[];
473
+ };
474
+ export type RAGDocumentFileInput = Omit<RAGIngestDocument, "text"> & {
475
+ path: string;
476
+ contentType?: string;
477
+ extractors?: RAGFileExtractor[];
478
+ extractorRegistry?: RAGFileExtractorRegistryLike;
479
+ };
480
+ export type RAGDirectoryIngestInput = {
481
+ directory: string;
482
+ recursive?: boolean;
483
+ includeExtensions?: string[];
484
+ baseMetadata?: Record<string, unknown>;
485
+ defaultChunking?: RAGChunkingOptions;
486
+ chunkingRegistry?: RAGChunkingRegistryLike;
487
+ extractors?: RAGFileExtractor[];
488
+ extractorRegistry?: RAGFileExtractorRegistryLike;
489
+ };
490
+ export type RAGQueryInput = {
491
+ queryVector: number[];
492
+ topK: number;
493
+ filter?: Record<string, unknown>;
494
+ plannerProfile?: RAGNativeQueryProfile;
495
+ queryMultiplier?: number;
496
+ candidateLimit?: number;
497
+ maxBackfills?: number;
498
+ minResults?: number;
499
+ fillPolicy?: "strict_topk" | "satisfy_min_results";
500
+ };
501
+ export type RAGLexicalQueryInput = {
502
+ query: string;
503
+ topK: number;
504
+ filter?: Record<string, unknown>;
505
+ };
506
+ export type RAGNativeQueryProfile = "latency" | "balanced" | "recall";
507
+ export type RAGQueryTransformInput = {
508
+ query: string;
509
+ topK: number;
510
+ candidateTopK?: number;
511
+ filter?: Record<string, unknown>;
512
+ model?: string;
513
+ scoreThreshold?: number;
514
+ };
515
+ export type RAGQueryTransformResult = {
516
+ query: string;
517
+ variants?: string[];
518
+ label?: string;
519
+ reason?: string;
520
+ metadata?: Record<string, string | number | boolean | null>;
521
+ };
522
+ export type RAGQueryTransformer = (input: RAGQueryTransformInput) => Promise<RAGQueryTransformResult> | RAGQueryTransformResult;
523
+ export type RAGQueryTransformProvider = {
524
+ transform: RAGQueryTransformer;
525
+ defaultModel?: string;
526
+ providerName?: string;
527
+ };
528
+ export type RAGQueryTransformProviderLike = RAGQueryTransformer | RAGQueryTransformProvider;
529
+ export type RAGRetrievalStrategyDecision = {
530
+ mode?: RAGHybridRetrievalMode;
531
+ lexicalTopK?: number;
532
+ maxResultsPerSource?: number;
533
+ sourceBalanceStrategy?: RAGSourceBalanceStrategy;
534
+ diversityStrategy?: RAGDiversityStrategy;
535
+ mmrLambda?: number;
536
+ fusion?: RAGHybridFusionMode;
537
+ fusionConstant?: number;
538
+ lexicalWeight?: number;
539
+ vectorWeight?: number;
540
+ label?: string;
541
+ reason?: string;
542
+ metadata?: Record<string, string | number | boolean | null>;
543
+ };
544
+ export type RAGRetrievalStrategyInput = {
545
+ query: string;
546
+ transformedQuery: string;
547
+ variantQueries: string[];
548
+ topK: number;
549
+ candidateTopK: number;
550
+ filter?: Record<string, unknown>;
551
+ scoreThreshold?: number;
552
+ model?: string;
553
+ retrieval: RAGHybridSearchOptions;
554
+ };
555
+ export type RAGRetrievalStrategySelector = (input: RAGRetrievalStrategyInput) => Promise<RAGRetrievalStrategyDecision | undefined> | RAGRetrievalStrategyDecision | undefined;
556
+ export type RAGRetrievalStrategyProvider = {
557
+ select: RAGRetrievalStrategySelector;
558
+ providerName?: string;
559
+ defaultLabel?: string;
560
+ };
561
+ export type RAGRetrievalStrategyProviderLike = RAGRetrievalStrategySelector | RAGRetrievalStrategyProvider;
562
+ export type RAGRerankerInput = {
563
+ query: string;
564
+ queryVector: number[];
565
+ model?: string;
566
+ filter?: Record<string, unknown>;
567
+ topK: number;
568
+ candidateTopK?: number;
569
+ scoreThreshold?: number;
570
+ results: RAGQueryResult[];
571
+ };
572
+ export type RAGReranker = (input: RAGRerankerInput) => Promise<RAGQueryResult[]> | RAGQueryResult[];
573
+ export type RAGRerankerProvider = {
574
+ rerank: RAGReranker;
575
+ defaultModel?: string;
576
+ providerName?: string;
577
+ };
578
+ export type RAGRerankerProviderLike = RAGReranker | RAGRerankerProvider;
579
+ export type RAGQueryResult = {
580
+ chunkId: string;
581
+ score: number;
582
+ chunkText: string;
583
+ embedding?: number[];
584
+ title?: string;
585
+ source?: string;
586
+ metadata?: Record<string, unknown>;
587
+ };
588
+ export type RAGHybridFusionMode = "rrf" | "max";
589
+ export type RAGHybridSearchOptions = {
590
+ mode?: RAGHybridRetrievalMode;
591
+ lexicalTopK?: number;
592
+ maxResultsPerSource?: number;
593
+ sourceBalanceStrategy?: RAGSourceBalanceStrategy;
594
+ diversityStrategy?: RAGDiversityStrategy;
595
+ mmrLambda?: number;
596
+ fusion?: RAGHybridFusionMode;
597
+ fusionConstant?: number;
598
+ lexicalWeight?: number;
599
+ vectorWeight?: number;
600
+ nativeQueryProfile?: RAGNativeQueryProfile;
601
+ nativeCandidateLimit?: number;
602
+ nativeMaxBackfills?: number;
603
+ nativeMinResults?: number;
604
+ nativeFillPolicy?: "strict_topk" | "satisfy_min_results";
605
+ };
606
+ export type RAGUpsertInput = {
607
+ chunks: RAGDocumentChunk[];
608
+ };
609
+ export type RAGDocumentIngestInput = {
610
+ documents: RAGIngestDocument[];
611
+ defaultChunking?: RAGChunkingOptions;
612
+ chunkingRegistry?: RAGChunkingRegistryLike;
613
+ };
614
+ export type RAGDocumentUploadInput = {
615
+ name: string;
616
+ content: string;
617
+ contentType?: string;
618
+ encoding?: "base64" | "utf8";
619
+ format?: RAGContentFormat;
620
+ source?: string;
621
+ title?: string;
622
+ chunking?: RAGChunkingOptions;
623
+ metadata?: Record<string, unknown>;
624
+ };
625
+ export type RAGDocumentUploadIngestInput = {
626
+ baseMetadata?: Record<string, unknown>;
627
+ defaultChunking?: RAGChunkingOptions;
628
+ chunkingRegistry?: RAGChunkingRegistryLike;
629
+ extractors?: RAGFileExtractor[];
630
+ extractorRegistry?: RAGFileExtractorRegistryLike;
631
+ uploads: RAGDocumentUploadInput[];
632
+ };
633
+ export type RAGIndexedDocument = {
634
+ corpusKey?: string;
635
+ id: string;
636
+ title: string;
637
+ source: string;
638
+ text?: string;
639
+ kind?: string;
640
+ format?: RAGContentFormat;
641
+ chunkStrategy?: RAGChunkingStrategy;
642
+ chunkSize?: number;
643
+ chunkCount?: number;
644
+ createdAt?: number;
645
+ updatedAt?: number;
646
+ metadata?: Record<string, unknown>;
647
+ labels?: RAGSourceLabels;
648
+ };
649
+ export type RAGDocumentChunkPreview = {
650
+ document: Omit<RAGIndexedDocument, "text" | "metadata"> & {
651
+ metadata?: Record<string, unknown>;
652
+ labels?: RAGSourceLabels;
653
+ };
654
+ normalizedText: string;
655
+ chunks: Array<RAGDocumentChunk & {
656
+ labels?: RAGSourceLabels;
657
+ excerpts?: RAGChunkExcerpts;
658
+ excerptSelection?: RAGExcerptSelection;
659
+ structure?: RAGChunkStructure;
660
+ }>;
661
+ };
662
+ export type RAGChunkExcerpts = {
663
+ chunkExcerpt: string;
664
+ windowExcerpt: string;
665
+ sectionExcerpt: string;
666
+ };
667
+ export type RAGChunkGraphNode = {
668
+ chunkId: string;
669
+ label: string;
670
+ source?: string;
671
+ title?: string;
672
+ score?: number;
673
+ contextLabel?: string;
674
+ locatorLabel?: string;
675
+ provenanceLabel?: string;
676
+ structure?: RAGChunkStructure;
677
+ };
678
+ export type RAGChunkGraphEdge = {
679
+ fromChunkId: string;
680
+ toChunkId: string;
681
+ relation: "previous" | "next" | "section_parent" | "section_child";
682
+ };
683
+ export type RAGChunkGraphSectionGroup = {
684
+ id: string;
685
+ title?: string;
686
+ path?: string[];
687
+ depth?: number;
688
+ kind?: "markdown_heading" | "html_heading" | "office_heading" | "office_block" | "pdf_block" | "spreadsheet_rows" | "presentation_slide";
689
+ chunkIds: string[];
690
+ chunkCount: number;
691
+ leadChunkId?: string;
692
+ parentSectionId?: string;
693
+ childSectionIds: string[];
694
+ };
695
+ export type RAGChunkGraph = {
696
+ nodes: RAGChunkGraphNode[];
697
+ edges: RAGChunkGraphEdge[];
698
+ sections: RAGChunkGraphSectionGroup[];
699
+ };
700
+ export type RAGChunkGraphNavigation = {
701
+ activeChunkId?: string;
702
+ activeNode?: RAGChunkGraphNode;
703
+ previousNode?: RAGChunkGraphNode;
704
+ nextNode?: RAGChunkGraphNode;
705
+ section?: RAGChunkGraphSectionGroup;
706
+ parentSection?: RAGChunkGraphSectionGroup;
707
+ childSections: RAGChunkGraphSectionGroup[];
708
+ siblingSections: RAGChunkGraphSectionGroup[];
709
+ sectionNodes: RAGChunkGraphNode[];
710
+ };
711
+ export type RAGBackendDescriptor = {
712
+ id: string;
713
+ label: string;
714
+ path?: string;
715
+ available: boolean;
716
+ reason?: string;
717
+ lastSeedMs?: number;
718
+ status?: RAGVectorStoreStatus;
719
+ capabilities?: RAGBackendCapabilities;
720
+ };
721
+ export type RAGBackendsResponse = {
722
+ ok: true;
723
+ defaultMode?: string;
724
+ activeModeCookie?: string;
725
+ backends: RAGBackendDescriptor[];
726
+ };
727
+ export type SQLiteVecResolutionSource = "absolute-package" | "explicit" | "env" | "database";
728
+ export type SQLiteVecResolutionStatus = "resolved" | "not_configured" | "unsupported_platform" | "package_not_installed" | "binary_missing" | "package_invalid";
729
+ export type SQLiteVecResolution = {
730
+ status: SQLiteVecResolutionStatus;
731
+ source: SQLiteVecResolutionSource;
732
+ platformKey: string;
733
+ packageName?: string;
734
+ packageVersion?: string;
735
+ packageRoot?: string;
736
+ libraryFile?: string;
737
+ libraryPath?: string;
738
+ reason?: string;
739
+ };
740
+ export type RAGSQLiteNativeDiagnostics = {
741
+ requested: boolean;
742
+ available: boolean;
743
+ active: boolean;
744
+ mode?: "vec0";
745
+ tableName?: string;
746
+ distanceMetric?: "cosine" | "l2";
747
+ rowCount?: number;
748
+ pageCount?: number;
749
+ freelistCount?: number;
750
+ databaseBytes?: number;
751
+ lastHealthCheckAt?: number;
752
+ lastAnalyzeAt?: number;
753
+ resolution?: SQLiteVecResolution;
754
+ fallbackReason?: string;
755
+ lastAnalyzeError?: string;
756
+ lastHealthError?: string;
757
+ lastLoadError?: string;
758
+ lastQueryError?: string;
759
+ lastUpsertError?: string;
760
+ lastQueryPlan?: {
761
+ pushdownMode: "none" | "partial" | "full";
762
+ pushdownApplied: boolean;
763
+ pushdownClauseCount: number;
764
+ totalFilterClauseCount: number;
765
+ jsRemainderClauseCount: number;
766
+ plannerProfileUsed?: RAGNativeQueryProfile;
767
+ queryMultiplierUsed?: number;
768
+ candidateLimitUsed?: number;
769
+ maxBackfillsUsed?: number;
770
+ minResultsUsed?: number;
771
+ fillPolicyUsed?: "strict_topk" | "satisfy_min_results";
772
+ pushdownCoverageRatio?: number;
773
+ jsRemainderRatio?: number;
774
+ filteredCandidateCount?: number;
775
+ initialSearchK?: number;
776
+ finalSearchK?: number;
777
+ searchExpansionRatio?: number;
778
+ backfillCount?: number;
779
+ backfillLimitReached?: boolean;
780
+ minResultsSatisfied?: boolean;
781
+ returnedCount?: number;
782
+ candidateYieldRatio?: number;
783
+ topKFillRatio?: number;
784
+ underfilledTopK?: boolean;
785
+ candidateBudgetExhausted?: boolean;
786
+ candidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
787
+ queryMode: "json_fallback" | "native_vec0";
788
+ };
789
+ };
790
+ export type RAGPostgresNativeDiagnostics = {
791
+ requested: boolean;
792
+ available: boolean;
793
+ active: boolean;
794
+ mode?: "pgvector";
795
+ extensionName?: string;
796
+ schemaName?: string;
797
+ tableName?: string;
798
+ distanceMetric?: "cosine" | "l2" | "inner_product";
799
+ indexType?: "none" | "hnsw" | "ivfflat";
800
+ indexName?: string;
801
+ indexPresent?: boolean;
802
+ estimatedRowCount?: number;
803
+ tableBytes?: number;
804
+ indexBytes?: number;
805
+ totalBytes?: number;
806
+ lastHealthCheckAt?: number;
807
+ lastAnalyzeAt?: number;
808
+ lastReindexAt?: number;
809
+ fallbackReason?: string;
810
+ lastAnalyzeError?: string;
811
+ lastInitError?: string;
812
+ lastQueryError?: string;
813
+ lastReindexError?: string;
814
+ lastUpsertError?: string;
815
+ lastMigrationError?: string;
816
+ lastHealthError?: string;
817
+ lastFilterDebug?: {
818
+ filter?: Record<string, unknown>;
819
+ pushdownFilter?: Record<string, unknown>;
820
+ countSql?: string;
821
+ countParams?: unknown[];
822
+ querySql?: string;
823
+ queryParams?: unknown[];
824
+ countResultRaw?: unknown;
825
+ queryRowCount?: number;
826
+ };
827
+ lastQueryPlan?: {
828
+ pushdownMode: "none" | "partial" | "full";
829
+ pushdownApplied: boolean;
830
+ pushdownClauseCount: number;
831
+ totalFilterClauseCount: number;
832
+ jsRemainderClauseCount: number;
833
+ plannerProfileUsed?: RAGNativeQueryProfile;
834
+ queryMultiplierUsed?: number;
835
+ candidateLimitUsed?: number;
836
+ maxBackfillsUsed?: number;
837
+ minResultsUsed?: number;
838
+ fillPolicyUsed?: "strict_topk" | "satisfy_min_results";
839
+ pushdownCoverageRatio?: number;
840
+ jsRemainderRatio?: number;
841
+ filteredCandidateCount?: number;
842
+ initialSearchK?: number;
843
+ finalSearchK?: number;
844
+ searchExpansionRatio?: number;
845
+ backfillCount?: number;
846
+ backfillLimitReached?: boolean;
847
+ minResultsSatisfied?: boolean;
848
+ returnedCount?: number;
849
+ candidateYieldRatio?: number;
850
+ topKFillRatio?: number;
851
+ underfilledTopK?: boolean;
852
+ candidateBudgetExhausted?: boolean;
853
+ candidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
854
+ queryMode: "native_pgvector";
855
+ };
856
+ };
857
+ export type RAGVectorStoreStatus = {
858
+ backend: "in_memory";
859
+ vectorMode: "in_memory";
860
+ dimensions?: number;
861
+ native?: undefined;
862
+ } | {
863
+ backend: "sqlite";
864
+ vectorMode: "json_fallback" | "native_vec0";
865
+ dimensions?: number;
866
+ native?: RAGSQLiteNativeDiagnostics;
867
+ } | {
868
+ backend: "postgres";
869
+ vectorMode: "native_pgvector";
870
+ dimensions?: number;
871
+ native?: RAGPostgresNativeDiagnostics;
872
+ };
873
+ export type RAGVectorCountInput = {
874
+ filter?: Record<string, unknown>;
875
+ chunkIds?: string[];
876
+ };
877
+ export type RAGVectorDeleteInput = {
878
+ filter?: Record<string, unknown>;
879
+ chunkIds?: string[];
880
+ };
881
+ export type RAGBackendCapabilities = {
882
+ backend: "in_memory" | "sqlite" | "postgres" | "custom";
883
+ persistence: "memory_only" | "embedded" | "external";
884
+ nativeVectorSearch: boolean;
885
+ serverSideFiltering: boolean;
886
+ streamingIngestStatus: boolean;
887
+ };
888
+ export type RAGVectorStore = {
889
+ embed: (input: RAGEmbeddingInput) => Promise<number[]>;
890
+ query: (input: RAGQueryInput) => Promise<RAGQueryResult[]>;
891
+ queryLexical?: (input: RAGLexicalQueryInput) => Promise<RAGQueryResult[]>;
892
+ count?: (input?: RAGVectorCountInput) => Promise<number>;
893
+ delete?: (input?: RAGVectorDeleteInput) => Promise<number>;
894
+ analyze?: () => Promise<void> | void;
895
+ rebuildNativeIndex?: () => Promise<void> | void;
896
+ upsert: (input: RAGUpsertInput) => Promise<void>;
897
+ clear?: () => Promise<void> | void;
898
+ close?: () => Promise<void> | void;
899
+ getStatus?: () => RAGVectorStoreStatus;
900
+ getCapabilities?: () => RAGBackendCapabilities;
901
+ };
902
+ export type RAGCollectionSearchParams = {
903
+ query: string;
904
+ topK?: number;
905
+ candidateTopK?: number;
906
+ nativeQueryProfile?: RAGNativeQueryProfile;
907
+ nativeQueryMultiplier?: number;
908
+ nativeCandidateLimit?: number;
909
+ nativeMaxBackfills?: number;
910
+ nativeMinResults?: number;
911
+ nativeFillPolicy?: "strict_topk" | "satisfy_min_results";
912
+ filter?: Record<string, unknown>;
913
+ scoreThreshold?: number;
914
+ queryTransform?: RAGQueryTransformProviderLike;
915
+ retrievalStrategy?: RAGRetrievalStrategyProviderLike;
916
+ rerank?: RAGRerankerProviderLike;
917
+ retrieval?: RAGHybridSearchOptions | RAGHybridRetrievalMode;
918
+ model?: string;
919
+ signal?: AbortSignal;
920
+ };
921
+ export type RAGCollectionSearchResult = {
922
+ results: RAGQueryResult[];
923
+ trace: RAGRetrievalTrace;
924
+ };
925
+ export type RAGSearchRequest = Omit<RAGCollectionSearchParams, "signal" | "rerank"> & {
926
+ includeTrace?: boolean;
927
+ persistTrace?: boolean;
928
+ traceGroupKey?: string;
929
+ traceTags?: string[];
930
+ };
931
+ export type RAGSearchResponse = {
932
+ ok: boolean;
933
+ results?: RAGSource[];
934
+ trace?: RAGRetrievalTrace;
935
+ error?: string;
936
+ };
937
+ export type RAGSearchTraceHistoryResponse = {
938
+ ok: boolean;
939
+ history?: RAGSearchTraceHistory;
940
+ error?: string;
941
+ };
942
+ export type RAGSearchTraceGroupHistoryResponse = {
943
+ ok: boolean;
944
+ history?: RAGSearchTraceGroupHistory;
945
+ error?: string;
946
+ };
947
+ export type RAGIngestResponse = {
948
+ ok: boolean;
949
+ count?: number;
950
+ documentCount?: number;
951
+ error?: string;
952
+ };
953
+ export type RAGDocumentSummary = {
954
+ total: number;
955
+ chunkCount: number;
956
+ byKind: Record<string, number>;
957
+ };
958
+ export type RAGIngestJobStatus = "running" | "completed" | "failed";
959
+ export type RAGIngestJobRecord = {
960
+ id: string;
961
+ status: RAGIngestJobStatus;
962
+ startedAt: number;
963
+ finishedAt?: number;
964
+ elapsedMs?: number;
965
+ inputKind: "chunks" | "documents" | "urls" | "uploads";
966
+ requestedCount: number;
967
+ chunkCount?: number;
968
+ documentCount?: number;
969
+ error?: string;
970
+ extractorNames?: string[];
971
+ };
972
+ export type RAGCorpusHealth = {
973
+ emptyDocuments: number;
974
+ emptyChunks: number;
975
+ duplicateSources: string[];
976
+ duplicateSourceGroups: Array<{
977
+ source: string;
978
+ count: number;
979
+ }>;
980
+ duplicateDocumentIds: string[];
981
+ duplicateDocumentIdGroups: Array<{
982
+ id: string;
983
+ count: number;
984
+ }>;
985
+ documentsMissingSource: number;
986
+ documentsMissingTitle: number;
987
+ documentsMissingMetadata: number;
988
+ documentsMissingCreatedAt: number;
989
+ documentsMissingUpdatedAt: number;
990
+ documentsWithoutChunkPreview: number;
991
+ coverageByFormat: Record<string, number>;
992
+ coverageByKind: Record<string, number>;
993
+ failedAdminJobs: number;
994
+ failedIngestJobs: number;
995
+ failuresByAdminAction: Record<string, number>;
996
+ failuresByExtractor: Record<string, number>;
997
+ failuresByInputKind: Record<string, number>;
998
+ inspectedChunks: number;
999
+ inspectedDocuments: number;
1000
+ lowSignalChunks: number;
1001
+ oldestDocumentAgeMs?: number;
1002
+ newestDocumentAgeMs?: number;
1003
+ staleAfterMs: number;
1004
+ staleDocuments: string[];
1005
+ averageChunksPerDocument: number;
1006
+ inspection?: {
1007
+ corpusKeys: Record<string, number>;
1008
+ sourceNativeKinds: Record<string, number>;
1009
+ extractorRegistryMatches: Record<string, number>;
1010
+ chunkingProfiles: Record<string, number>;
1011
+ documentsWithSourceLabels: number;
1012
+ chunksWithSourceLabels: number;
1013
+ sampleDocuments: Array<{
1014
+ corpusKey?: string;
1015
+ id: string;
1016
+ title: string;
1017
+ source: string;
1018
+ sourceNativeKind?: string;
1019
+ extractorRegistryMatch?: string;
1020
+ chunkingProfile?: string;
1021
+ labels?: RAGSourceLabels;
1022
+ }>;
1023
+ sampleChunks: Array<{
1024
+ chunkId: string;
1025
+ corpusKey?: string;
1026
+ documentId?: string;
1027
+ source?: string;
1028
+ sourceNativeKind?: string;
1029
+ extractorRegistryMatch?: string;
1030
+ chunkingProfile?: string;
1031
+ labels?: RAGSourceLabels;
1032
+ }>;
1033
+ };
1034
+ };
1035
+ export type RAGAdminActionRecord = {
1036
+ id: string;
1037
+ action: "analyze_backend" | "rebuild_native_index" | "clear_index" | "create_document" | "delete_document" | "promote_retrieval_baseline" | "revert_retrieval_baseline" | "prune_search_traces" | "reindex_document" | "reindex_source" | "sync_all_sources" | "sync_source" | "reseed" | "reset";
1038
+ status: "completed" | "failed";
1039
+ startedAt: number;
1040
+ finishedAt?: number;
1041
+ elapsedMs?: number;
1042
+ documentId?: string;
1043
+ target?: string;
1044
+ error?: string;
1045
+ };
1046
+ export type RAGAdminJobStatus = "running" | "completed" | "failed";
1047
+ export type RAGAdminJobRecord = {
1048
+ id: string;
1049
+ action: "analyze_backend" | "rebuild_native_index" | "clear_index" | "create_document" | "delete_document" | "promote_retrieval_baseline" | "revert_retrieval_baseline" | "prune_search_traces" | "reindex_document" | "reindex_source" | "sync_all_sources" | "sync_source" | "reseed" | "reset";
1050
+ status: RAGAdminJobStatus;
1051
+ startedAt: number;
1052
+ finishedAt?: number;
1053
+ elapsedMs?: number;
1054
+ target?: string;
1055
+ error?: string;
1056
+ };
1057
+ export type RAGJobState = {
1058
+ adminActions: RAGAdminActionRecord[];
1059
+ ingestJobs: RAGIngestJobRecord[];
1060
+ adminJobs: RAGAdminJobRecord[];
1061
+ syncJobs: RAGAdminJobRecord[];
1062
+ };
1063
+ export type RAGJobStateStore = {
1064
+ load: () => Promise<Partial<RAGJobState> | undefined> | Partial<RAGJobState> | undefined;
1065
+ save: (state: RAGJobState) => Promise<void> | void;
1066
+ };
1067
+ export type RAGJobHistoryRetention = {
1068
+ maxAdminActions?: number;
1069
+ maxAdminJobs?: number;
1070
+ maxIngestJobs?: number;
1071
+ maxSyncJobs?: number;
1072
+ };
1073
+ export type RAGAdminCapabilities = {
1074
+ canAnalyzeBackend: boolean;
1075
+ canClearIndex: boolean;
1076
+ canCreateDocument: boolean;
1077
+ canDeleteDocument: boolean;
1078
+ canListSyncSources: boolean;
1079
+ canManageRetrievalBaselines: boolean;
1080
+ canPruneSearchTraces: boolean;
1081
+ canRebuildNativeIndex: boolean;
1082
+ canReindexDocument: boolean;
1083
+ canReindexSource: boolean;
1084
+ canReseed: boolean;
1085
+ canReset: boolean;
1086
+ canSyncAllSources: boolean;
1087
+ canSyncSource: boolean;
1088
+ };
1089
+ export type RAGBackendMaintenanceRecommendation = {
1090
+ code: "backend_statistics_refresh_recommended" | "native_backend_inactive" | "native_backend_recent_errors" | "native_index_missing" | "native_index_rebuild_recommended" | "sqlite_storage_optimization_recommended";
1091
+ message: string;
1092
+ severity: "info" | "warning" | "error";
1093
+ action?: "analyze_backend" | "rebuild_native_index";
1094
+ };
1095
+ export type RAGBackendMaintenanceSummary = {
1096
+ backend: Exclude<RAGVectorStoreStatus["backend"], "in_memory">;
1097
+ activeJobs: Array<{
1098
+ action: "analyze_backend" | "rebuild_native_index";
1099
+ startedAt: number;
1100
+ target?: string;
1101
+ }>;
1102
+ recentActions: Array<{
1103
+ action: "analyze_backend" | "rebuild_native_index";
1104
+ status: RAGAdminActionRecord["status"];
1105
+ finishedAt?: number;
1106
+ target?: string;
1107
+ error?: string;
1108
+ }>;
1109
+ recommendations: RAGBackendMaintenanceRecommendation[];
1110
+ };
1111
+ export type RAGAuthorizedAction = "analyze_backend" | "rebuild_native_index" | "clear_index" | "create_document" | "delete_document" | "ingest" | "list_sync_sources" | "manage_retrieval_admin" | "manage_retrieval_baselines" | "prune_search_traces" | "reindex_document" | "reindex_source" | "reseed" | "reset" | "sync_all_sources" | "sync_source";
1112
+ export type RAGAuthorizationResource = {
1113
+ documentId?: string;
1114
+ path?: string;
1115
+ source?: string;
1116
+ sourceId?: string;
1117
+ };
1118
+ export type RAGAuthorizationDecision = boolean | {
1119
+ allowed: boolean;
1120
+ reason?: string;
1121
+ };
1122
+ export type RAGAuthorizationContext = {
1123
+ action: RAGAuthorizedAction;
1124
+ request: Request;
1125
+ resource?: RAGAuthorizationResource;
1126
+ };
1127
+ export type RAGAuthorizationProvider = (context: RAGAuthorizationContext) => Promise<RAGAuthorizationDecision> | RAGAuthorizationDecision;
1128
+ export type RAGAccessScope = {
1129
+ allowedComparisonGroupKeys?: string[];
1130
+ allowedCorpusGroupKeys?: string[];
1131
+ allowedCorpusKeys?: string[];
1132
+ allowedDocumentIds?: string[];
1133
+ allowedSourcePrefixes?: string[];
1134
+ allowedSources?: string[];
1135
+ allowedSyncSourceIds?: string[];
1136
+ requiredMetadata?: Record<string, unknown>;
1137
+ };
1138
+ export type RAGAccessScopeProvider = (request: Request) => Promise<RAGAccessScope | undefined> | RAGAccessScope | undefined;
1139
+ export type RAGAccessControlContextResolver<TContext = unknown> = (request: Request) => Promise<TContext | undefined> | TContext | undefined;
1140
+ export type RAGAccessControlAuthorizeResolver<TContext = unknown> = (input: RAGAuthorizationContext & {
1141
+ context: TContext | undefined;
1142
+ }) => Promise<RAGAuthorizationDecision> | RAGAuthorizationDecision;
1143
+ export type RAGAccessControlScopeResolver<TContext = unknown> = (input: {
1144
+ context: TContext | undefined;
1145
+ request: Request;
1146
+ }) => Promise<RAGAccessScope | undefined> | RAGAccessScope | undefined;
1147
+ export type CreateRAGAccessControlOptions<TContext = unknown> = {
1148
+ resolveContext: RAGAccessControlContextResolver<TContext>;
1149
+ authorize?: RAGAccessControlAuthorizeResolver<TContext>;
1150
+ resolveScope?: RAGAccessControlScopeResolver<TContext>;
1151
+ };
1152
+ export type RAGSyncSourceStatus = "idle" | "running" | "completed" | "failed" | "disabled";
1153
+ export type RAGSyncSourceDiagnosticCode = "sync_failed" | "retry_scheduled" | "storage_resume_pending" | "email_resume_pending" | "lineage_conflict_detected" | "duplicate_sync_key_detected" | "targeted_refresh_applied" | "noop_sync" | "extraction_failures_detected" | "extractor_missing" | "ocr_extractor_recommended" | "canonical_dedupe_applied" | "robots_blocked" | "nofollow_skipped" | "noindex_skipped";
1154
+ export type RAGSyncSourceDiagnosticEntry = {
1155
+ code: RAGSyncSourceDiagnosticCode;
1156
+ severity: "info" | "warning" | "error";
1157
+ summary: string;
1158
+ };
1159
+ export type RAGSyncRetryGuidance = {
1160
+ action: "wait_for_retry" | "resume_sync" | "resolve_conflicts" | "rerun_sync" | "inspect_source" | "configure_extractor";
1161
+ reason: string;
1162
+ nextRetryAt?: number;
1163
+ resumeCursor?: string;
1164
+ syncKeys?: string[];
1165
+ };
1166
+ export type RAGSyncExtractionFailure = {
1167
+ itemLabel: string;
1168
+ itemKind: "directory_file" | "url" | "storage_object" | "email_attachment";
1169
+ reason: string;
1170
+ remediation: "configure_extractor" | "add_ocr_extractor" | "inspect_file";
1171
+ };
1172
+ export type RAGSyncExtractionRecoveryAction = {
1173
+ remediation: RAGSyncExtractionFailure["remediation"];
1174
+ itemKinds: RAGSyncExtractionFailure["itemKind"][];
1175
+ itemLabels: string[];
1176
+ reasons: string[];
1177
+ count: number;
1178
+ summary: string;
1179
+ };
1180
+ export type RAGSyncExtractionRecoveryPreview = {
1181
+ actions: RAGSyncExtractionRecoveryAction[];
1182
+ recommendedAction?: RAGSyncExtractionRecoveryAction;
1183
+ unresolvedFailures: RAGSyncExtractionFailure[];
1184
+ summary?: string;
1185
+ };
1186
+ export type RAGSyncExtractionRecoveryHandler = (action: RAGSyncExtractionRecoveryAction) => Promise<boolean | void> | boolean | void;
1187
+ export type RAGSyncExtractionRecoveryHandlers = Partial<Record<RAGSyncExtractionFailure["remediation"], RAGSyncExtractionRecoveryHandler>>;
1188
+ export type RAGSyncExtractionRecoveryResult = RAGSyncExtractionRecoveryPreview & {
1189
+ completedActions: RAGSyncExtractionRecoveryAction[];
1190
+ failedActions: RAGSyncExtractionRecoveryAction[];
1191
+ skippedActions: RAGSyncExtractionRecoveryAction[];
1192
+ errorsByRemediation?: Partial<Record<RAGSyncExtractionFailure["remediation"], string>>;
1193
+ };
1194
+ export type RAGSyncSourceDiagnostics = {
1195
+ summary: string;
1196
+ entries: RAGSyncSourceDiagnosticEntry[];
1197
+ extractionFailures?: RAGSyncExtractionFailure[];
1198
+ retryGuidance?: RAGSyncRetryGuidance;
1199
+ };
1200
+ export type RAGSyncSourceRecord = {
1201
+ id: string;
1202
+ label: string;
1203
+ kind: "directory" | "url" | "storage" | "email" | "connector" | "custom";
1204
+ status: RAGSyncSourceStatus;
1205
+ description?: string;
1206
+ target?: string;
1207
+ lastStartedAt?: number;
1208
+ lastSyncedAt?: number;
1209
+ lastSyncDurationMs?: number;
1210
+ lastError?: string;
1211
+ lastSuccessfulSyncAt?: number;
1212
+ consecutiveFailures?: number;
1213
+ retryAttempts?: number;
1214
+ nextRetryAt?: number;
1215
+ documentCount?: number;
1216
+ chunkCount?: number;
1217
+ reconciliation?: RAGSyncSourceReconciliationSummary;
1218
+ diagnostics?: RAGSyncSourceDiagnostics;
1219
+ metadata?: Record<string, unknown>;
1220
+ };
1221
+ export type RAGSyncSourceReconciliationSummary = {
1222
+ refreshMode: "noop" | "targeted";
1223
+ staleDocumentIds: string[];
1224
+ staleSyncKeys: string[];
1225
+ refreshedDocumentIds: string[];
1226
+ refreshedSyncKeys: string[];
1227
+ unchangedDocumentIds: string[];
1228
+ unchangedSyncKeys: string[];
1229
+ targetedRefreshSyncKeys: string[];
1230
+ duplicateSyncKeyGroups: Array<{
1231
+ syncKey: string;
1232
+ count: number;
1233
+ documentIds: string[];
1234
+ }>;
1235
+ lineageConflicts: Array<{
1236
+ syncKey: string;
1237
+ lineageIds: string[];
1238
+ versionIds: string[];
1239
+ latestDocumentIds: string[];
1240
+ documentIds: string[];
1241
+ documents: Array<{
1242
+ documentId: string;
1243
+ lineageId?: string;
1244
+ versionId?: string;
1245
+ versionNumber?: number;
1246
+ isLatestVersion: boolean;
1247
+ }>;
1248
+ reasons: Array<"duplicate_sync_key" | "multiple_lineages" | "multiple_versions" | "multiple_latest_versions">;
1249
+ }>;
1250
+ };
1251
+ export type RAGSyncConflictResolutionStrategy = "keep_latest" | "keep_highest_version";
1252
+ export type RAGSyncConflictResolutionAction = {
1253
+ syncKey: string;
1254
+ keepDocumentId: string;
1255
+ deleteDocumentIds: string[];
1256
+ reasons: RAGSyncSourceReconciliationSummary["lineageConflicts"][number]["reasons"];
1257
+ };
1258
+ export type RAGSyncConflictResolutionAmbiguity = {
1259
+ syncKey: string;
1260
+ reasons: RAGSyncSourceReconciliationSummary["lineageConflicts"][number]["reasons"];
1261
+ candidateDocumentIds: string[];
1262
+ recommendedStrategy?: RAGSyncConflictResolutionStrategy;
1263
+ };
1264
+ export type RAGSyncConflictResolutionPreview = {
1265
+ strategy: RAGSyncConflictResolutionStrategy;
1266
+ actions: RAGSyncConflictResolutionAction[];
1267
+ unresolvedSyncKeys: string[];
1268
+ unresolvedConflicts: RAGSyncConflictResolutionAmbiguity[];
1269
+ };
1270
+ export type RAGSyncConflictResolutionResult = RAGSyncConflictResolutionPreview & {
1271
+ deletedDocumentIds: string[];
1272
+ failedDocumentIds: string[];
1273
+ errorsByDocumentId?: Record<string, string>;
1274
+ };
1275
+ export type RAGSyncSourceRunResult = {
1276
+ documentCount?: number;
1277
+ chunkCount?: number;
1278
+ reconciliation?: RAGSyncSourceReconciliationSummary;
1279
+ diagnostics?: RAGSyncSourceDiagnostics;
1280
+ metadata?: Record<string, unknown>;
1281
+ };
1282
+ export type RAGSyncSourceDefinition = {
1283
+ id: string;
1284
+ label: string;
1285
+ kind: RAGSyncSourceRecord["kind"];
1286
+ description?: string;
1287
+ target?: string;
1288
+ metadata?: Record<string, unknown>;
1289
+ retryAttempts?: number;
1290
+ retryDelayMs?: number;
1291
+ sync: (input: RAGSyncSourceContext) => Promise<RAGSyncSourceRunResult> | RAGSyncSourceRunResult;
1292
+ };
1293
+ export type RAGSyncSourceContext = {
1294
+ collection: RAGCollection;
1295
+ listDocuments?: () => Promise<RAGIndexedDocument[]> | RAGIndexedDocument[];
1296
+ deleteDocument?: (id: string) => Promise<boolean> | boolean;
1297
+ sourceRecord?: RAGSyncSourceRecord;
1298
+ signal?: AbortSignal;
1299
+ };
1300
+ export type RAGSQLiteStoreMigrationIssue = {
1301
+ tableName: string;
1302
+ columnName: string;
1303
+ definition: string;
1304
+ };
1305
+ export type RAGSQLiteStoreMigrationInspection = {
1306
+ issues: RAGSQLiteStoreMigrationIssue[];
1307
+ summary?: string;
1308
+ };
1309
+ export type RAGSQLiteStoreMigrationResult = RAGSQLiteStoreMigrationInspection & {
1310
+ applied: RAGSQLiteStoreMigrationIssue[];
1311
+ };
1312
+ export type RAGStorageSyncObject = {
1313
+ key: string;
1314
+ size?: number;
1315
+ etag?: string;
1316
+ lastModified?: number | string | Date;
1317
+ contentType?: string;
1318
+ metadata?: Record<string, unknown>;
1319
+ };
1320
+ export type RAGStorageSyncFile = {
1321
+ arrayBuffer: () => Promise<ArrayBuffer>;
1322
+ text?: () => Promise<string>;
1323
+ exists?: () => Promise<boolean>;
1324
+ };
1325
+ export type RAGStorageSyncListInput = {
1326
+ prefix?: string;
1327
+ startAfter?: string;
1328
+ maxKeys?: number;
1329
+ };
1330
+ export type RAGStorageSyncListResult = {
1331
+ contents: RAGStorageSyncObject[];
1332
+ isTruncated?: boolean;
1333
+ nextContinuationToken?: string;
1334
+ };
1335
+ export type RAGStorageSyncClient = {
1336
+ file: (key: string) => RAGStorageSyncFile;
1337
+ list: (input?: RAGStorageSyncListInput) => Promise<RAGStorageSyncListResult> | RAGStorageSyncListResult;
1338
+ };
1339
+ export type RAGDirectorySyncSourceOptions = {
1340
+ id: string;
1341
+ label: string;
1342
+ directory: string;
1343
+ description?: string;
1344
+ baseMetadata?: Record<string, unknown>;
1345
+ defaultChunking?: RAGChunkingOptions;
1346
+ chunkingRegistry?: RAGChunkingRegistryLike;
1347
+ extractors?: RAGFileExtractor[];
1348
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1349
+ includeExtensions?: string[];
1350
+ metadata?: Record<string, unknown>;
1351
+ recursive?: boolean;
1352
+ retryAttempts?: number;
1353
+ retryDelayMs?: number;
1354
+ };
1355
+ export type RAGUrlSyncSourceOptions = {
1356
+ id: string;
1357
+ label: string;
1358
+ urls: RAGDocumentUrlInput[];
1359
+ description?: string;
1360
+ baseMetadata?: Record<string, unknown>;
1361
+ defaultChunking?: RAGChunkingOptions;
1362
+ chunkingRegistry?: RAGChunkingRegistryLike;
1363
+ extractors?: RAGFileExtractor[];
1364
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1365
+ metadata?: Record<string, unknown>;
1366
+ retryAttempts?: number;
1367
+ retryDelayMs?: number;
1368
+ };
1369
+ export type RAGFeedSyncInput = {
1370
+ url: string;
1371
+ title?: string;
1372
+ metadata?: Record<string, unknown>;
1373
+ };
1374
+ export type RAGFeedSyncSourceOptions = {
1375
+ id: string;
1376
+ label: string;
1377
+ feeds: RAGFeedSyncInput[];
1378
+ description?: string;
1379
+ autoDiscoverFromHTML?: boolean;
1380
+ maxEntriesPerFeed?: number;
1381
+ maxDiscoveredFeeds?: number;
1382
+ baseMetadata?: Record<string, unknown>;
1383
+ defaultChunking?: RAGChunkingOptions;
1384
+ chunkingRegistry?: RAGChunkingRegistryLike;
1385
+ extractors?: RAGFileExtractor[];
1386
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1387
+ metadata?: Record<string, unknown>;
1388
+ retryAttempts?: number;
1389
+ retryDelayMs?: number;
1390
+ };
1391
+ export type RAGSitemapSyncInput = {
1392
+ url: string;
1393
+ title?: string;
1394
+ metadata?: Record<string, unknown>;
1395
+ };
1396
+ export type RAGSitemapSyncSourceOptions = {
1397
+ id: string;
1398
+ label: string;
1399
+ sitemaps: RAGSitemapSyncInput[];
1400
+ description?: string;
1401
+ maxUrlsPerSitemap?: number;
1402
+ autoDiscoverFromRobots?: boolean;
1403
+ maxNestedSitemaps?: number;
1404
+ baseMetadata?: Record<string, unknown>;
1405
+ defaultChunking?: RAGChunkingOptions;
1406
+ chunkingRegistry?: RAGChunkingRegistryLike;
1407
+ extractors?: RAGFileExtractor[];
1408
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1409
+ metadata?: Record<string, unknown>;
1410
+ retryAttempts?: number;
1411
+ retryDelayMs?: number;
1412
+ };
1413
+ export type RAGSiteDiscoveryInput = {
1414
+ url: string;
1415
+ title?: string;
1416
+ metadata?: Record<string, unknown>;
1417
+ };
1418
+ export type RAGSiteDiscoverySyncSourceOptions = {
1419
+ id: string;
1420
+ label: string;
1421
+ sites: RAGSiteDiscoveryInput[];
1422
+ description?: string;
1423
+ autoDiscoverFeeds?: boolean;
1424
+ autoDiscoverSitemaps?: boolean;
1425
+ autoDiscoverLinkedPages?: boolean;
1426
+ maxDiscoveredFeeds?: number;
1427
+ maxEntriesPerFeed?: number;
1428
+ maxUrlsPerSitemap?: number;
1429
+ maxNestedSitemaps?: number;
1430
+ maxLinkedPages?: number;
1431
+ maxLinksPerPage?: number;
1432
+ maxLinkDepth?: number;
1433
+ baseMetadata?: Record<string, unknown>;
1434
+ defaultChunking?: RAGChunkingOptions;
1435
+ chunkingRegistry?: RAGChunkingRegistryLike;
1436
+ extractors?: RAGFileExtractor[];
1437
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1438
+ metadata?: Record<string, unknown>;
1439
+ retryAttempts?: number;
1440
+ retryDelayMs?: number;
1441
+ };
1442
+ export type RAGGitHubRepoSyncInput = {
1443
+ owner: string;
1444
+ repo: string;
1445
+ branch?: string;
1446
+ pathPrefix?: string;
1447
+ includePaths?: string[];
1448
+ excludePaths?: string[];
1449
+ metadata?: Record<string, unknown>;
1450
+ };
1451
+ export type RAGGitHubSyncSourceOptions = {
1452
+ id: string;
1453
+ label: string;
1454
+ repos: RAGGitHubRepoSyncInput[];
1455
+ description?: string;
1456
+ apiBaseUrl?: string;
1457
+ token?: string;
1458
+ maxDepth?: number;
1459
+ maxFilesPerRepo?: number;
1460
+ includeExtensions?: string[];
1461
+ baseMetadata?: Record<string, unknown>;
1462
+ defaultChunking?: RAGChunkingOptions;
1463
+ chunkingRegistry?: RAGChunkingRegistryLike;
1464
+ extractors?: RAGFileExtractor[];
1465
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1466
+ metadata?: Record<string, unknown>;
1467
+ retryAttempts?: number;
1468
+ retryDelayMs?: number;
1469
+ };
1470
+ export type RAGStorageSyncSourceOptions = {
1471
+ id: string;
1472
+ label: string;
1473
+ client: RAGStorageSyncClient;
1474
+ description?: string;
1475
+ prefix?: string;
1476
+ keys?: string[];
1477
+ maxKeys?: number;
1478
+ baseMetadata?: Record<string, unknown>;
1479
+ defaultChunking?: RAGChunkingOptions;
1480
+ chunkingRegistry?: RAGChunkingRegistryLike;
1481
+ extractors?: RAGFileExtractor[];
1482
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1483
+ maxPagesPerRun?: number;
1484
+ metadata?: Record<string, unknown>;
1485
+ resumeFromLastCursor?: boolean;
1486
+ retryAttempts?: number;
1487
+ retryDelayMs?: number;
1488
+ };
1489
+ export type RAGEmailSyncAttachment = {
1490
+ id?: string;
1491
+ name: string;
1492
+ content: string | Uint8Array;
1493
+ contentType?: string;
1494
+ encoding?: "base64" | "utf8";
1495
+ format?: RAGContentFormat;
1496
+ source?: string;
1497
+ title?: string;
1498
+ metadata?: Record<string, unknown>;
1499
+ chunking?: RAGChunkingOptions;
1500
+ };
1501
+ export type RAGEmailSyncMessage = {
1502
+ id: string;
1503
+ threadId?: string;
1504
+ subject?: string;
1505
+ from?: string;
1506
+ to?: string[];
1507
+ cc?: string[];
1508
+ sentAt?: number | string | Date;
1509
+ receivedAt?: number | string | Date;
1510
+ bodyText: string;
1511
+ bodyHtml?: string;
1512
+ metadata?: Record<string, unknown>;
1513
+ attachments?: RAGEmailSyncAttachment[];
1514
+ };
1515
+ export type RAGEmailSyncListInput = {
1516
+ cursor?: string;
1517
+ maxResults?: number;
1518
+ };
1519
+ export type RAGEmailSyncListResult = {
1520
+ messages: RAGEmailSyncMessage[];
1521
+ nextCursor?: string;
1522
+ };
1523
+ export type RAGEmailSyncClient = {
1524
+ listMessages: (input?: RAGEmailSyncListInput) => Promise<RAGEmailSyncListResult> | RAGEmailSyncListResult;
1525
+ };
1526
+ export type RAGEmailSyncSourceOptions = {
1527
+ id: string;
1528
+ label: string;
1529
+ client: RAGEmailSyncClient;
1530
+ description?: string;
1531
+ maxResults?: number;
1532
+ baseMetadata?: Record<string, unknown>;
1533
+ defaultChunking?: RAGChunkingOptions;
1534
+ chunkingRegistry?: RAGChunkingRegistryLike;
1535
+ extractors?: RAGFileExtractor[];
1536
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1537
+ maxPagesPerRun?: number;
1538
+ metadata?: Record<string, unknown>;
1539
+ resumeFromLastCursor?: boolean;
1540
+ retryAttempts?: number;
1541
+ retryDelayMs?: number;
1542
+ };
1543
+ export type RAGGmailLinkedEmailSyncClientOptions = {
1544
+ resolver: RAGLinkedProviderCredentialResolver;
1545
+ ownerRef: string;
1546
+ bindingId?: string;
1547
+ externalAccountId?: string;
1548
+ purpose?: RAGLinkedProviderResolutionPurpose;
1549
+ requiredScopes?: string[];
1550
+ minValidityMs?: number;
1551
+ userId?: string;
1552
+ query?: string;
1553
+ labelIds?: string[];
1554
+ includeSpamTrash?: boolean;
1555
+ maxResults?: number;
1556
+ fetch?: typeof fetch;
1557
+ };
1558
+ export type RAGGmailLinkedEmailSyncSourceOptions = Omit<RAGEmailSyncSourceOptions, "client"> & RAGGmailLinkedEmailSyncClientOptions;
1559
+ export type RAGLinkedConnectorSyncSourceOptions = {
1560
+ id: string;
1561
+ label: string;
1562
+ runtime: RAGConnectorRuntime;
1563
+ resolver: RAGLinkedProviderCredentialResolver;
1564
+ ownerRef: string;
1565
+ bindingId?: string;
1566
+ externalAccountId?: string;
1567
+ purpose?: RAGLinkedProviderResolutionPurpose;
1568
+ requiredScopes?: string[];
1569
+ minValidityMs?: number;
1570
+ description?: string;
1571
+ maxItemsPerRun?: number;
1572
+ baseMetadata?: Record<string, unknown>;
1573
+ defaultChunking?: RAGChunkingOptions;
1574
+ chunkingRegistry?: RAGChunkingRegistryLike;
1575
+ extractors?: RAGFileExtractor[];
1576
+ extractorRegistry?: RAGFileExtractorRegistryLike;
1577
+ metadata?: Record<string, unknown>;
1578
+ retryAttempts?: number;
1579
+ retryDelayMs?: number;
1580
+ };
1581
+ export type RAGLinkedProviderFamily = LinkedProviderFamily;
1582
+ export type RAGConnectorProvider = LinkedConnectorProvider;
1583
+ export type RAGLinkedProviderAccountType = LinkedProviderAccountType;
1584
+ export type RAGLinkedProviderBindingStatus = LinkedProviderBindingStatus;
1585
+ export type RAGLinkedProviderResolutionPurpose = LinkedProviderResolutionPurpose;
1586
+ export type RAGLinkedProviderFailureCode = LinkedProviderFailureCode;
1587
+ export type RAGLinkedProviderBinding = LinkedProviderBinding;
1588
+ export type RAGResolvedLinkedProviderCredential = ResolvedLinkedProviderCredential;
1589
+ export type RAGLinkedProviderAccessTokenLease = LinkedProviderAccessTokenLease;
1590
+ export type RAGLinkedProviderCredentialFailureReport = LinkedProviderCredentialFailureReport;
1591
+ export type ResolveRAGLinkedProviderCredentialInput = ResolveLinkedProviderCredentialInput;
1592
+ export type RAGLinkedProviderCredentialResolver = LinkedProviderCredentialResolver;
1593
+ export type RAGConnectorCheckpoint = Record<string, unknown>;
1594
+ export type RAGConnectorItem = {
1595
+ id: string;
1596
+ kind: string;
1597
+ threadId?: string;
1598
+ title?: string;
1599
+ text?: string;
1600
+ html?: string;
1601
+ url?: string;
1602
+ createdAt?: number | string | Date;
1603
+ updatedAt?: number | string | Date;
1604
+ metadata?: Record<string, unknown>;
1605
+ attachments?: RAGEmailSyncAttachment[];
1606
+ };
1607
+ export type RAGConnectorSyncInput = {
1608
+ credential: RAGResolvedLinkedProviderCredential;
1609
+ resolver: RAGLinkedProviderCredentialResolver;
1610
+ checkpoint?: RAGConnectorCheckpoint;
1611
+ signal?: AbortSignal;
1612
+ };
1613
+ export type RAGConnectorSyncResult = {
1614
+ items: RAGConnectorItem[];
1615
+ nextCheckpoint?: RAGConnectorCheckpoint;
1616
+ diagnostics?: Record<string, unknown>;
1617
+ };
1618
+ export type RAGConnectorRuntime = {
1619
+ provider: RAGConnectorProvider;
1620
+ requiredScopes: (input?: {
1621
+ mode?: "read" | "write" | "messages";
1622
+ }) => string[];
1623
+ sync: (input: RAGConnectorSyncInput) => Promise<RAGConnectorSyncResult> | RAGConnectorSyncResult;
1624
+ };
1625
+ export type RAGSyncManager = Pick<RAGIndexManager, "listSyncSources" | "syncSource" | "syncAllSources">;
1626
+ export type RAGSyncRunOptions = {
1627
+ background?: boolean;
1628
+ };
1629
+ export type CreateRAGSyncManagerOptions = {
1630
+ collection: RAGCollection;
1631
+ deleteDocument?: (id: string) => Promise<boolean> | boolean;
1632
+ listDocuments?: () => Promise<RAGIndexedDocument[]> | RAGIndexedDocument[];
1633
+ loadState?: () => Promise<RAGSyncSourceRecord[]> | RAGSyncSourceRecord[];
1634
+ saveState?: (records: RAGSyncSourceRecord[]) => Promise<void> | void;
1635
+ backgroundByDefault?: boolean;
1636
+ continueOnError?: boolean;
1637
+ retryAttempts?: number;
1638
+ retryDelayMs?: number;
1639
+ sources: RAGSyncSourceDefinition[];
1640
+ };
1641
+ export type RAGSyncStateStore = {
1642
+ load: () => Promise<RAGSyncSourceRecord[]> | RAGSyncSourceRecord[];
1643
+ save: (records: RAGSyncSourceRecord[]) => Promise<void> | void;
1644
+ };
1645
+ export type RAGSyncSchedule = {
1646
+ id: string;
1647
+ label?: string;
1648
+ sourceIds?: string[];
1649
+ intervalMs: number;
1650
+ runImmediately?: boolean;
1651
+ background?: boolean;
1652
+ };
1653
+ export type RAGSyncScheduler = {
1654
+ start: () => Promise<void> | void;
1655
+ stop: () => void;
1656
+ isRunning: () => boolean;
1657
+ listSchedules: () => RAGSyncSchedule[];
1658
+ };
1659
+ export type RAGSyncResponse = {
1660
+ ok: true;
1661
+ source: RAGSyncSourceRecord;
1662
+ partial?: boolean;
1663
+ } | {
1664
+ ok: true;
1665
+ sources: RAGSyncSourceRecord[];
1666
+ partial?: boolean;
1667
+ failedSourceIds?: string[];
1668
+ errorsBySource?: Record<string, string>;
1669
+ } | {
1670
+ ok: false;
1671
+ error: string;
1672
+ };
1673
+ export type RAGExtractorReadiness = {
1674
+ providerConfigured: boolean;
1675
+ providerName?: string;
1676
+ model?: string;
1677
+ embeddingConfigured: boolean;
1678
+ embeddingModel?: string;
1679
+ rerankerConfigured: boolean;
1680
+ indexManagerConfigured: boolean;
1681
+ extractorsConfigured: boolean;
1682
+ extractorNames: string[];
1683
+ };
1684
+ export type RAGOperationsResponse = {
1685
+ ok: true;
1686
+ status?: RAGVectorStoreStatus;
1687
+ capabilities?: RAGBackendCapabilities;
1688
+ documents?: RAGDocumentSummary;
1689
+ admin: RAGAdminCapabilities;
1690
+ adminActions: RAGAdminActionRecord[];
1691
+ adminJobs: RAGAdminJobRecord[];
1692
+ maintenance?: RAGBackendMaintenanceSummary;
1693
+ health: RAGCorpusHealth;
1694
+ readiness: RAGExtractorReadiness;
1695
+ ingestJobs: RAGIngestJobRecord[];
1696
+ syncSources: RAGSyncSourceRecord[];
1697
+ searchTraces?: RAGSearchTraceRetentionRuntime;
1698
+ retrievalComparisons?: RAGRetrievalComparisonRuntime;
1699
+ };
1700
+ export type RAGStatusResponse = {
1701
+ ok: true;
1702
+ status?: RAGVectorStoreStatus;
1703
+ capabilities?: RAGBackendCapabilities;
1704
+ documents?: RAGDocumentSummary;
1705
+ admin?: RAGAdminCapabilities;
1706
+ adminActions?: RAGAdminActionRecord[];
1707
+ adminJobs?: RAGAdminJobRecord[];
1708
+ maintenance?: RAGBackendMaintenanceSummary;
1709
+ health?: RAGCorpusHealth;
1710
+ readiness?: RAGExtractorReadiness;
1711
+ ingestJobs?: RAGIngestJobRecord[];
1712
+ syncSources?: RAGSyncSourceRecord[];
1713
+ searchTraces?: RAGSearchTraceRetentionRuntime;
1714
+ retrievalComparisons?: RAGRetrievalComparisonRuntime;
1715
+ };
1716
+ export type RAGRetrievalReleaseStatusResponse = {
1717
+ ok: true;
1718
+ retrievalComparisons?: RAGRetrievalComparisonRuntime;
1719
+ };
1720
+ export type RAGRetrievalReleaseDriftStatusResponse = {
1721
+ ok: true;
1722
+ handoffDriftRollups?: RAGRetrievalComparisonRuntime["handoffDriftRollups"];
1723
+ handoffDriftCountsByLane?: RAGRetrievalComparisonRuntime["handoffDriftCountsByLane"];
1724
+ };
1725
+ export type RAGRemediationAction = {
1726
+ kind: "approve_candidate" | "acknowledge_incident" | "resolve_incident" | "view_release_status" | "view_release_drift" | "view_handoffs";
1727
+ label: string;
1728
+ method: "GET" | "POST";
1729
+ path: string;
1730
+ payload?: Record<string, unknown>;
1731
+ };
1732
+ export type RAGRemediationStep = {
1733
+ kind: "renew_approval" | "record_approval" | "inspect_gate" | "rerun_comparison" | "restore_source_lane" | "review_readiness" | "monitor_lane";
1734
+ label: string;
1735
+ actions?: RAGRemediationAction[];
1736
+ };
1737
+ export type RAGRetrievalLaneHandoffIncidentSummary = {
1738
+ openCount: number;
1739
+ resolvedCount: number;
1740
+ staleOpenCount: number;
1741
+ acknowledgedOpenCount: number;
1742
+ unacknowledgedOpenCount: number;
1743
+ latestTriggeredAt?: number;
1744
+ latestResolvedAt?: number;
1745
+ oldestOpenTriggeredAt?: number;
1746
+ oldestOpenAgeMs?: number;
1747
+ };
1748
+ export type RAGRetrievalLaneHandoffFreshnessWindow = {
1749
+ groupKey: string;
1750
+ sourceRolloutLabel?: RAGRetrievalLaneHandoffDecisionRecord["sourceRolloutLabel"];
1751
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
1752
+ candidateRetrievalId?: string;
1753
+ sourceRunId?: string;
1754
+ latestApprovedAt?: number;
1755
+ approvalAgeMs?: number;
1756
+ staleAfterMs?: number;
1757
+ expiresAt?: number;
1758
+ freshnessStatus: "fresh" | "expired" | "not_applicable";
1759
+ };
1760
+ export type RAGRetrievalLaneHandoffAutoCompleteSummary = {
1761
+ groupKey: string;
1762
+ sourceRolloutLabel?: RAGRetrievalLaneHandoffDecisionRecord["sourceRolloutLabel"];
1763
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
1764
+ candidateRetrievalId?: string;
1765
+ sourceRunId?: string;
1766
+ enabled: boolean;
1767
+ ready: boolean;
1768
+ maxApprovedDecisionAgeMs?: number;
1769
+ latestApprovedAt?: number;
1770
+ approvalAgeMs?: number;
1771
+ approvalExpiresAt?: number;
1772
+ freshnessStatus: "fresh" | "expired" | "not_applicable";
1773
+ reasons: string[];
1774
+ };
1775
+ export type RAGRetrievalLaneHandoffIncidentStatusResponse = {
1776
+ ok: true;
1777
+ incidents?: RAGRetrievalLaneHandoffIncidentRecord[];
1778
+ incidentSummary?: RAGRetrievalLaneHandoffIncidentSummary;
1779
+ freshnessWindows?: RAGRetrievalLaneHandoffFreshnessWindow[];
1780
+ recentHistory?: RAGRetrievalLaneHandoffIncidentHistoryRecord[];
1781
+ };
1782
+ export type RAGRetrievalLaneHandoffStatusResponse = {
1783
+ ok: true;
1784
+ handoffs?: RAGRetrievalReleaseLaneHandoffSummary[];
1785
+ decisions?: RAGRetrievalLaneHandoffDecisionRecord[];
1786
+ incidents?: RAGRetrievalLaneHandoffIncidentRecord[];
1787
+ incidentSummary?: RAGRetrievalLaneHandoffIncidentSummary;
1788
+ freshnessWindows?: RAGRetrievalLaneHandoffFreshnessWindow[];
1789
+ autoComplete?: RAGRetrievalLaneHandoffAutoCompleteSummary[];
1790
+ recentHistory?: RAGRetrievalLaneHandoffIncidentHistoryRecord[];
1791
+ };
1792
+ export type RAGSearchTraceStatsResponse = {
1793
+ ok: boolean;
1794
+ stats?: RAGSearchTraceStats;
1795
+ error?: string;
1796
+ };
1797
+ export type RAGSearchTracePrunePreviewResponse = {
1798
+ ok: boolean;
1799
+ preview?: RAGSearchTracePrunePreview;
1800
+ error?: string;
1801
+ };
1802
+ export type RAGSearchTracePruneResponse = {
1803
+ ok: boolean;
1804
+ result?: RAGSearchTracePruneResult;
1805
+ stats?: RAGSearchTraceStats;
1806
+ error?: string;
1807
+ };
1808
+ export type RAGSearchTracePruneHistoryResponse = {
1809
+ ok: boolean;
1810
+ runs?: RAGSearchTracePruneRun[];
1811
+ error?: string;
1812
+ };
1813
+ export type RAGDocumentsResponse = {
1814
+ ok: true;
1815
+ documents: RAGIndexedDocument[];
1816
+ lastSeedMsByMode?: Record<string, number>;
1817
+ };
1818
+ export type RAGDocumentChunksResponse = ({
1819
+ ok: true;
1820
+ } & RAGDocumentChunkPreview) | {
1821
+ ok: false;
1822
+ error: string;
1823
+ };
1824
+ export type RAGMutationResponse = {
1825
+ ok: boolean;
1826
+ error?: string;
1827
+ deleted?: string;
1828
+ inserted?: string;
1829
+ reindexed?: string;
1830
+ status?: string;
1831
+ documents?: number;
1832
+ maintenance?: RAGBackendMaintenanceSummary;
1833
+ workflowStatus?: RAGVectorStoreStatus;
1834
+ admin?: RAGAdminCapabilities;
1835
+ adminActions?: RAGAdminActionRecord[];
1836
+ adminJobs?: RAGAdminJobRecord[];
1837
+ backendStats?: Record<string, {
1838
+ chunkCount: number;
1839
+ totalDocuments: number;
1840
+ elapsedMs: number;
1841
+ }>;
1842
+ document?: RAGIndexedDocument;
1843
+ };
1844
+ export type RAGEvaluationCase = {
1845
+ id: string;
1846
+ query: string;
1847
+ corpusKey?: string;
1848
+ topK?: number;
1849
+ model?: string;
1850
+ scoreThreshold?: number;
1851
+ filter?: Record<string, unknown>;
1852
+ retrieval?: RAGCollectionSearchParams["retrieval"];
1853
+ expectedChunkIds?: string[];
1854
+ expectedSources?: string[];
1855
+ expectedDocumentIds?: string[];
1856
+ goldenSet?: boolean;
1857
+ hardNegativeChunkIds?: string[];
1858
+ hardNegativeSources?: string[];
1859
+ hardNegativeDocumentIds?: string[];
1860
+ label?: string;
1861
+ metadata?: Record<string, unknown>;
1862
+ };
1863
+ export type RAGAnswerGroundingEvaluationCase = {
1864
+ id: string;
1865
+ answer: string;
1866
+ sources: RAGSource[];
1867
+ query?: string;
1868
+ label?: string;
1869
+ expectedChunkIds?: string[];
1870
+ expectedSources?: string[];
1871
+ expectedDocumentIds?: string[];
1872
+ metadata?: Record<string, unknown>;
1873
+ };
1874
+ export type RAGAnswerGroundingEvaluationInput = {
1875
+ cases: RAGAnswerGroundingEvaluationCase[];
1876
+ };
1877
+ export type RAGAnswerGroundingEvaluationCaseResult = {
1878
+ caseId: string;
1879
+ answer: string;
1880
+ query?: string;
1881
+ label?: string;
1882
+ status: "pass" | "partial" | "fail";
1883
+ mode: "chunkId" | "source" | "documentId";
1884
+ coverage: RAGGroundedAnswer["coverage"];
1885
+ hasCitations: boolean;
1886
+ citationCount: number;
1887
+ referenceCount: number;
1888
+ resolvedCitationCount: number;
1889
+ unresolvedCitationCount: number;
1890
+ resolvedCitationRate: number;
1891
+ citationPrecision: number;
1892
+ citationRecall: number;
1893
+ citationF1: number;
1894
+ expectedCount: number;
1895
+ matchedCount: number;
1896
+ expectedIds: string[];
1897
+ citedIds: string[];
1898
+ matchedIds: string[];
1899
+ missingIds: string[];
1900
+ extraIds: string[];
1901
+ failureClasses?: Array<"no_expected_targets" | "no_citations" | "unresolved_citations" | "missing_expected_sources" | "extra_citations" | "section_source_miss" | "section_graph_source_miss" | "section_hierarchy_source_miss" | "spreadsheet_source_miss" | "media_source_miss" | "ocr_source_miss">;
1902
+ groundedAnswer: RAGGroundedAnswer;
1903
+ metadata?: Record<string, unknown>;
1904
+ };
1905
+ export type RAGAnswerGroundingEvaluationSummary = {
1906
+ totalCases: number;
1907
+ passedCases: number;
1908
+ partialCases: number;
1909
+ failedCases: number;
1910
+ groundedCases: number;
1911
+ partiallyGroundedCases: number;
1912
+ ungroundedCases: number;
1913
+ averageResolvedCitationRate: number;
1914
+ averageCitationPrecision: number;
1915
+ averageCitationRecall: number;
1916
+ averageCitationF1: number;
1917
+ };
1918
+ export type RAGAnswerGroundingEvaluationResponse = {
1919
+ ok: true;
1920
+ cases: RAGAnswerGroundingEvaluationCaseResult[];
1921
+ summary: RAGAnswerGroundingEvaluationSummary;
1922
+ totalCases: number;
1923
+ passingRate: number;
1924
+ };
1925
+ export type RAGAnswerGroundingEvaluationRun = {
1926
+ id: string;
1927
+ suiteId: string;
1928
+ label: string;
1929
+ startedAt: number;
1930
+ finishedAt: number;
1931
+ elapsedMs: number;
1932
+ response: RAGAnswerGroundingEvaluationResponse;
1933
+ metadata?: Record<string, unknown>;
1934
+ };
1935
+ export type RAGAnswerGroundingEvaluationHistoryStore = {
1936
+ saveRun: (run: RAGAnswerGroundingEvaluationRun) => Promise<void> | void;
1937
+ listRuns: (input?: {
1938
+ suiteId?: string;
1939
+ limit?: number;
1940
+ }) => Promise<RAGAnswerGroundingEvaluationRun[]> | RAGAnswerGroundingEvaluationRun[];
1941
+ pruneRuns?: (input?: RAGEvaluationHistoryPruneInput) => Promise<RAGEvaluationHistoryPruneResult> | RAGEvaluationHistoryPruneResult;
1942
+ };
1943
+ export type RAGAnswerGroundingEvaluationLeaderboardEntry = {
1944
+ runId: string;
1945
+ suiteId: string;
1946
+ label: string;
1947
+ passingRate: number;
1948
+ averageCitationF1: number;
1949
+ averageResolvedCitationRate: number;
1950
+ rank: number;
1951
+ totalCases: number;
1952
+ };
1953
+ export type RAGAnswerGroundingEvaluationCaseDifficultyEntry = {
1954
+ caseId: string;
1955
+ label?: string;
1956
+ query?: string;
1957
+ passRate: number;
1958
+ partialRate: number;
1959
+ failRate: number;
1960
+ groundedRate: number;
1961
+ averageCitationF1: number;
1962
+ averageResolvedCitationRate: number;
1963
+ rank: number;
1964
+ totalEvaluations: number;
1965
+ };
1966
+ export type RAGAnswerGroundingCaseDifficultyRun = {
1967
+ id: string;
1968
+ suiteId: string;
1969
+ label: string;
1970
+ startedAt: number;
1971
+ finishedAt: number;
1972
+ entries: RAGAnswerGroundingEvaluationCaseDifficultyEntry[];
1973
+ metadata?: Record<string, unknown>;
1974
+ };
1975
+ export type RAGAnswerGroundingCaseDifficultyHistoryStore = {
1976
+ saveRun: (run: RAGAnswerGroundingCaseDifficultyRun) => Promise<void> | void;
1977
+ listRuns: (input?: {
1978
+ suiteId?: string;
1979
+ limit?: number;
1980
+ }) => Promise<RAGAnswerGroundingCaseDifficultyRun[]> | RAGAnswerGroundingCaseDifficultyRun[];
1981
+ };
1982
+ export type RAGAnswerGroundingCaseDifficultyDiffEntry = {
1983
+ caseId: string;
1984
+ label?: string;
1985
+ query?: string;
1986
+ previousRank?: number;
1987
+ currentRank: number;
1988
+ previousPassRate?: number;
1989
+ currentPassRate: number;
1990
+ previousFailRate?: number;
1991
+ currentFailRate: number;
1992
+ previousAverageCitationF1?: number;
1993
+ currentAverageCitationF1: number;
1994
+ };
1995
+ export type RAGAnswerGroundingCaseDifficultyRunDiff = {
1996
+ suiteId: string;
1997
+ currentRunId: string;
1998
+ previousRunId?: string;
1999
+ harderCases: RAGAnswerGroundingCaseDifficultyDiffEntry[];
2000
+ easierCases: RAGAnswerGroundingCaseDifficultyDiffEntry[];
2001
+ unchangedCases: RAGAnswerGroundingCaseDifficultyDiffEntry[];
2002
+ };
2003
+ export type RAGAnswerGroundingCaseDifficultyHistory = {
2004
+ suiteId: string;
2005
+ suiteLabel?: string;
2006
+ runs: RAGAnswerGroundingCaseDifficultyRun[];
2007
+ latestRun?: RAGAnswerGroundingCaseDifficultyRun;
2008
+ previousRun?: RAGAnswerGroundingCaseDifficultyRun;
2009
+ diff?: RAGAnswerGroundingCaseDifficultyRunDiff;
2010
+ trends: {
2011
+ hardestCaseIds: string[];
2012
+ easiestCaseIds: string[];
2013
+ mostOftenHarderCaseIds: string[];
2014
+ mostOftenEasierCaseIds: string[];
2015
+ movementCounts: Record<string, {
2016
+ harder: number;
2017
+ easier: number;
2018
+ unchanged: number;
2019
+ }>;
2020
+ };
2021
+ };
2022
+ export type RAGAnswerGroundingEvaluationCaseDiff = {
2023
+ caseId: string;
2024
+ label?: string;
2025
+ query?: string;
2026
+ previousStatus?: RAGAnswerGroundingEvaluationCaseResult["status"];
2027
+ currentStatus: RAGAnswerGroundingEvaluationCaseResult["status"];
2028
+ previousCoverage?: RAGAnswerGroundingEvaluationCaseResult["coverage"];
2029
+ currentCoverage: RAGAnswerGroundingEvaluationCaseResult["coverage"];
2030
+ previousCitationF1?: number;
2031
+ currentCitationF1: number;
2032
+ previousCitedIds: string[];
2033
+ currentCitedIds: string[];
2034
+ previousMatchedIds: string[];
2035
+ currentMatchedIds: string[];
2036
+ previousMissingIds: string[];
2037
+ currentMissingIds: string[];
2038
+ previousExtraIds: string[];
2039
+ currentExtraIds: string[];
2040
+ previousFailureClasses?: NonNullable<RAGAnswerGroundingEvaluationCaseResult["failureClasses"]>;
2041
+ currentFailureClasses?: NonNullable<RAGAnswerGroundingEvaluationCaseResult["failureClasses"]>;
2042
+ previousReferenceCount?: number;
2043
+ currentReferenceCount: number;
2044
+ previousResolvedCitationCount?: number;
2045
+ currentResolvedCitationCount: number;
2046
+ previousUnresolvedCitationCount?: number;
2047
+ currentUnresolvedCitationCount: number;
2048
+ previousUngroundedReferenceNumbers: number[];
2049
+ currentUngroundedReferenceNumbers: number[];
2050
+ previousAnswer?: string;
2051
+ currentAnswer: string;
2052
+ answerChanged: boolean;
2053
+ };
2054
+ export type RAGAnswerGroundingEvaluationCaseSnapshot = {
2055
+ caseId: string;
2056
+ label?: string;
2057
+ query?: string;
2058
+ status: RAGAnswerGroundingEvaluationCaseResult["status"];
2059
+ coverage: RAGAnswerGroundingEvaluationCaseResult["coverage"];
2060
+ citationF1: number;
2061
+ resolvedCitationRate: number;
2062
+ citationCount: number;
2063
+ referenceCount: number;
2064
+ resolvedCitationCount: number;
2065
+ unresolvedCitationCount: number;
2066
+ citedIds: string[];
2067
+ matchedIds: string[];
2068
+ missingIds: string[];
2069
+ extraIds: string[];
2070
+ failureClasses?: NonNullable<RAGAnswerGroundingEvaluationCaseResult["failureClasses"]>;
2071
+ ungroundedReferenceNumbers: number[];
2072
+ answer: string;
2073
+ previousAnswer?: string;
2074
+ answerChange: "new" | "changed" | "unchanged";
2075
+ };
2076
+ export type RAGAnswerGroundingEvaluationRunDiff = {
2077
+ suiteId: string;
2078
+ currentRunId: string;
2079
+ previousRunId?: string;
2080
+ regressedCases: RAGAnswerGroundingEvaluationCaseDiff[];
2081
+ improvedCases: RAGAnswerGroundingEvaluationCaseDiff[];
2082
+ unchangedCases: RAGAnswerGroundingEvaluationCaseDiff[];
2083
+ summaryDelta: {
2084
+ passingRate: number;
2085
+ averageCitationF1: number;
2086
+ averageResolvedCitationRate: number;
2087
+ passedCases: number;
2088
+ failedCases: number;
2089
+ partialCases: number;
2090
+ };
2091
+ };
2092
+ export type RAGAnswerGroundingEvaluationHistory = {
2093
+ suiteId: string;
2094
+ suiteLabel?: string;
2095
+ runs: RAGAnswerGroundingEvaluationRun[];
2096
+ leaderboard: RAGAnswerGroundingEvaluationLeaderboardEntry[];
2097
+ latestRun?: RAGAnswerGroundingEvaluationRun;
2098
+ previousRun?: RAGAnswerGroundingEvaluationRun;
2099
+ caseSnapshots: RAGAnswerGroundingEvaluationCaseSnapshot[];
2100
+ diff?: RAGAnswerGroundingEvaluationRunDiff;
2101
+ };
2102
+ export type RAGAnswerGroundingCaseSnapshotPresentation = {
2103
+ caseId: string;
2104
+ label: string;
2105
+ summary: string;
2106
+ answerChange: RAGAnswerGroundingEvaluationCaseSnapshot["answerChange"];
2107
+ rows: RAGLabelValueRow[];
2108
+ };
2109
+ export type RAGEvaluationInput = {
2110
+ cases: RAGEvaluationCase[];
2111
+ topK?: number;
2112
+ scoreThreshold?: number;
2113
+ model?: string;
2114
+ filter?: Record<string, unknown>;
2115
+ retrieval?: RAGCollectionSearchParams["retrieval"];
2116
+ dryRun?: boolean;
2117
+ };
2118
+ export type RAGEvaluationCaseResult = {
2119
+ caseId: string;
2120
+ corpusKey?: string;
2121
+ query: string;
2122
+ label?: string;
2123
+ status: "pass" | "partial" | "fail";
2124
+ topK: number;
2125
+ elapsedMs: number;
2126
+ retrievedCount: number;
2127
+ expectedCount: number;
2128
+ matchedCount: number;
2129
+ precision: number;
2130
+ recall: number;
2131
+ f1: number;
2132
+ retrievedIds: string[];
2133
+ expectedIds: string[];
2134
+ matchedIds: string[];
2135
+ missingIds: string[];
2136
+ mode: "chunkId" | "source" | "documentId";
2137
+ failureClasses?: Array<"no_expected_targets" | "no_results" | "no_match" | "partial_recall" | "extra_noise" | "section_evidence_miss" | "section_graph_miss" | "section_hierarchy_miss" | "spreadsheet_evidence_miss" | "media_evidence_miss" | "ocr_evidence_miss" | "routing_miss">;
2138
+ metadata?: Record<string, unknown>;
2139
+ };
2140
+ export type RAGEvaluationSummary = {
2141
+ totalCases: number;
2142
+ passedCases: number;
2143
+ partialCases: number;
2144
+ failedCases: number;
2145
+ averagePrecision: number;
2146
+ averageRecall: number;
2147
+ averageF1: number;
2148
+ averageLatencyMs: number;
2149
+ };
2150
+ export type RAGEvaluationResponse = {
2151
+ ok: true;
2152
+ corpusKeys?: string[];
2153
+ cases: RAGEvaluationCaseResult[];
2154
+ summary: RAGEvaluationSummary;
2155
+ elapsedMs: number;
2156
+ totalCases: number;
2157
+ passingRate: number;
2158
+ };
2159
+ export type RAGEvaluationSuite = {
2160
+ id: string;
2161
+ label?: string;
2162
+ description?: string;
2163
+ input: RAGEvaluationInput;
2164
+ metadata?: Record<string, unknown>;
2165
+ };
2166
+ export type RAGEvaluationSuiteDatasetSummary = {
2167
+ suiteId: string;
2168
+ caseCount: number;
2169
+ goldenSetCount: number;
2170
+ hardNegativeCaseCount: number;
2171
+ hardNegativeChunkIdCount: number;
2172
+ hardNegativeSourceCount: number;
2173
+ hardNegativeDocumentIdCount: number;
2174
+ };
2175
+ export type RAGEvaluationSuiteGenerationOptions = {
2176
+ suiteId: string;
2177
+ documents: RAGIndexedDocument[];
2178
+ label?: string;
2179
+ description?: string;
2180
+ maxCases?: number;
2181
+ topK?: number;
2182
+ scoreThreshold?: number;
2183
+ filter?: Record<string, unknown>;
2184
+ retrieval?: RAGCollectionSearchParams["retrieval"];
2185
+ includeGoldenSet?: boolean;
2186
+ hardNegativePerCase?: number;
2187
+ metadata?: Record<string, unknown>;
2188
+ };
2189
+ export type RAGEvaluationSuiteSnapshot = {
2190
+ id: string;
2191
+ suiteId: string;
2192
+ label?: string;
2193
+ description?: string;
2194
+ version: number;
2195
+ createdAt: number;
2196
+ caseCount: number;
2197
+ suite: RAGEvaluationSuite;
2198
+ metadata?: Record<string, unknown>;
2199
+ };
2200
+ export type RAGEvaluationSuiteSnapshotDiff = {
2201
+ suiteId: string;
2202
+ currentSnapshotId: string;
2203
+ previousSnapshotId?: string;
2204
+ addedCaseIds: string[];
2205
+ removedCaseIds: string[];
2206
+ changedCaseIds: string[];
2207
+ unchangedCaseIds: string[];
2208
+ orderChanged: boolean;
2209
+ caseCountDelta: number;
2210
+ };
2211
+ export type RAGEvaluationSuiteSnapshotHistoryStore = {
2212
+ saveSnapshot: (snapshot: RAGEvaluationSuiteSnapshot) => Promise<void> | void;
2213
+ listSnapshots: (input?: {
2214
+ suiteId?: string;
2215
+ limit?: number;
2216
+ }) => Promise<RAGEvaluationSuiteSnapshot[]> | RAGEvaluationSuiteSnapshot[];
2217
+ pruneSnapshots?: (input?: RAGEvaluationHistoryPruneInput) => Promise<RAGEvaluationHistoryPruneResult> | RAGEvaluationHistoryPruneResult;
2218
+ };
2219
+ export type RAGEvaluationSuiteSnapshotHistory = {
2220
+ suiteId: string;
2221
+ suiteLabel?: string;
2222
+ snapshots: RAGEvaluationSuiteSnapshot[];
2223
+ latestSnapshot?: RAGEvaluationSuiteSnapshot;
2224
+ previousSnapshot?: RAGEvaluationSuiteSnapshot;
2225
+ diff?: RAGEvaluationSuiteSnapshotDiff;
2226
+ };
2227
+ export type RAGEvaluationSuiteRun = {
2228
+ id: string;
2229
+ suiteId: string;
2230
+ label: string;
2231
+ startedAt: number;
2232
+ finishedAt: number;
2233
+ elapsedMs: number;
2234
+ response: RAGEvaluationResponse;
2235
+ traceSummary?: RAGRetrievalTraceComparisonSummary;
2236
+ caseTraceSnapshots?: RAGEvaluationCaseTraceSnapshot[];
2237
+ metadata?: Record<string, unknown>;
2238
+ };
2239
+ export type RAGRetrievalTraceSummaryRun = {
2240
+ id: string;
2241
+ label?: string;
2242
+ finishedAt: number;
2243
+ traceSummary?: RAGRetrievalTraceComparisonSummary;
2244
+ };
2245
+ export type RAGEvaluationHistoryStore = {
2246
+ saveRun: (run: RAGEvaluationSuiteRun) => Promise<void> | void;
2247
+ listRuns: (input?: {
2248
+ suiteId?: string;
2249
+ limit?: number;
2250
+ }) => Promise<RAGEvaluationSuiteRun[]> | RAGEvaluationSuiteRun[];
2251
+ pruneRuns?: (input?: RAGEvaluationHistoryPruneInput) => Promise<RAGEvaluationHistoryPruneResult> | RAGEvaluationHistoryPruneResult;
2252
+ };
2253
+ export type RAGEvaluationHistoryPruneInput = {
2254
+ suiteId?: string;
2255
+ maxAgeMs?: number;
2256
+ maxRunsPerSuite?: number;
2257
+ now?: number;
2258
+ };
2259
+ export type RAGEvaluationHistoryPruneResult = {
2260
+ removedCount: number;
2261
+ keptCount: number;
2262
+ };
2263
+ export type RAGEvaluationCaseDiff = {
2264
+ caseId: string;
2265
+ label?: string;
2266
+ query: string;
2267
+ previousStatus?: RAGEvaluationCaseResult["status"];
2268
+ currentStatus: RAGEvaluationCaseResult["status"];
2269
+ previousF1?: number;
2270
+ currentF1: number;
2271
+ previousMatchedIds: string[];
2272
+ currentMatchedIds: string[];
2273
+ previousMissingIds: string[];
2274
+ currentMissingIds: string[];
2275
+ previousFailureClasses?: NonNullable<RAGEvaluationCaseResult["failureClasses"]>;
2276
+ currentFailureClasses?: NonNullable<RAGEvaluationCaseResult["failureClasses"]>;
2277
+ };
2278
+ export type RAGEvaluationRunDiff = {
2279
+ suiteId: string;
2280
+ currentRunId: string;
2281
+ previousRunId?: string;
2282
+ regressedCases: RAGEvaluationCaseDiff[];
2283
+ improvedCases: RAGEvaluationCaseDiff[];
2284
+ unchangedCases: RAGEvaluationCaseDiff[];
2285
+ traceLeadChanges?: Array<{
2286
+ caseId: string;
2287
+ label?: string;
2288
+ previousLead?: string;
2289
+ currentLead: string;
2290
+ }>;
2291
+ summaryDelta: {
2292
+ passingRate: number;
2293
+ averageF1: number;
2294
+ averageLatencyMs: number;
2295
+ passedCases: number;
2296
+ failedCases: number;
2297
+ partialCases: number;
2298
+ };
2299
+ traceSummaryDelta?: {
2300
+ modesChanged: boolean;
2301
+ sourceBalanceStrategiesChanged: boolean;
2302
+ vectorCases: number;
2303
+ lexicalCases: number;
2304
+ balancedCases: number;
2305
+ roundRobinCases: number;
2306
+ transformedCases: number;
2307
+ variantCases: number;
2308
+ averageFinalCount: number;
2309
+ averageVectorCount: number;
2310
+ averageLexicalCount: number;
2311
+ averageCandidateTopK: number;
2312
+ averageLexicalTopK: number;
2313
+ officeEvidenceReconcileCasesDelta: number;
2314
+ officeParagraphEvidenceReconcileCasesDelta?: number;
2315
+ officeListEvidenceReconcileCasesDelta?: number;
2316
+ officeTableEvidenceReconcileCasesDelta?: number;
2317
+ pdfEvidenceReconcileCasesDelta: number;
2318
+ stageCounts: Partial<Record<RAGRetrievalTraceStage, number>>;
2319
+ };
2320
+ };
2321
+ export type RAGEvaluationCaseTraceSnapshot = {
2322
+ caseId: string;
2323
+ corpusKey?: string;
2324
+ label?: string;
2325
+ query: string;
2326
+ status: RAGEvaluationCaseResult["status"];
2327
+ inputFilter?: Record<string, unknown>;
2328
+ previousInputFilter?: Record<string, unknown>;
2329
+ inputRetrieval?: RAGCollectionSearchParams["retrieval"];
2330
+ previousInputRetrieval?: RAGCollectionSearchParams["retrieval"];
2331
+ traceMode?: RAGHybridRetrievalMode;
2332
+ previousTraceMode?: RAGHybridRetrievalMode;
2333
+ sourceBalanceStrategy?: RAGSourceBalanceStrategy;
2334
+ previousSourceBalanceStrategy?: RAGSourceBalanceStrategy;
2335
+ transformedQuery?: string;
2336
+ previousTransformedQuery?: string;
2337
+ variantQueries: string[];
2338
+ previousVariantQueries: string[];
2339
+ finalCount: number;
2340
+ previousFinalCount?: number;
2341
+ vectorCount: number;
2342
+ previousVectorCount?: number;
2343
+ lexicalCount: number;
2344
+ previousLexicalCount?: number;
2345
+ candidateTopK: number;
2346
+ previousCandidateTopK?: number;
2347
+ lexicalTopK: number;
2348
+ previousLexicalTopK?: number;
2349
+ topContextLabel?: string;
2350
+ previousTopContextLabel?: string;
2351
+ topLocatorLabel?: string;
2352
+ previousTopLocatorLabel?: string;
2353
+ leadPresentationCue?: "body" | "notes" | "title";
2354
+ previousLeadPresentationCue?: "body" | "notes" | "title";
2355
+ leadSpreadsheetCue?: "column" | "sheet" | "table";
2356
+ previousLeadSpreadsheetCue?: "column" | "sheet" | "table";
2357
+ leadSpeakerCue?: string;
2358
+ previousLeadSpeakerCue?: string;
2359
+ leadSpeakerAttributionCue?: string;
2360
+ previousLeadSpeakerAttributionCue?: string;
2361
+ leadChannelCue?: string;
2362
+ previousLeadChannelCue?: string;
2363
+ leadChannelAttributionCue?: string;
2364
+ previousLeadChannelAttributionCue?: string;
2365
+ leadContinuityCue?: string;
2366
+ previousLeadContinuityCue?: string;
2367
+ sqliteQueryMode?: "json_fallback" | "native_vec0";
2368
+ previousSqliteQueryMode?: "json_fallback" | "native_vec0";
2369
+ sqliteQueryPushdownMode?: "none" | "partial" | "full";
2370
+ previousSqliteQueryPushdownMode?: "none" | "partial" | "full";
2371
+ sqliteQueryPushdownApplied?: boolean;
2372
+ previousSqliteQueryPushdownApplied?: boolean;
2373
+ sqliteQueryPushdownClauseCount?: number;
2374
+ previousSqliteQueryPushdownClauseCount?: number;
2375
+ sqliteQueryTotalFilterClauseCount?: number;
2376
+ previousSqliteQueryTotalFilterClauseCount?: number;
2377
+ sqliteQueryJsRemainderClauseCount?: number;
2378
+ previousSqliteQueryJsRemainderClauseCount?: number;
2379
+ sqliteQueryMultiplierUsed?: number;
2380
+ previousSqliteQueryMultiplierUsed?: number;
2381
+ sqliteQueryPlannerProfileUsed?: RAGNativeQueryProfile;
2382
+ previousSqliteQueryPlannerProfileUsed?: RAGNativeQueryProfile;
2383
+ sqliteQueryCandidateLimitUsed?: number;
2384
+ previousSqliteQueryCandidateLimitUsed?: number;
2385
+ sqliteQueryMaxBackfillsUsed?: number;
2386
+ previousSqliteQueryMaxBackfillsUsed?: number;
2387
+ sqliteQueryMinResultsUsed?: number;
2388
+ previousSqliteQueryMinResultsUsed?: number;
2389
+ sqliteQueryFillPolicyUsed?: "strict_topk" | "satisfy_min_results";
2390
+ previousSqliteQueryFillPolicyUsed?: "strict_topk" | "satisfy_min_results";
2391
+ sqliteQueryPushdownCoverageRatio?: number;
2392
+ previousSqliteQueryPushdownCoverageRatio?: number;
2393
+ sqliteQueryJsRemainderRatio?: number;
2394
+ previousSqliteQueryJsRemainderRatio?: number;
2395
+ sqliteQueryFilteredCandidates?: number;
2396
+ previousSqliteQueryFilteredCandidates?: number;
2397
+ sqliteQueryInitialSearchK?: number;
2398
+ previousSqliteQueryInitialSearchK?: number;
2399
+ sqliteQueryFinalSearchK?: number;
2400
+ previousSqliteQueryFinalSearchK?: number;
2401
+ sqliteQuerySearchExpansionRatio?: number;
2402
+ previousSqliteQuerySearchExpansionRatio?: number;
2403
+ sqliteQueryBackfillCount?: number;
2404
+ previousSqliteQueryBackfillCount?: number;
2405
+ sqliteQueryBackfillLimitReached?: boolean;
2406
+ previousSqliteQueryBackfillLimitReached?: boolean;
2407
+ sqliteQueryMinResultsSatisfied?: boolean;
2408
+ previousSqliteQueryMinResultsSatisfied?: boolean;
2409
+ sqliteQueryReturnedCount?: number;
2410
+ previousSqliteQueryReturnedCount?: number;
2411
+ sqliteQueryCandidateYieldRatio?: number;
2412
+ previousSqliteQueryCandidateYieldRatio?: number;
2413
+ sqliteQueryTopKFillRatio?: number;
2414
+ previousSqliteQueryTopKFillRatio?: number;
2415
+ sqliteQueryUnderfilledTopK?: boolean;
2416
+ previousSqliteQueryUnderfilledTopK?: boolean;
2417
+ sqliteQueryCandidateBudgetExhausted?: boolean;
2418
+ previousSqliteQueryCandidateBudgetExhausted?: boolean;
2419
+ sqliteQueryCandidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
2420
+ previousSqliteQueryCandidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
2421
+ postgresQueryMode?: "native_pgvector";
2422
+ previousPostgresQueryMode?: "native_pgvector";
2423
+ postgresQueryPushdownMode?: "none" | "partial" | "full";
2424
+ previousPostgresQueryPushdownMode?: "none" | "partial" | "full";
2425
+ postgresQueryPushdownApplied?: boolean;
2426
+ previousPostgresQueryPushdownApplied?: boolean;
2427
+ postgresQueryPushdownClauseCount?: number;
2428
+ previousPostgresQueryPushdownClauseCount?: number;
2429
+ postgresQueryTotalFilterClauseCount?: number;
2430
+ previousPostgresQueryTotalFilterClauseCount?: number;
2431
+ postgresQueryJsRemainderClauseCount?: number;
2432
+ previousPostgresQueryJsRemainderClauseCount?: number;
2433
+ postgresQueryMultiplierUsed?: number;
2434
+ previousPostgresQueryMultiplierUsed?: number;
2435
+ postgresQueryPlannerProfileUsed?: RAGNativeQueryProfile;
2436
+ previousPostgresQueryPlannerProfileUsed?: RAGNativeQueryProfile;
2437
+ postgresQueryCandidateLimitUsed?: number;
2438
+ previousPostgresQueryCandidateLimitUsed?: number;
2439
+ postgresQueryMaxBackfillsUsed?: number;
2440
+ previousPostgresQueryMaxBackfillsUsed?: number;
2441
+ postgresQueryMinResultsUsed?: number;
2442
+ previousPostgresQueryMinResultsUsed?: number;
2443
+ postgresQueryFillPolicyUsed?: "strict_topk" | "satisfy_min_results";
2444
+ previousPostgresQueryFillPolicyUsed?: "strict_topk" | "satisfy_min_results";
2445
+ postgresQueryPushdownCoverageRatio?: number;
2446
+ previousPostgresQueryPushdownCoverageRatio?: number;
2447
+ postgresQueryJsRemainderRatio?: number;
2448
+ previousPostgresQueryJsRemainderRatio?: number;
2449
+ postgresQueryFilteredCandidates?: number;
2450
+ previousPostgresQueryFilteredCandidates?: number;
2451
+ postgresQueryInitialSearchK?: number;
2452
+ previousPostgresQueryInitialSearchK?: number;
2453
+ postgresQueryFinalSearchK?: number;
2454
+ previousPostgresQueryFinalSearchK?: number;
2455
+ postgresQuerySearchExpansionRatio?: number;
2456
+ previousPostgresQuerySearchExpansionRatio?: number;
2457
+ postgresQueryBackfillCount?: number;
2458
+ previousPostgresQueryBackfillCount?: number;
2459
+ postgresQueryBackfillLimitReached?: boolean;
2460
+ previousPostgresQueryBackfillLimitReached?: boolean;
2461
+ postgresQueryMinResultsSatisfied?: boolean;
2462
+ previousPostgresQueryMinResultsSatisfied?: boolean;
2463
+ postgresQueryReturnedCount?: number;
2464
+ previousPostgresQueryReturnedCount?: number;
2465
+ postgresQueryCandidateYieldRatio?: number;
2466
+ previousPostgresQueryCandidateYieldRatio?: number;
2467
+ postgresQueryTopKFillRatio?: number;
2468
+ previousPostgresQueryTopKFillRatio?: number;
2469
+ postgresQueryUnderfilledTopK?: boolean;
2470
+ previousPostgresQueryUnderfilledTopK?: boolean;
2471
+ postgresQueryCandidateBudgetExhausted?: boolean;
2472
+ previousPostgresQueryCandidateBudgetExhausted?: boolean;
2473
+ postgresQueryCandidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
2474
+ previousPostgresQueryCandidateCoverage?: "empty" | "under_target" | "target_sized" | "broad";
2475
+ postgresIndexType?: "none" | "hnsw" | "ivfflat";
2476
+ previousPostgresIndexType?: "none" | "hnsw" | "ivfflat";
2477
+ postgresIndexName?: string;
2478
+ previousPostgresIndexName?: string;
2479
+ postgresIndexPresent?: boolean;
2480
+ previousPostgresIndexPresent?: boolean;
2481
+ postgresEstimatedRowCount?: number;
2482
+ previousPostgresEstimatedRowCount?: number;
2483
+ postgresTableBytes?: number;
2484
+ previousPostgresTableBytes?: number;
2485
+ postgresIndexBytes?: number;
2486
+ previousPostgresIndexBytes?: number;
2487
+ postgresTotalBytes?: number;
2488
+ previousPostgresTotalBytes?: number;
2489
+ postgresIndexStorageRatio?: number;
2490
+ previousPostgresIndexStorageRatio?: number;
2491
+ sourceAwareChunkReasonLabel?: string;
2492
+ previousSourceAwareChunkReasonLabel?: string;
2493
+ sourceAwareUnitScopeLabel?: string;
2494
+ previousSourceAwareUnitScopeLabel?: string;
2495
+ stageCounts: Partial<Record<RAGRetrievalTraceStage, number>>;
2496
+ previousStageCounts: Partial<Record<RAGRetrievalTraceStage, number>>;
2497
+ traceChange: "new" | "changed" | "unchanged";
2498
+ };
2499
+ export type RAGEvaluationHistory = {
2500
+ suiteId: string;
2501
+ suiteLabel?: string;
2502
+ runs: RAGEvaluationSuiteRun[];
2503
+ leaderboard: RAGEvaluationLeaderboardEntry[];
2504
+ retrievalTraceTrend?: RAGRetrievalTraceTrend;
2505
+ caseTraceSnapshots: RAGEvaluationCaseTraceSnapshot[];
2506
+ latestRun?: RAGEvaluationSuiteRun;
2507
+ previousRun?: RAGEvaluationSuiteRun;
2508
+ diff?: RAGEvaluationRunDiff;
2509
+ };
2510
+ export type RAGLabelValueRow = {
2511
+ label: string;
2512
+ value: string;
2513
+ };
2514
+ export type RAGRetrievalTraceStepPresentation = {
2515
+ stage: RAGRetrievalTraceStage;
2516
+ label: string;
2517
+ count?: number;
2518
+ rows: RAGLabelValueRow[];
2519
+ };
2520
+ export type RAGRetrievalTracePresentation = {
2521
+ stats: RAGLabelValueRow[];
2522
+ details: RAGLabelValueRow[];
2523
+ steps: RAGRetrievalTraceStepPresentation[];
2524
+ };
2525
+ export type RAGSummarySectionPresentation = {
2526
+ label: string;
2527
+ title: string;
2528
+ summary: string;
2529
+ rows?: RAGLabelValueRow[];
2530
+ tags?: string[];
2531
+ };
2532
+ export type RAGReadinessPresentation = {
2533
+ sections: RAGSummarySectionPresentation[];
2534
+ };
2535
+ export type RAGCorpusHealthPresentation = {
2536
+ sections: RAGSummarySectionPresentation[];
2537
+ };
2538
+ export type RAGSyncOverviewPresentation = {
2539
+ rows: RAGLabelValueRow[];
2540
+ sections: RAGSummarySectionPresentation[];
2541
+ };
2542
+ export type RAGSyncSourceRunPresentation = {
2543
+ label: string;
2544
+ status: string;
2545
+ summary: string;
2546
+ rows?: RAGLabelValueRow[];
2547
+ };
2548
+ export type RAGSyncSourcePresentation = {
2549
+ id: string;
2550
+ label: string;
2551
+ kind: RAGSyncSourceRecord["kind"];
2552
+ status: RAGSyncSourceRecord["status"];
2553
+ summary: string;
2554
+ rows: RAGLabelValueRow[];
2555
+ tags?: string[];
2556
+ extendedSummary?: string;
2557
+ runs?: RAGSyncSourceRunPresentation[];
2558
+ };
2559
+ export type RAGAdminJobPresentation = {
2560
+ id: string;
2561
+ action: RAGAdminJobRecord["action"];
2562
+ status: RAGAdminJobRecord["status"];
2563
+ summary: string;
2564
+ rows: RAGLabelValueRow[];
2565
+ };
2566
+ export type RAGAdminActionPresentation = {
2567
+ id: string;
2568
+ action: RAGAdminActionRecord["action"];
2569
+ status: RAGAdminActionRecord["status"];
2570
+ summary: string;
2571
+ rows: RAGLabelValueRow[];
2572
+ };
2573
+ export type RAGEvaluationCaseTracePresentation = {
2574
+ caseId: string;
2575
+ label: string;
2576
+ summary: string;
2577
+ traceChange: RAGEvaluationCaseTraceSnapshot["traceChange"];
2578
+ rows: RAGLabelValueRow[];
2579
+ };
2580
+ export type RAGEvaluationHistoryPresentation = {
2581
+ summary: string;
2582
+ rows: RAGLabelValueRow[];
2583
+ caseTraces: RAGEvaluationCaseTracePresentation[];
2584
+ };
2585
+ export type RAGEvaluationSuiteSnapshotPresentation = {
2586
+ id: string;
2587
+ label: string;
2588
+ summary: string;
2589
+ version: number;
2590
+ rows: RAGLabelValueRow[];
2591
+ };
2592
+ export type RAGEvaluationSuiteSnapshotHistoryPresentation = {
2593
+ summary: string;
2594
+ rows: RAGLabelValueRow[];
2595
+ snapshots: RAGEvaluationSuiteSnapshotPresentation[];
2596
+ };
2597
+ export type RAGAdaptiveNativePlannerBenchmarkRuntime = {
2598
+ suiteId: string;
2599
+ suiteLabel: string;
2600
+ groupKey?: string;
2601
+ corpusGroupKey?: string;
2602
+ latestFixtureVariant?: string;
2603
+ fixtureVariants?: string[];
2604
+ recommendedGroupKey?: string;
2605
+ recommendedTags?: string[];
2606
+ latestRun?: RAGRetrievalComparisonRun;
2607
+ recentRuns?: RAGRetrievalComparisonRun[];
2608
+ historyPresentation?: RAGRetrievalReleaseGroupHistoryPresentation;
2609
+ snapshotHistory?: RAGEvaluationSuiteSnapshotHistory;
2610
+ snapshotHistoryPresentation?: RAGEvaluationSuiteSnapshotHistoryPresentation;
2611
+ };
2612
+ export type RAGNativeBackendComparisonBenchmarkRuntime = RAGAdaptiveNativePlannerBenchmarkRuntime;
2613
+ export type RAGPresentationCueBenchmarkRuntime = RAGAdaptiveNativePlannerBenchmarkRuntime;
2614
+ export type RAGSpreadsheetCueBenchmarkRuntime = RAGAdaptiveNativePlannerBenchmarkRuntime;
2615
+ export type RAGAdaptiveNativePlannerBenchmarkResponse = {
2616
+ ok: boolean;
2617
+ suite?: RAGEvaluationSuite;
2618
+ comparison?: RAGRetrievalComparison;
2619
+ groupKey?: string;
2620
+ corpusGroupKey?: string;
2621
+ latestFixtureVariant?: string;
2622
+ fixtureVariants?: string[];
2623
+ latestRun?: RAGRetrievalComparisonRun;
2624
+ recentRuns?: RAGRetrievalComparisonRun[];
2625
+ historyPresentation?: RAGRetrievalReleaseGroupHistoryPresentation;
2626
+ snapshotHistory?: RAGEvaluationSuiteSnapshotHistory;
2627
+ snapshotHistoryPresentation?: RAGEvaluationSuiteSnapshotHistoryPresentation;
2628
+ error?: string;
2629
+ };
2630
+ export type RAGNativeBackendComparisonBenchmarkResponse = RAGAdaptiveNativePlannerBenchmarkResponse;
2631
+ export type RAGPresentationCueBenchmarkResponse = RAGAdaptiveNativePlannerBenchmarkResponse;
2632
+ export type RAGSpreadsheetCueBenchmarkResponse = RAGAdaptiveNativePlannerBenchmarkResponse;
2633
+ export type RAGAdaptiveNativePlannerBenchmarkSnapshotResponse = {
2634
+ ok: boolean;
2635
+ suite?: RAGEvaluationSuite;
2636
+ snapshot?: RAGEvaluationSuiteSnapshot;
2637
+ snapshotHistory?: RAGEvaluationSuiteSnapshotHistory;
2638
+ snapshotHistoryPresentation?: RAGEvaluationSuiteSnapshotHistoryPresentation;
2639
+ error?: string;
2640
+ };
2641
+ export type RAGNativeBackendComparisonBenchmarkSnapshotResponse = RAGAdaptiveNativePlannerBenchmarkSnapshotResponse;
2642
+ export type RAGPresentationCueBenchmarkSnapshotResponse = RAGAdaptiveNativePlannerBenchmarkSnapshotResponse;
2643
+ export type RAGSpreadsheetCueBenchmarkSnapshotResponse = RAGAdaptiveNativePlannerBenchmarkSnapshotResponse;
2644
+ export type RAGRetrievalReleaseHistoryRunPresentation = {
2645
+ runId: string;
2646
+ label: string;
2647
+ summary: string;
2648
+ rows: RAGLabelValueRow[];
2649
+ };
2650
+ export type RAGRetrievalReleaseGroupHistoryPresentation = {
2651
+ summary: string;
2652
+ rows: RAGLabelValueRow[];
2653
+ recentRuns: RAGRetrievalReleaseHistoryRunPresentation[];
2654
+ };
2655
+ export type RAGAnswerGroundingHistoryPresentation = {
2656
+ summary: string;
2657
+ rows: RAGLabelValueRow[];
2658
+ caseSnapshots: RAGAnswerGroundingCaseSnapshotPresentation[];
2659
+ };
2660
+ export type RAGEvaluationEntityQualitySummary = {
2661
+ key: string;
2662
+ label: string;
2663
+ entityType: "source" | "document";
2664
+ totalCases: number;
2665
+ passedCases: number;
2666
+ partialCases: number;
2667
+ failedCases: number;
2668
+ passingRate: number;
2669
+ averageF1: number;
2670
+ failureCounts: Record<string, number>;
2671
+ caseIds: string[];
2672
+ };
2673
+ export type RAGAnswerGroundingEntityQualitySummary = {
2674
+ key: string;
2675
+ label: string;
2676
+ entityType: "source" | "document";
2677
+ totalCases: number;
2678
+ passedCases: number;
2679
+ partialCases: number;
2680
+ failedCases: number;
2681
+ passingRate: number;
2682
+ averageCitationF1: number;
2683
+ averageResolvedCitationRate: number;
2684
+ failureCounts: Record<string, number>;
2685
+ caseIds: string[];
2686
+ };
2687
+ export type RAGEvaluationEntityQualityView = {
2688
+ bySource: RAGEvaluationEntityQualitySummary[];
2689
+ byDocument: RAGEvaluationEntityQualitySummary[];
2690
+ };
2691
+ export type RAGAnswerGroundingEntityQualityView = {
2692
+ bySource: RAGAnswerGroundingEntityQualitySummary[];
2693
+ byDocument: RAGAnswerGroundingEntityQualitySummary[];
2694
+ };
2695
+ export type RAGEntityQualityPresentation = {
2696
+ key: string;
2697
+ label: string;
2698
+ summary: string;
2699
+ rows: RAGLabelValueRow[];
2700
+ };
2701
+ export type RAGEntityQualityViewPresentation = {
2702
+ summary: string;
2703
+ rows: RAGLabelValueRow[];
2704
+ entities: RAGEntityQualityPresentation[];
2705
+ };
2706
+ export type RAGComparisonPresentation = {
2707
+ id: string;
2708
+ label: string;
2709
+ summary: string;
2710
+ traceSummaryRows: RAGLabelValueRow[];
2711
+ diffLabel: string;
2712
+ diffRows: RAGLabelValueRow[];
2713
+ };
2714
+ export type RAGComparisonOverviewPresentation = {
2715
+ winnerLabel: string;
2716
+ summary: string;
2717
+ rows: RAGLabelValueRow[];
2718
+ };
2719
+ export type RAGGroundingProviderPresentation = {
2720
+ id: string;
2721
+ label: string;
2722
+ summary: string;
2723
+ };
2724
+ export type RAGGroundingProviderOverviewPresentation = {
2725
+ winnerLabel: string;
2726
+ summary: string;
2727
+ rows: RAGLabelValueRow[];
2728
+ };
2729
+ export type RAGQualityOverviewPresentation = {
2730
+ rows: RAGLabelValueRow[];
2731
+ };
2732
+ export type RAGGroundingOverviewPresentation = {
2733
+ rows: RAGLabelValueRow[];
2734
+ };
2735
+ export type RAGGroundingProviderCaseComparisonPresentation = {
2736
+ caseId: string;
2737
+ label: string;
2738
+ summary: string;
2739
+ rows: RAGLabelValueRow[];
2740
+ };
2741
+ export type RAGEvaluationLeaderboardEntry = {
2742
+ runId: string;
2743
+ suiteId: string;
2744
+ label: string;
2745
+ passingRate: number;
2746
+ averageF1: number;
2747
+ averageLatencyMs: number;
2748
+ totalCases: number;
2749
+ rank: number;
2750
+ };
2751
+ export type RAGRerankerCandidate = {
2752
+ id: string;
2753
+ label?: string;
2754
+ rerank?: RAGRerankerProviderLike;
2755
+ };
2756
+ export type RAGRetrievalTraceComparisonSummary = {
2757
+ totalCases: number;
2758
+ modes: RAGHybridRetrievalMode[];
2759
+ sourceBalanceStrategies: RAGSourceBalanceStrategy[];
2760
+ vectorCases: number;
2761
+ lexicalCases: number;
2762
+ balancedCases: number;
2763
+ roundRobinCases: number;
2764
+ transformedCases: number;
2765
+ variantCases: number;
2766
+ multiVectorCases: number;
2767
+ multiVectorVectorHitCases: number;
2768
+ multiVectorLexicalHitCases: number;
2769
+ multiVectorCollapsedCases: number;
2770
+ officeEvidenceReconcileCases: number;
2771
+ officeParagraphEvidenceReconcileCases?: number;
2772
+ officeListEvidenceReconcileCases?: number;
2773
+ officeTableEvidenceReconcileCases?: number;
2774
+ pdfEvidenceReconcileCases: number;
2775
+ runtimeCandidateBudgetExhaustedCases: number;
2776
+ runtimeUnderfilledTopKCases: number;
2777
+ averageFinalCount: number;
2778
+ averageVectorCount: number;
2779
+ averageLexicalCount: number;
2780
+ averageCandidateTopK: number;
2781
+ averageLexicalTopK: number;
2782
+ stageCounts: Partial<Record<RAGRetrievalTraceStage, number>>;
2783
+ };
2784
+ export type RAGTraceSummaryListDelta<T extends string> = {
2785
+ current: T[];
2786
+ previous: T[];
2787
+ added: T[];
2788
+ removed: T[];
2789
+ };
2790
+ export type RAGTraceSummaryTrendDirection = "flat" | "up" | "down";
2791
+ export type RAGTraceSummaryNumericDelta = {
2792
+ metric: string;
2793
+ current: number;
2794
+ previous: number;
2795
+ delta: number;
2796
+ direction: RAGTraceSummaryTrendDirection;
2797
+ };
2798
+ export type RAGTraceSummaryListTrend<T extends string> = {
2799
+ current: T[];
2800
+ previous: T[];
2801
+ appeared: T[];
2802
+ disappeared: T[];
2803
+ stable: T[];
2804
+ frequency: Record<T, number>;
2805
+ };
2806
+ export type RAGTraceSummaryStageTrend = {
2807
+ netDelta: number;
2808
+ latestDelta: number;
2809
+ stage: RAGRetrievalTraceStage;
2810
+ totalChanges: number;
2811
+ };
2812
+ export type RAGRetrievalTraceHistoryWindow = {
2813
+ current: RAGRetrievalTraceComparisonSummary;
2814
+ currentRunId: string;
2815
+ currentRunLabel?: string;
2816
+ delta?: RAGRetrievalTraceComparisonSummaryDiff;
2817
+ previous: RAGRetrievalTraceComparisonSummary;
2818
+ previousRunId: string;
2819
+ previousRunLabel?: string;
2820
+ };
2821
+ export type RAGRetrievalTraceTrend = {
2822
+ aggregate: RAGTraceSummaryNumericDelta[];
2823
+ latestToPrevious?: RAGRetrievalTraceComparisonSummaryDiff;
2824
+ modeTurnover: RAGTraceSummaryListTrend<RAGHybridRetrievalMode>;
2825
+ runsWithTraceSummary: number;
2826
+ stageChurn: RAGTraceSummaryStageTrend[];
2827
+ sourceBalanceStrategyTurnover: RAGTraceSummaryListTrend<RAGSourceBalanceStrategy>;
2828
+ summaryTrendWindows: RAGRetrievalTraceHistoryWindow[];
2829
+ worstMetric: RAGTraceSummaryNumericDelta | undefined;
2830
+ bestMetric: RAGTraceSummaryNumericDelta | undefined;
2831
+ worstVolatileStage: RAGTraceSummaryStageTrend | undefined;
2832
+ };
2833
+ export type RAGSearchTraceResultSnapshot = {
2834
+ chunkId: string;
2835
+ corpusKey?: string;
2836
+ score: number;
2837
+ source?: string;
2838
+ title?: string;
2839
+ documentId?: string;
2840
+ };
2841
+ export type RAGSearchTraceRecord = {
2842
+ id: string;
2843
+ label: string;
2844
+ query: string;
2845
+ groupKey?: string;
2846
+ tags?: string[];
2847
+ startedAt: number;
2848
+ finishedAt: number;
2849
+ elapsedMs: number;
2850
+ trace: RAGRetrievalTrace;
2851
+ summary: RAGRetrievalTraceComparisonSummary;
2852
+ results: RAGSearchTraceResultSnapshot[];
2853
+ metadata?: Record<string, unknown>;
2854
+ };
2855
+ export type RAGSearchTraceStore = {
2856
+ saveTrace: (trace: RAGSearchTraceRecord) => Promise<void> | void;
2857
+ listTraces: (input?: {
2858
+ query?: string;
2859
+ groupKey?: string;
2860
+ tag?: string;
2861
+ limit?: number;
2862
+ }) => Promise<RAGSearchTraceRecord[]> | RAGSearchTraceRecord[];
2863
+ pruneTraces: (input?: RAGSearchTracePruneInput) => Promise<RAGSearchTracePruneResult> | RAGSearchTracePruneResult;
2864
+ };
2865
+ export type RAGSearchTracePruneInput = {
2866
+ maxAgeMs?: number;
2867
+ maxRecordsPerQuery?: number;
2868
+ maxRecordsPerGroup?: number;
2869
+ now?: number;
2870
+ tag?: string;
2871
+ };
2872
+ export type RAGSearchTracePruneResult = {
2873
+ removedCount: number;
2874
+ keptCount: number;
2875
+ };
2876
+ export type RAGSearchTraceStats = {
2877
+ totalTraces: number;
2878
+ queryCount: number;
2879
+ groupCount: number;
2880
+ tagCounts: Record<string, number>;
2881
+ oldestFinishedAt?: number;
2882
+ newestFinishedAt?: number;
2883
+ };
2884
+ export type RAGSearchTracePrunePreview = {
2885
+ input?: RAGSearchTracePruneInput;
2886
+ statsBefore: RAGSearchTraceStats;
2887
+ statsAfter: RAGSearchTraceStats;
2888
+ result: RAGSearchTracePruneResult;
2889
+ };
2890
+ export type RAGSearchTraceRetentionSchedule = {
2891
+ intervalMs: number;
2892
+ runImmediately?: boolean;
2893
+ };
2894
+ export type RAGSearchTraceRetentionRuntime = {
2895
+ configured: boolean;
2896
+ retention?: RAGSearchTracePruneInput;
2897
+ schedule?: RAGSearchTraceRetentionSchedule;
2898
+ stats?: RAGSearchTraceStats;
2899
+ running?: boolean;
2900
+ totalRuns?: number;
2901
+ lastStartedAt?: number;
2902
+ lastFinishedAt?: number;
2903
+ lastResult?: RAGSearchTracePruneResult;
2904
+ lastError?: string;
2905
+ nextScheduledAt?: number;
2906
+ recentRuns?: RAGSearchTracePruneRun[];
2907
+ };
2908
+ export type RAGSearchTracePruneRun = {
2909
+ id: string;
2910
+ startedAt: number;
2911
+ finishedAt: number;
2912
+ elapsedMs: number;
2913
+ trigger: "manual" | "write" | "schedule";
2914
+ input?: RAGSearchTracePruneInput;
2915
+ result?: RAGSearchTracePruneResult;
2916
+ statsBefore?: RAGSearchTraceStats;
2917
+ statsAfter?: RAGSearchTraceStats;
2918
+ error?: string;
2919
+ };
2920
+ export type RAGSearchTracePruneHistoryStore = {
2921
+ saveRun: (run: RAGSearchTracePruneRun) => Promise<void> | void;
2922
+ listRuns: (input?: {
2923
+ limit?: number;
2924
+ trigger?: RAGSearchTracePruneRun["trigger"];
2925
+ }) => Promise<RAGSearchTracePruneRun[]> | RAGSearchTracePruneRun[];
2926
+ };
2927
+ export type RAGSearchTraceDiff = {
2928
+ currentTraceId: string;
2929
+ previousTraceId?: string;
2930
+ summaryDelta?: RAGRetrievalTraceComparisonSummaryDiff;
2931
+ addedChunkIds: string[];
2932
+ removedChunkIds: string[];
2933
+ retainedChunkIds: string[];
2934
+ topResultChanged: boolean;
2935
+ };
2936
+ export type RAGSearchTraceHistory = {
2937
+ query?: string;
2938
+ groupKey?: string;
2939
+ tag?: string;
2940
+ traces: RAGSearchTraceRecord[];
2941
+ latestTrace?: RAGSearchTraceRecord;
2942
+ previousTrace?: RAGSearchTraceRecord;
2943
+ diff?: RAGSearchTraceDiff;
2944
+ retrievalTraceTrend: RAGRetrievalTraceTrend;
2945
+ };
2946
+ export type RAGSearchTraceGroupHistoryEntry = {
2947
+ groupKey: string;
2948
+ traceCount: number;
2949
+ latestTrace?: RAGSearchTraceRecord;
2950
+ previousTrace?: RAGSearchTraceRecord;
2951
+ diff?: RAGSearchTraceDiff;
2952
+ retrievalTraceTrend: RAGRetrievalTraceTrend;
2953
+ };
2954
+ export type RAGSearchTraceGroupHistory = {
2955
+ groups: RAGSearchTraceGroupHistoryEntry[];
2956
+ tag?: string;
2957
+ };
2958
+ export type RAGTraceSummaryStageCountsDelta = {
2959
+ previous: number;
2960
+ current: number;
2961
+ delta: number;
2962
+ };
2963
+ export type RAGRetrievalTraceComparisonSummaryDiff = {
2964
+ current: RAGRetrievalTraceComparisonSummary;
2965
+ previous: RAGRetrievalTraceComparisonSummary;
2966
+ totalCasesDelta: number;
2967
+ averageFinalCountDelta: number;
2968
+ averageVectorCountDelta: number;
2969
+ averageLexicalCountDelta: number;
2970
+ averageCandidateTopKDelta: number;
2971
+ averageLexicalTopKDelta: number;
2972
+ vectorCasesDelta: number;
2973
+ lexicalCasesDelta: number;
2974
+ balancedCasesDelta: number;
2975
+ roundRobinCasesDelta: number;
2976
+ transformedCasesDelta: number;
2977
+ variantCasesDelta: number;
2978
+ multiVectorCasesDelta: number;
2979
+ multiVectorVectorHitCasesDelta: number;
2980
+ multiVectorLexicalHitCasesDelta: number;
2981
+ multiVectorCollapsedCasesDelta: number;
2982
+ officeEvidenceReconcileCasesDelta: number;
2983
+ officeParagraphEvidenceReconcileCasesDelta?: number;
2984
+ officeListEvidenceReconcileCasesDelta?: number;
2985
+ officeTableEvidenceReconcileCasesDelta?: number;
2986
+ pdfEvidenceReconcileCasesDelta: number;
2987
+ runtimeCandidateBudgetExhaustedCasesDelta: number;
2988
+ runtimeUnderfilledTopKCasesDelta: number;
2989
+ modeDelta: RAGTraceSummaryListDelta<RAGHybridRetrievalMode>;
2990
+ sourceBalanceStrategyDelta: RAGTraceSummaryListDelta<RAGSourceBalanceStrategy>;
2991
+ stageCountsDelta: Partial<Record<RAGRetrievalTraceStage, RAGTraceSummaryStageCountsDelta>>;
2992
+ };
2993
+ export type RAGRetrievalCandidate = {
2994
+ id: string;
2995
+ label?: string;
2996
+ retrieval?: RAGCollectionSearchParams["retrieval"];
2997
+ queryTransform?: RAGQueryTransformProviderLike;
2998
+ rerank?: RAGRerankerProviderLike;
2999
+ };
3000
+ export type RAGRerankerComparisonEntry = {
3001
+ rerankerId: string;
3002
+ label: string;
3003
+ providerName?: string;
3004
+ response: RAGEvaluationResponse;
3005
+ traceSummary?: RAGRetrievalTraceComparisonSummary;
3006
+ caseTraceSnapshots?: RAGEvaluationCaseTraceSnapshot[];
3007
+ };
3008
+ export type RAGRerankerComparisonSummary = {
3009
+ bestByPassingRate?: string;
3010
+ bestByAverageF1?: string;
3011
+ fastest?: string;
3012
+ };
3013
+ export type RAGRerankerComparison = {
3014
+ suiteId: string;
3015
+ suiteLabel: string;
3016
+ entries: RAGRerankerComparisonEntry[];
3017
+ summary: RAGRerankerComparisonSummary;
3018
+ leaderboard: RAGEvaluationLeaderboardEntry[];
3019
+ };
3020
+ export type RAGRetrievalComparisonEntry = {
3021
+ retrievalId: string;
3022
+ label: string;
3023
+ retrievalMode: RAGHybridRetrievalMode;
3024
+ response: RAGEvaluationResponse;
3025
+ traceSummary?: RAGRetrievalTraceComparisonSummary;
3026
+ caseTraceSnapshots?: RAGEvaluationCaseTraceSnapshot[];
3027
+ };
3028
+ export type RAGRetrievalComparisonSummary = {
3029
+ bestByPassingRate?: string;
3030
+ bestByAverageF1?: string;
3031
+ fastest?: string;
3032
+ bestByPresentationTitleCueCases?: string;
3033
+ bestByPresentationBodyCueCases?: string;
3034
+ bestByPresentationNotesCueCases?: string;
3035
+ bestBySpreadsheetSheetCueCases?: string;
3036
+ bestBySpreadsheetTableCueCases?: string;
3037
+ bestBySpreadsheetColumnCueCases?: string;
3038
+ bestByMultivectorCollapsedCases?: string;
3039
+ bestByMultivectorLexicalHitCases?: string;
3040
+ bestByMultivectorVectorHitCases?: string;
3041
+ bestByEvidenceReconcileCases?: string;
3042
+ bestByOfficeEvidenceReconcileCases?: string;
3043
+ bestByOfficeParagraphEvidenceReconcileCases?: string;
3044
+ bestByOfficeListEvidenceReconcileCases?: string;
3045
+ bestByOfficeTableEvidenceReconcileCases?: string;
3046
+ bestByPDFEvidenceReconcileCases?: string;
3047
+ bestByLowestRuntimeCandidateBudgetExhaustedCases?: string;
3048
+ bestByLowestRuntimeUnderfilledTopKCases?: string;
3049
+ };
3050
+ export type RAGRetrievalComparison = {
3051
+ suiteId: string;
3052
+ suiteLabel: string;
3053
+ corpusGroupKey?: string;
3054
+ corpusKeys?: string[];
3055
+ entries: RAGRetrievalComparisonEntry[];
3056
+ summary: RAGRetrievalComparisonSummary;
3057
+ leaderboard: RAGEvaluationLeaderboardEntry[];
3058
+ };
3059
+ export type RAGRetrievalComparisonCandidateInput = {
3060
+ id: string;
3061
+ label?: string;
3062
+ retrieval?: RAGCollectionSearchParams["retrieval"];
3063
+ };
3064
+ export type RAGRetrievalComparisonRequest = RAGEvaluationInput & {
3065
+ retrievals: RAGRetrievalComparisonCandidateInput[];
3066
+ suiteId?: string;
3067
+ label?: string;
3068
+ persistRun?: boolean;
3069
+ baselineRetrievalId?: string;
3070
+ candidateRetrievalId?: string;
3071
+ corpusGroupKey?: string;
3072
+ groupKey?: string;
3073
+ tags?: string[];
3074
+ };
3075
+ export type RAGRetrievalComparisonResponse = {
3076
+ ok: boolean;
3077
+ comparison?: RAGRetrievalComparison;
3078
+ error?: string;
3079
+ };
3080
+ export type RAGRetrievalComparisonRun = {
3081
+ id: string;
3082
+ label: string;
3083
+ suiteId: string;
3084
+ suiteLabel: string;
3085
+ corpusGroupKey?: string;
3086
+ corpusKeys?: string[];
3087
+ groupKey?: string;
3088
+ tags?: string[];
3089
+ startedAt: number;
3090
+ finishedAt: number;
3091
+ elapsedMs: number;
3092
+ comparison: RAGRetrievalComparison;
3093
+ decisionSummary?: RAGRetrievalComparisonDecisionSummary;
3094
+ releaseVerdict?: RAGRetrievalReleaseVerdict;
3095
+ };
3096
+ export type RAGRetrievalComparisonDecisionDelta = {
3097
+ passingRateDelta: number;
3098
+ averageF1Delta: number;
3099
+ elapsedMsDelta: number;
3100
+ presentationTitleCueCasesDelta?: number;
3101
+ presentationBodyCueCasesDelta?: number;
3102
+ presentationNotesCueCasesDelta?: number;
3103
+ spreadsheetSheetCueCasesDelta?: number;
3104
+ spreadsheetTableCueCasesDelta?: number;
3105
+ spreadsheetColumnCueCasesDelta?: number;
3106
+ multiVectorCollapsedCasesDelta?: number;
3107
+ multiVectorLexicalHitCasesDelta?: number;
3108
+ multiVectorVectorHitCasesDelta?: number;
3109
+ evidenceReconcileCasesDelta?: number;
3110
+ officeEvidenceReconcileCasesDelta?: number;
3111
+ officeParagraphEvidenceReconcileCasesDelta?: number;
3112
+ officeListEvidenceReconcileCasesDelta?: number;
3113
+ officeTableEvidenceReconcileCasesDelta?: number;
3114
+ pdfEvidenceReconcileCasesDelta?: number;
3115
+ runtimeCandidateBudgetExhaustedCasesDelta?: number;
3116
+ runtimeUnderfilledTopKCasesDelta?: number;
3117
+ };
3118
+ export type RAGRetrievalBaselineGatePolicy = {
3119
+ minPassingRateDelta?: number;
3120
+ minAverageF1Delta?: number;
3121
+ maxElapsedMsDelta?: number;
3122
+ minPresentationTitleCueCasesDelta?: number;
3123
+ minPresentationBodyCueCasesDelta?: number;
3124
+ minPresentationNotesCueCasesDelta?: number;
3125
+ minSpreadsheetSheetCueCasesDelta?: number;
3126
+ minSpreadsheetTableCueCasesDelta?: number;
3127
+ minSpreadsheetColumnCueCasesDelta?: number;
3128
+ minMultiVectorCollapsedCasesDelta?: number;
3129
+ minMultiVectorLexicalHitCasesDelta?: number;
3130
+ minMultiVectorVectorHitCasesDelta?: number;
3131
+ minEvidenceReconcileCasesDelta?: number;
3132
+ maxRuntimeCandidateBudgetExhaustedCasesDelta?: number;
3133
+ maxRuntimeUnderfilledTopKCasesDelta?: number;
3134
+ severity?: "warn" | "fail";
3135
+ };
3136
+ export type RAGRetrievalComparisonGateResult = {
3137
+ status: "pass" | "warn" | "fail";
3138
+ reasons: string[];
3139
+ policy?: RAGRetrievalBaselineGatePolicy;
3140
+ };
3141
+ export type RAGRetrievalReleaseVerdict = {
3142
+ status: "pass" | "warn" | "fail" | "needs_review";
3143
+ summary: string;
3144
+ baselineGroupKey?: string;
3145
+ baselineRetrievalId?: string;
3146
+ candidateRetrievalId?: string;
3147
+ gate?: RAGRetrievalComparisonGateResult;
3148
+ delta?: RAGRetrievalComparisonDecisionDelta;
3149
+ };
3150
+ export type RAGRetrievalComparisonDecisionSummary = {
3151
+ baselineRetrievalId?: string;
3152
+ candidateRetrievalId?: string;
3153
+ winnerByPassingRate?: string;
3154
+ winnerByAverageF1?: string;
3155
+ fastest?: string;
3156
+ winnerByPresentationTitleCueCases?: string;
3157
+ winnerByPresentationBodyCueCases?: string;
3158
+ winnerByPresentationNotesCueCases?: string;
3159
+ winnerBySpreadsheetSheetCueCases?: string;
3160
+ winnerBySpreadsheetTableCueCases?: string;
3161
+ winnerBySpreadsheetColumnCueCases?: string;
3162
+ winnerByMultivectorCollapsedCases?: string;
3163
+ winnerByMultivectorLexicalHitCases?: string;
3164
+ winnerByMultivectorVectorHitCases?: string;
3165
+ winnerByEvidenceReconcileCases?: string;
3166
+ winnerByOfficeEvidenceReconcileCases?: string;
3167
+ winnerByPDFEvidenceReconcileCases?: string;
3168
+ winnerByLowestRuntimeCandidateBudgetExhaustedCases?: string;
3169
+ winnerByLowestRuntimeUnderfilledTopKCases?: string;
3170
+ baseline?: {
3171
+ retrievalId: string;
3172
+ label: string;
3173
+ passingRate: number;
3174
+ averageF1: number;
3175
+ elapsedMs: number;
3176
+ presentationTitleCueCases?: number;
3177
+ presentationBodyCueCases?: number;
3178
+ presentationNotesCueCases?: number;
3179
+ spreadsheetSheetCueCases?: number;
3180
+ spreadsheetTableCueCases?: number;
3181
+ spreadsheetColumnCueCases?: number;
3182
+ multiVectorCollapsedCases?: number;
3183
+ multiVectorLexicalHitCases?: number;
3184
+ multiVectorVectorHitCases?: number;
3185
+ evidenceReconcileCases?: number;
3186
+ officeEvidenceReconcileCases?: number;
3187
+ pdfEvidenceReconcileCases?: number;
3188
+ runtimeCandidateBudgetExhaustedCases?: number;
3189
+ runtimeUnderfilledTopKCases?: number;
3190
+ };
3191
+ candidate?: {
3192
+ retrievalId: string;
3193
+ label: string;
3194
+ passingRate: number;
3195
+ averageF1: number;
3196
+ elapsedMs: number;
3197
+ presentationTitleCueCases?: number;
3198
+ presentationBodyCueCases?: number;
3199
+ presentationNotesCueCases?: number;
3200
+ spreadsheetSheetCueCases?: number;
3201
+ spreadsheetTableCueCases?: number;
3202
+ spreadsheetColumnCueCases?: number;
3203
+ multiVectorCollapsedCases?: number;
3204
+ multiVectorLexicalHitCases?: number;
3205
+ multiVectorVectorHitCases?: number;
3206
+ evidenceReconcileCases?: number;
3207
+ officeEvidenceReconcileCases?: number;
3208
+ pdfEvidenceReconcileCases?: number;
3209
+ runtimeCandidateBudgetExhaustedCases?: number;
3210
+ runtimeUnderfilledTopKCases?: number;
3211
+ };
3212
+ delta?: RAGRetrievalComparisonDecisionDelta;
3213
+ gate?: RAGRetrievalComparisonGateResult;
3214
+ };
3215
+ export type RAGRetrievalComparisonHistoryStore = {
3216
+ saveRun: (run: RAGRetrievalComparisonRun) => Promise<void> | void;
3217
+ listRuns: (input?: {
3218
+ limit?: number;
3219
+ suiteId?: string;
3220
+ label?: string;
3221
+ winnerId?: string;
3222
+ corpusGroupKey?: string;
3223
+ groupKey?: string;
3224
+ tag?: string;
3225
+ }) => Promise<RAGRetrievalComparisonRun[]> | RAGRetrievalComparisonRun[];
3226
+ };
3227
+ export type RAGRetrievalComparisonHistoryResponse = {
3228
+ ok: boolean;
3229
+ runs?: RAGRetrievalComparisonRun[];
3230
+ error?: string;
3231
+ };
3232
+ export type RAGRetrievalBaselineRecord = {
3233
+ id: string;
3234
+ corpusGroupKey?: string;
3235
+ groupKey: string;
3236
+ version: number;
3237
+ status: "active" | "superseded";
3238
+ rolloutLabel?: "canary" | "stable" | "rollback_target";
3239
+ retrievalId: string;
3240
+ label: string;
3241
+ suiteId?: string;
3242
+ suiteLabel?: string;
3243
+ sourceRunId?: string;
3244
+ promotedAt: number;
3245
+ tags?: string[];
3246
+ approvedBy?: string;
3247
+ approvedAt?: number;
3248
+ approvalNotes?: string;
3249
+ policy?: RAGRetrievalBaselineGatePolicy;
3250
+ metadata?: Record<string, unknown>;
3251
+ };
3252
+ export type RAGRetrievalBaselineStore = {
3253
+ saveBaseline: (record: RAGRetrievalBaselineRecord) => Promise<void> | void;
3254
+ listBaselines: (input?: {
3255
+ corpusGroupKey?: string;
3256
+ groupKey?: string;
3257
+ tag?: string;
3258
+ limit?: number;
3259
+ status?: RAGRetrievalBaselineRecord["status"];
3260
+ }) => Promise<RAGRetrievalBaselineRecord[]> | RAGRetrievalBaselineRecord[];
3261
+ getBaseline?: (groupKey: string) => Promise<RAGRetrievalBaselineRecord | null | undefined> | RAGRetrievalBaselineRecord | null | undefined;
3262
+ };
3263
+ export type RAGRetrievalBaselinePromotionRequest = {
3264
+ corpusGroupKey?: string;
3265
+ groupKey: string;
3266
+ retrievalId: string;
3267
+ rolloutLabel?: "canary" | "stable" | "rollback_target";
3268
+ label?: string;
3269
+ suiteId?: string;
3270
+ suiteLabel?: string;
3271
+ sourceRunId?: string;
3272
+ tags?: string[];
3273
+ approvedBy?: string;
3274
+ approvedAt?: number;
3275
+ approvalNotes?: string;
3276
+ policy?: RAGRetrievalBaselineGatePolicy;
3277
+ metadata?: Record<string, unknown>;
3278
+ };
3279
+ export type RAGRetrievalBaselinePromotionFromRunRequest = {
3280
+ corpusGroupKey?: string;
3281
+ groupKey: string;
3282
+ sourceRunId: string;
3283
+ retrievalId?: string;
3284
+ rolloutLabel?: "canary" | "stable" | "rollback_target";
3285
+ overrideGate?: boolean;
3286
+ overrideReason?: string;
3287
+ approvedBy?: string;
3288
+ approvedAt?: number;
3289
+ approvalNotes?: string;
3290
+ policy?: RAGRetrievalBaselineGatePolicy;
3291
+ metadata?: Record<string, unknown>;
3292
+ };
3293
+ export type RAGRetrievalBaselineRevertRequest = {
3294
+ corpusGroupKey?: string;
3295
+ groupKey: string;
3296
+ version?: number;
3297
+ baselineId?: string;
3298
+ approvedBy?: string;
3299
+ approvedAt?: number;
3300
+ approvalNotes?: string;
3301
+ metadata?: Record<string, unknown>;
3302
+ };
3303
+ export type RAGRetrievalBaselineResponse = {
3304
+ ok: boolean;
3305
+ baseline?: RAGRetrievalBaselineRecord;
3306
+ rolloutState?: RAGRetrievalLanePromotionStateSummary;
3307
+ error?: string;
3308
+ };
3309
+ export type RAGRetrievalBaselineListResponse = {
3310
+ ok: boolean;
3311
+ baselines?: RAGRetrievalBaselineRecord[];
3312
+ error?: string;
3313
+ };
3314
+ export type RAGRetrievalReleaseDecisionRecord = {
3315
+ id: string;
3316
+ kind: "approve" | "promote" | "reject" | "revert";
3317
+ corpusGroupKey?: string;
3318
+ groupKey: string;
3319
+ targetRolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
3320
+ baselineId?: string;
3321
+ retrievalId: string;
3322
+ version?: number;
3323
+ decidedAt: number;
3324
+ decidedBy?: string;
3325
+ notes?: string;
3326
+ sourceRunId?: string;
3327
+ restoredFromBaselineId?: string;
3328
+ restoredFromVersion?: number;
3329
+ gateStatus?: RAGRetrievalComparisonGateResult["status"];
3330
+ overrideGate?: boolean;
3331
+ overrideReason?: string;
3332
+ freshnessStatus?: "fresh" | "expired" | "not_applicable";
3333
+ expiresAt?: number;
3334
+ ageMs?: number;
3335
+ };
3336
+ export type RAGRetrievalPromotionReadiness = {
3337
+ ready: boolean;
3338
+ reasons: string[];
3339
+ targetRolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
3340
+ sourceRunId?: string;
3341
+ baselineRetrievalId?: string;
3342
+ candidateRetrievalId?: string;
3343
+ gateStatus?: RAGRetrievalComparisonGateResult["status"];
3344
+ requiresApproval?: boolean;
3345
+ requiresOverride?: boolean;
3346
+ effectiveReleasePolicy?: RAGRetrievalReleasePolicy;
3347
+ effectiveBaselineGatePolicy?: RAGRetrievalBaselineGatePolicy;
3348
+ };
3349
+ export type RAGRetrievalPromotionCandidate = {
3350
+ sourceRunId: string;
3351
+ groupKey?: string;
3352
+ label: string;
3353
+ suiteId: string;
3354
+ suiteLabel: string;
3355
+ finishedAt: number;
3356
+ targetRolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
3357
+ candidateRetrievalId?: string;
3358
+ baselineRetrievalId?: string;
3359
+ gateStatus?: RAGRetrievalComparisonGateResult["status"];
3360
+ reviewStatus: "approved" | "blocked" | "needs_review" | "ready";
3361
+ priority: "ready_now" | "needs_review" | "gate_warn" | "gate_fail" | "blocked";
3362
+ priorityScore: number;
3363
+ sortReason: string;
3364
+ ready: boolean;
3365
+ reasons: string[];
3366
+ requiresApproval: boolean;
3367
+ approved: boolean;
3368
+ approvedAt?: number;
3369
+ approvedBy?: string;
3370
+ approvalFreshnessStatus?: "fresh" | "expired" | "not_applicable";
3371
+ approvalExpiresAt?: number;
3372
+ approvalAgeMs?: number;
3373
+ effectiveReleasePolicy?: RAGRetrievalReleasePolicy;
3374
+ effectiveBaselineGatePolicy?: RAGRetrievalBaselineGatePolicy;
3375
+ delta?: RAGRetrievalComparisonDecisionDelta;
3376
+ releaseVerdictStatus?: RAGRetrievalReleaseVerdict["status"];
3377
+ tags?: string[];
3378
+ };
3379
+ export type RAGRetrievalReleasePolicy = {
3380
+ requireApprovalBeforePromotion?: boolean;
3381
+ approvalMaxAgeMs?: number;
3382
+ };
3383
+ export type RAGRetrievalReleaseLanePolicySummary = RAGRetrievalReleasePolicy & {
3384
+ groupKey?: string;
3385
+ rolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3386
+ scope: "rollout_label" | "group_rollout_label";
3387
+ };
3388
+ export type RAGRetrievalReleaseLanePolicyHistoryRecord = {
3389
+ id: string;
3390
+ corpusGroupKey?: string;
3391
+ groupKey?: string;
3392
+ rolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3393
+ scope: "rollout_label" | "group_rollout_label";
3394
+ requireApprovalBeforePromotion?: boolean;
3395
+ approvalMaxAgeMs?: number;
3396
+ recordedAt: number;
3397
+ changeKind: "snapshot" | "changed";
3398
+ previousRequireApprovalBeforePromotion?: boolean;
3399
+ previousApprovalMaxAgeMs?: number;
3400
+ };
3401
+ export type RAGRetrievalReleaseLanePolicyHistoryStore = {
3402
+ saveRecord: (record: RAGRetrievalReleaseLanePolicyHistoryRecord) => Promise<void> | void;
3403
+ listRecords: (input?: {
3404
+ corpusGroupKey?: string;
3405
+ groupKey?: string;
3406
+ limit?: number;
3407
+ rolloutLabel?: RAGRetrievalReleaseLanePolicyHistoryRecord["rolloutLabel"];
3408
+ scope?: RAGRetrievalReleaseLanePolicyHistoryRecord["scope"];
3409
+ }) => Promise<RAGRetrievalReleaseLanePolicyHistoryRecord[]> | RAGRetrievalReleaseLanePolicyHistoryRecord[];
3410
+ };
3411
+ export type RAGRetrievalReleaseLanePolicyHistoryResponse = {
3412
+ ok: boolean;
3413
+ records?: RAGRetrievalReleaseLanePolicyHistoryRecord[];
3414
+ error?: string;
3415
+ };
3416
+ export type RAGRetrievalBaselineGatePolicySummary = {
3417
+ groupKey?: string;
3418
+ rolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3419
+ scope: "rollout_label" | "group_rollout_label";
3420
+ policy: RAGRetrievalBaselineGatePolicy;
3421
+ };
3422
+ export type RAGRetrievalBaselineGatePolicyHistoryRecord = {
3423
+ id: string;
3424
+ corpusGroupKey?: string;
3425
+ groupKey?: string;
3426
+ rolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3427
+ scope: "rollout_label" | "group_rollout_label";
3428
+ policy: RAGRetrievalBaselineGatePolicy;
3429
+ recordedAt: number;
3430
+ changeKind: "snapshot" | "changed";
3431
+ previousPolicy?: RAGRetrievalBaselineGatePolicy;
3432
+ };
3433
+ export type RAGRetrievalBaselineGatePolicyHistoryStore = {
3434
+ saveRecord: (record: RAGRetrievalBaselineGatePolicyHistoryRecord) => Promise<void> | void;
3435
+ listRecords: (input?: {
3436
+ corpusGroupKey?: string;
3437
+ groupKey?: string;
3438
+ limit?: number;
3439
+ rolloutLabel?: RAGRetrievalBaselineGatePolicyHistoryRecord["rolloutLabel"];
3440
+ scope?: RAGRetrievalBaselineGatePolicyHistoryRecord["scope"];
3441
+ }) => Promise<RAGRetrievalBaselineGatePolicyHistoryRecord[]> | RAGRetrievalBaselineGatePolicyHistoryRecord[];
3442
+ };
3443
+ export type RAGRetrievalBaselineGatePolicyHistoryResponse = {
3444
+ ok: boolean;
3445
+ records?: RAGRetrievalBaselineGatePolicyHistoryRecord[];
3446
+ error?: string;
3447
+ };
3448
+ export type RAGRetrievalReleaseIncidentSummary = {
3449
+ openCount: number;
3450
+ resolvedCount: number;
3451
+ acknowledgedOpenCount: number;
3452
+ unacknowledgedOpenCount: number;
3453
+ latestAcknowledgedAt?: number;
3454
+ };
3455
+ export type RAGRetrievalIncidentRemediationDecisionRecord = {
3456
+ id: string;
3457
+ incidentId: string;
3458
+ idempotencyKey?: string;
3459
+ groupKey: string;
3460
+ targetRolloutLabel?: RAGRetrievalReleaseIncidentRecord["targetRolloutLabel"];
3461
+ incidentKind?: RAGRetrievalReleaseIncidentRecord["kind"];
3462
+ remediationKind: RAGRemediationStep["kind"];
3463
+ status: "planned" | "applied" | "dismissed";
3464
+ decidedAt: number;
3465
+ decidedBy?: string;
3466
+ notes?: string;
3467
+ action?: RAGRemediationAction;
3468
+ };
3469
+ export type RAGRetrievalIncidentRemediationDecisionRequest = {
3470
+ incidentId: string;
3471
+ remediationKind: RAGRemediationStep["kind"];
3472
+ status?: RAGRetrievalIncidentRemediationDecisionRecord["status"];
3473
+ decidedAt?: number;
3474
+ decidedBy?: string;
3475
+ notes?: string;
3476
+ action?: RAGRemediationAction;
3477
+ };
3478
+ export type RAGRetrievalIncidentRemediationDecisionStore = {
3479
+ saveRecord: (record: RAGRetrievalIncidentRemediationDecisionRecord) => Promise<void> | void;
3480
+ listRecords: (input?: {
3481
+ corpusGroupKey?: string;
3482
+ groupKey?: string;
3483
+ incidentId?: string;
3484
+ limit?: number;
3485
+ remediationKind?: RAGRetrievalIncidentRemediationDecisionRecord["remediationKind"];
3486
+ status?: RAGRetrievalIncidentRemediationDecisionRecord["status"];
3487
+ targetRolloutLabel?: RAGRetrievalIncidentRemediationDecisionRecord["targetRolloutLabel"];
3488
+ }) => Promise<RAGRetrievalIncidentRemediationDecisionRecord[]> | RAGRetrievalIncidentRemediationDecisionRecord[];
3489
+ };
3490
+ export type RAGRetrievalIncidentRemediationDecisionListResponse = {
3491
+ ok: boolean;
3492
+ records?: RAGRetrievalIncidentRemediationDecisionRecord[];
3493
+ error?: string;
3494
+ };
3495
+ export type RAGRetrievalIncidentRemediationExecutionRequest = {
3496
+ incidentId?: string;
3497
+ idempotencyKey?: string;
3498
+ remediationKind?: RAGRemediationStep["kind"];
3499
+ decidedAt?: number;
3500
+ decidedBy?: string;
3501
+ notes?: string;
3502
+ persistDecision?: boolean;
3503
+ action: RAGRemediationAction;
3504
+ };
3505
+ export type RAGRetrievalIncidentRemediationExecutionCode = "approval_recorded" | "incident_acknowledged" | "incident_resolved" | "release_status_loaded" | "release_drift_loaded" | "handoff_status_loaded" | "guardrail_blocked" | "idempotent_replay";
3506
+ export type RAGRetrievalIncidentRemediationExecutionResult = {
3507
+ action: RAGRemediationAction;
3508
+ code: RAGRetrievalIncidentRemediationExecutionCode;
3509
+ idempotentReplay?: boolean;
3510
+ incidents?: RAGRetrievalReleaseIncidentRecord[];
3511
+ decisions?: RAGRetrievalReleaseDecisionRecord[];
3512
+ releaseStatus?: RAGRetrievalComparisonRuntime;
3513
+ releaseIncidentStatus?: RAGRetrievalReleaseIncidentStatusResponse;
3514
+ releaseDriftStatus?: RAGRetrievalReleaseDriftStatusResponse;
3515
+ handoffStatus?: RAGRetrievalLaneHandoffStatusResponse;
3516
+ followUpSteps?: RAGRemediationStep[];
3517
+ };
3518
+ export type RAGRetrievalIncidentRemediationExecutionResponse = {
3519
+ ok: boolean;
3520
+ execution?: RAGRetrievalIncidentRemediationExecutionResult;
3521
+ record?: RAGRetrievalIncidentRemediationDecisionRecord;
3522
+ error?: string;
3523
+ };
3524
+ export type RAGRetrievalIncidentRemediationExecutionHistoryRecord = {
3525
+ id: string;
3526
+ executedAt: number;
3527
+ groupKey?: string;
3528
+ incidentId?: string;
3529
+ incidentKind?: RAGRetrievalReleaseIncidentRecord["kind"];
3530
+ targetRolloutLabel?: RAGRetrievalReleaseIncidentRecord["targetRolloutLabel"];
3531
+ remediationKind?: RAGRemediationStep["kind"];
3532
+ action: RAGRemediationAction;
3533
+ code: RAGRetrievalIncidentRemediationExecutionCode;
3534
+ ok: boolean;
3535
+ error?: string;
3536
+ idempotencyKey?: string;
3537
+ idempotentReplay?: boolean;
3538
+ mutationSkipped?: boolean;
3539
+ blockedByGuardrail?: boolean;
3540
+ guardrailKind?: "bulk_mutation_opt_in_required" | "bulk_missing_idempotency_key";
3541
+ bulkExecutionId?: string;
3542
+ bulkIndex?: number;
3543
+ };
3544
+ export type RAGRetrievalIncidentRemediationExecutionHistoryStore = {
3545
+ saveRecord: (record: RAGRetrievalIncidentRemediationExecutionHistoryRecord) => Promise<void> | void;
3546
+ listRecords: (input?: {
3547
+ groupKey?: string;
3548
+ incidentId?: string;
3549
+ limit?: number;
3550
+ actionKind?: RAGRemediationAction["kind"];
3551
+ code?: RAGRetrievalIncidentRemediationExecutionCode;
3552
+ blockedByGuardrail?: boolean;
3553
+ idempotentReplay?: boolean;
3554
+ targetRolloutLabel?: RAGRetrievalReleaseIncidentRecord["targetRolloutLabel"];
3555
+ }) => Promise<RAGRetrievalIncidentRemediationExecutionHistoryRecord[]> | RAGRetrievalIncidentRemediationExecutionHistoryRecord[];
3556
+ };
3557
+ export type RAGRetrievalIncidentRemediationExecutionHistoryResponse = {
3558
+ ok: boolean;
3559
+ records?: RAGRetrievalIncidentRemediationExecutionHistoryRecord[];
3560
+ error?: string;
3561
+ };
3562
+ export type RAGRetrievalIncidentRemediationExecutionSummary = {
3563
+ totalCount: number;
3564
+ replayCount: number;
3565
+ replayRate: number;
3566
+ guardrailBlockedCount: number;
3567
+ guardrailBlockRate: number;
3568
+ mutationSkippedReplayCount: number;
3569
+ recentMutationSkippedReplays: RAGRetrievalIncidentRemediationExecutionHistoryRecord[];
3570
+ recentGuardrailBlocks: RAGRetrievalIncidentRemediationExecutionHistoryRecord[];
3571
+ };
3572
+ export type RAGRetrievalIncidentRemediationBulkExecutionRequest = {
3573
+ items: RAGRetrievalIncidentRemediationExecutionRequest[];
3574
+ allowMutationExecution?: boolean;
3575
+ stopOnError?: boolean;
3576
+ };
3577
+ export type RAGRetrievalIncidentRemediationBulkExecutionResponse = {
3578
+ ok: boolean;
3579
+ results?: Array<{
3580
+ index: number;
3581
+ ok: boolean;
3582
+ execution?: RAGRetrievalIncidentRemediationExecutionResult;
3583
+ record?: RAGRetrievalIncidentRemediationDecisionRecord;
3584
+ error?: string;
3585
+ }>;
3586
+ error?: string;
3587
+ };
3588
+ export type RAGRetrievalReleaseGroupSummary = {
3589
+ corpusGroupKey?: string;
3590
+ groupKey: string;
3591
+ classification?: "general" | "multivector" | "runtime" | "evidence" | "cue";
3592
+ escalationSeverity: "none" | "info" | "warning" | "critical";
3593
+ recommendedAction: "promote_candidate" | "renew_approval" | "await_approval" | "investigate_regression" | "monitor";
3594
+ recommendedActionReasons: string[];
3595
+ approvalRequired: boolean;
3596
+ approvalMaxAgeMs?: number;
3597
+ blockedReasons: string[];
3598
+ actionRequired: boolean;
3599
+ actionRequiredReasons: string[];
3600
+ activeBaselineRetrievalId?: string;
3601
+ activeBaselineVersion?: number;
3602
+ activeBaselineRolloutLabel?: "canary" | "stable" | "rollback_target";
3603
+ latestDecisionKind?: RAGRetrievalReleaseDecisionRecord["kind"];
3604
+ latestDecisionAt?: number;
3605
+ latestRejectedCandidateRetrievalId?: string;
3606
+ pendingCandidateCount: number;
3607
+ openIncidentCount: number;
3608
+ acknowledgedOpenIncidentCount: number;
3609
+ unacknowledgedOpenIncidentCount: number;
3610
+ activeBaselineGatePolicy?: RAGRetrievalBaselineGatePolicy;
3611
+ };
3612
+ export type RAGRetrievalReleaseTimelineSummary = {
3613
+ corpusGroupKey?: string;
3614
+ groupKey: string;
3615
+ lastApprovedAt?: number;
3616
+ lastPromotedAt?: number;
3617
+ lastRejectedAt?: number;
3618
+ lastRevertedAt?: number;
3619
+ latestDecisionKind?: RAGRetrievalReleaseDecisionRecord["kind"];
3620
+ latestDecisionAt?: number;
3621
+ latestDecisionFreshnessStatus?: RAGRetrievalReleaseDecisionRecord["freshnessStatus"];
3622
+ };
3623
+ export type RAGRetrievalReleaseLaneTimelineSummary = {
3624
+ corpusGroupKey?: string;
3625
+ groupKey: string;
3626
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3627
+ lastApprovedAt?: number;
3628
+ lastPromotedAt?: number;
3629
+ lastRejectedAt?: number;
3630
+ lastRevertedAt?: number;
3631
+ latestDecisionKind?: RAGRetrievalReleaseDecisionRecord["kind"];
3632
+ latestDecisionAt?: number;
3633
+ latestDecisionFreshnessStatus?: RAGRetrievalReleaseDecisionRecord["freshnessStatus"];
3634
+ };
3635
+ export type RAGRetrievalReleaseLaneDecisionSummary = {
3636
+ corpusGroupKey?: string;
3637
+ groupKey: string;
3638
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3639
+ decisionCount: number;
3640
+ approvalCount: number;
3641
+ promotionCount: number;
3642
+ rejectionCount: number;
3643
+ revertCount: number;
3644
+ latestDecisionKind?: RAGRetrievalReleaseDecisionRecord["kind"];
3645
+ latestDecisionAt?: number;
3646
+ latestDecisionBy?: string;
3647
+ };
3648
+ export type RAGRetrievalReleaseApprovalScopeSummary = {
3649
+ corpusGroupKey?: string;
3650
+ groupKey: string;
3651
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3652
+ status: "approved" | "rejected" | "none";
3653
+ latestDecisionKind?: "approve" | "reject";
3654
+ latestDecisionAt?: number;
3655
+ latestApprovedAt?: number;
3656
+ latestApprovedBy?: string;
3657
+ latestRejectedAt?: number;
3658
+ latestRejectedBy?: string;
3659
+ };
3660
+ export type RAGRetrievalReleaseLaneEscalationPolicySummary = {
3661
+ corpusGroupKey?: string;
3662
+ groupKey: string;
3663
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3664
+ openIncidentSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3665
+ regressionSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3666
+ gateFailureSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3667
+ approvalExpiredSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3668
+ };
3669
+ export type RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord = {
3670
+ id: string;
3671
+ corpusGroupKey?: string;
3672
+ groupKey: string;
3673
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3674
+ openIncidentSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3675
+ regressionSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3676
+ gateFailureSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3677
+ approvalExpiredSeverity: RAGRetrievalReleaseIncidentRecord["severity"];
3678
+ recordedAt: number;
3679
+ changeKind: "snapshot" | "changed";
3680
+ previousOpenIncidentSeverity?: RAGRetrievalReleaseIncidentRecord["severity"];
3681
+ previousRegressionSeverity?: RAGRetrievalReleaseIncidentRecord["severity"];
3682
+ previousGateFailureSeverity?: RAGRetrievalReleaseIncidentRecord["severity"];
3683
+ previousApprovalExpiredSeverity?: RAGRetrievalReleaseIncidentRecord["severity"];
3684
+ };
3685
+ export type RAGRetrievalReleaseLaneEscalationPolicyHistoryStore = {
3686
+ saveRecord: (record: RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord) => Promise<void> | void;
3687
+ listRecords: (input?: {
3688
+ corpusGroupKey?: string;
3689
+ groupKey?: string;
3690
+ limit?: number;
3691
+ targetRolloutLabel?: RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord["targetRolloutLabel"];
3692
+ }) => Promise<RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord[]> | RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord[];
3693
+ };
3694
+ export type RAGRetrievalReleaseLaneEscalationPolicyHistoryResponse = {
3695
+ ok: boolean;
3696
+ records?: RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord[];
3697
+ error?: string;
3698
+ };
3699
+ export type RAGRetrievalReleaseLaneAuditSummary = {
3700
+ corpusGroupKey?: string;
3701
+ groupKey: string;
3702
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3703
+ activeBaselineRetrievalId?: string;
3704
+ activeBaselineVersion?: number;
3705
+ latestDecisionKind?: RAGRetrievalReleaseDecisionRecord["kind"];
3706
+ latestDecisionAt?: number;
3707
+ lastApprovedAt?: number;
3708
+ lastApprovedBy?: string;
3709
+ lastPromotedAt?: number;
3710
+ lastPromotedBy?: string;
3711
+ lastRejectedAt?: number;
3712
+ lastRejectedBy?: string;
3713
+ lastRevertedAt?: number;
3714
+ lastRevertedBy?: string;
3715
+ };
3716
+ export type RAGRetrievalReleaseLaneRecommendationSummary = {
3717
+ corpusGroupKey?: string;
3718
+ groupKey: string;
3719
+ classification?: "general" | "multivector" | "runtime" | "evidence" | "cue";
3720
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3721
+ recommendedAction: "promote_candidate" | "renew_approval" | "await_approval" | "investigate_regression" | "monitor";
3722
+ recommendedActionReasons: string[];
3723
+ ready: boolean;
3724
+ requiresApproval: boolean;
3725
+ requiresOverride?: boolean;
3726
+ reviewStatus?: RAGRetrievalPromotionCandidate["reviewStatus"];
3727
+ gateStatus?: RAGRetrievalPromotionCandidate["gateStatus"];
3728
+ candidateRetrievalId?: string;
3729
+ baselineRetrievalId?: string;
3730
+ sourceRunId?: string;
3731
+ effectiveReleasePolicy?: RAGRetrievalPromotionCandidate["effectiveReleasePolicy"];
3732
+ effectiveBaselineGatePolicy?: RAGRetrievalPromotionCandidate["effectiveBaselineGatePolicy"];
3733
+ remediationActions?: string[];
3734
+ remediationSteps?: RAGRemediationStep[];
3735
+ };
3736
+ export type RAGRetrievalReleaseLaneHandoffSummary = {
3737
+ corpusGroupKey?: string;
3738
+ groupKey: string;
3739
+ sourceRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3740
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3741
+ sourceBaselineRetrievalId?: string;
3742
+ targetBaselineRetrievalId?: string;
3743
+ candidateRetrievalId?: string;
3744
+ sourceActive: boolean;
3745
+ targetActive: boolean;
3746
+ readyForHandoff: boolean;
3747
+ reasons: string[];
3748
+ policyDelta: {
3749
+ requireApprovalBeforePromotionChanged: boolean;
3750
+ approvalMaxAgeMsDelta?: number;
3751
+ gateSeverityChanged: boolean;
3752
+ minPassingRateDeltaDelta?: number;
3753
+ minAverageF1DeltaDelta?: number;
3754
+ };
3755
+ targetReadiness?: RAGRetrievalPromotionReadiness;
3756
+ };
3757
+ export type RAGRetrievalLanePromotionStateSummary = {
3758
+ groupKey: string;
3759
+ classification?: "general" | "multivector" | "runtime" | "evidence" | "cue";
3760
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3761
+ baselineRetrievalId?: string;
3762
+ candidateRetrievalId?: string;
3763
+ sourceRunId?: string;
3764
+ ready: boolean;
3765
+ reasons: string[];
3766
+ gateStatus?: RAGRetrievalPromotionCandidate["gateStatus"];
3767
+ reviewStatus?: RAGRetrievalPromotionCandidate["reviewStatus"];
3768
+ requiresApproval: boolean;
3769
+ requiresOverride?: boolean;
3770
+ effectiveReleasePolicy?: RAGRetrievalPromotionCandidate["effectiveReleasePolicy"];
3771
+ effectiveBaselineGatePolicy?: RAGRetrievalPromotionCandidate["effectiveBaselineGatePolicy"];
3772
+ remediationActions?: string[];
3773
+ remediationSteps?: RAGRemediationStep[];
3774
+ };
3775
+ export type RAGRetrievalReleaseIncidentRecord = {
3776
+ id: string;
3777
+ groupKey: string;
3778
+ corpusGroupKey?: string;
3779
+ targetRolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
3780
+ severity: "warning" | "critical";
3781
+ status: "open" | "resolved";
3782
+ kind: "approval_expired" | "baseline_regression" | "gate_failure" | "handoff_stale";
3783
+ message: string;
3784
+ triggeredAt: number;
3785
+ resolvedAt?: number;
3786
+ candidateRetrievalId?: string;
3787
+ baselineRetrievalId?: string;
3788
+ sourceRunId?: string;
3789
+ acknowledgedAt?: number;
3790
+ acknowledgedBy?: string;
3791
+ acknowledgementNotes?: string;
3792
+ notes?: string;
3793
+ classification?: "general" | "multivector" | "runtime" | "evidence" | "cue";
3794
+ };
3795
+ export type RAGRetrievalLaneHandoffIncidentRecord = Omit<RAGRetrievalReleaseIncidentRecord, "kind"> & {
3796
+ corpusGroupKey?: string;
3797
+ kind: "handoff_stale";
3798
+ sourceRolloutLabel?: RAGRetrievalLaneHandoffDecisionRecord["sourceRolloutLabel"];
3799
+ };
3800
+ export type RAGRetrievalReleaseLaneIncidentSummary = {
3801
+ corpusGroupKey?: string;
3802
+ groupKey: string;
3803
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
3804
+ openCount: number;
3805
+ resolvedCount: number;
3806
+ acknowledgedOpenCount: number;
3807
+ unacknowledgedOpenCount: number;
3808
+ latestTriggeredAt?: number;
3809
+ latestResolvedAt?: number;
3810
+ latestKind?: RAGRetrievalReleaseIncidentRecord["kind"];
3811
+ highestSeverity?: RAGRetrievalReleaseIncidentRecord["severity"];
3812
+ };
3813
+ export type RAGRetrievalReleaseIncidentAcknowledgeRequest = {
3814
+ incidentId: string;
3815
+ acknowledgedAt?: number;
3816
+ acknowledgedBy?: string;
3817
+ acknowledgementNotes?: string;
3818
+ };
3819
+ export type RAGRetrievalReleaseIncidentUnacknowledgeRequest = {
3820
+ incidentId: string;
3821
+ };
3822
+ export type RAGRetrievalReleaseIncidentResolveRequest = {
3823
+ incidentId: string;
3824
+ resolvedAt?: number;
3825
+ resolvedBy?: string;
3826
+ resolutionNotes?: string;
3827
+ };
3828
+ export type RAGRetrievalReleaseIncidentStore = {
3829
+ saveIncident: (record: RAGRetrievalReleaseIncidentRecord) => Promise<void> | void;
3830
+ listIncidents: (input?: {
3831
+ corpusGroupKey?: string;
3832
+ groupKey?: string;
3833
+ limit?: number;
3834
+ targetRolloutLabel?: RAGRetrievalReleaseIncidentRecord["targetRolloutLabel"];
3835
+ status?: RAGRetrievalReleaseIncidentRecord["status"];
3836
+ severity?: RAGRetrievalReleaseIncidentRecord["severity"];
3837
+ }) => Promise<RAGRetrievalReleaseIncidentRecord[]> | RAGRetrievalReleaseIncidentRecord[];
3838
+ };
3839
+ export type RAGRetrievalLaneHandoffIncidentStore = {
3840
+ saveIncident: (record: RAGRetrievalLaneHandoffIncidentRecord) => Promise<void> | void;
3841
+ listIncidents: (input?: {
3842
+ corpusGroupKey?: string;
3843
+ groupKey?: string;
3844
+ limit?: number;
3845
+ targetRolloutLabel?: RAGRetrievalLaneHandoffIncidentRecord["targetRolloutLabel"];
3846
+ status?: RAGRetrievalLaneHandoffIncidentRecord["status"];
3847
+ severity?: RAGRetrievalLaneHandoffIncidentRecord["severity"];
3848
+ }) => Promise<RAGRetrievalLaneHandoffIncidentRecord[]> | RAGRetrievalLaneHandoffIncidentRecord[];
3849
+ };
3850
+ export type RAGRetrievalLaneHandoffIncidentListResponse = {
3851
+ ok: boolean;
3852
+ incidents?: RAGRetrievalLaneHandoffIncidentRecord[];
3853
+ error?: string;
3854
+ };
3855
+ export type RAGRetrievalLaneHandoffIncidentHistoryRecord = {
3856
+ id: string;
3857
+ incidentId: string;
3858
+ corpusGroupKey?: string;
3859
+ groupKey: string;
3860
+ kind: "handoff_stale";
3861
+ targetRolloutLabel?: RAGRetrievalLaneHandoffIncidentRecord["targetRolloutLabel"];
3862
+ sourceRolloutLabel?: RAGRetrievalLaneHandoffIncidentRecord["sourceRolloutLabel"];
3863
+ action: "opened" | "acknowledged" | "unacknowledged" | "resolved";
3864
+ recordedAt: number;
3865
+ recordedBy?: string;
3866
+ notes?: string;
3867
+ status?: RAGRetrievalLaneHandoffIncidentRecord["status"];
3868
+ severity?: RAGRetrievalLaneHandoffIncidentRecord["severity"];
3869
+ };
3870
+ export type RAGRetrievalLaneHandoffIncidentHistoryStore = {
3871
+ saveRecord: (record: RAGRetrievalLaneHandoffIncidentHistoryRecord) => Promise<void> | void;
3872
+ listRecords: (input?: {
3873
+ corpusGroupKey?: string;
3874
+ groupKey?: string;
3875
+ incidentId?: string;
3876
+ limit?: number;
3877
+ targetRolloutLabel?: RAGRetrievalLaneHandoffIncidentRecord["targetRolloutLabel"];
3878
+ action?: RAGRetrievalLaneHandoffIncidentHistoryRecord["action"];
3879
+ }) => Promise<RAGRetrievalLaneHandoffIncidentHistoryRecord[]> | RAGRetrievalLaneHandoffIncidentHistoryRecord[];
3880
+ };
3881
+ export type RAGRetrievalLaneHandoffIncidentHistoryResponse = {
3882
+ ok: boolean;
3883
+ records?: RAGRetrievalLaneHandoffIncidentHistoryRecord[];
3884
+ error?: string;
3885
+ };
3886
+ export type RAGRetrievalLaneHandoffAutoCompletePolicy = {
3887
+ enabled?: boolean;
3888
+ maxApprovedDecisionAgeMs?: number;
3889
+ };
3890
+ export type RAGRetrievalLaneHandoffAutoCompletePolicySummary = {
3891
+ groupKey: string;
3892
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
3893
+ enabled: boolean;
3894
+ maxApprovedDecisionAgeMs?: number;
3895
+ scope: "group_target_rollout_label";
3896
+ };
3897
+ export type RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord = {
3898
+ id: string;
3899
+ corpusGroupKey?: string;
3900
+ groupKey: string;
3901
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
3902
+ enabled: boolean;
3903
+ maxApprovedDecisionAgeMs?: number;
3904
+ recordedAt: number;
3905
+ changeKind: "snapshot" | "changed";
3906
+ previousEnabled?: boolean;
3907
+ previousMaxApprovedDecisionAgeMs?: number;
3908
+ };
3909
+ export type RAGRetrievalLaneHandoffAutoCompletePolicyHistoryStore = {
3910
+ saveRecord: (record: RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord) => Promise<void> | void;
3911
+ listRecords: (input?: {
3912
+ corpusGroupKey?: string;
3913
+ groupKey?: string;
3914
+ limit?: number;
3915
+ targetRolloutLabel?: RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord["targetRolloutLabel"];
3916
+ }) => Promise<RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord[]> | RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord[];
3917
+ };
3918
+ export type RAGRetrievalLaneHandoffAutoCompletePolicyHistoryResponse = {
3919
+ ok: boolean;
3920
+ records?: RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord[];
3921
+ error?: string;
3922
+ };
3923
+ export type RAGRetrievalLaneAutoCompleteSafetySummary = {
3924
+ groupKey: string;
3925
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
3926
+ safe: boolean;
3927
+ enabled: boolean;
3928
+ reasons: string[];
3929
+ candidateRetrievalId?: string;
3930
+ sourceRunId?: string;
3931
+ latestApprovedAt?: number;
3932
+ approvalExpiresAt?: number;
3933
+ freshnessStatus: "fresh" | "expired" | "not_applicable";
3934
+ };
3935
+ export type RAGRetrievalLaneHandoffDriftRollup = {
3936
+ kind: "handoff_auto_complete_policy_drift" | "handoff_auto_complete_stale_approval" | "handoff_auto_complete_source_lane_missing" | "handoff_auto_complete_gate_blocked" | "handoff_auto_complete_approval_missing";
3937
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
3938
+ count: number;
3939
+ groupKeys: string[];
3940
+ severity: "warning";
3941
+ remediationHints: string[];
3942
+ remediationSteps?: RAGRemediationStep[];
3943
+ };
3944
+ export type RAGRetrievalLaneHandoffDriftCountByLane = {
3945
+ targetRolloutLabel: Exclude<RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"], undefined>;
3946
+ totalCount: number;
3947
+ countsByKind: Record<RAGRetrievalLaneHandoffDriftRollup["kind"], number>;
3948
+ };
3949
+ export type RAGRetrievalReleaseIncidentListResponse = {
3950
+ ok: boolean;
3951
+ incidents?: RAGRetrievalReleaseIncidentRecord[];
3952
+ error?: string;
3953
+ };
3954
+ export type RAGRetrievalReleaseIncidentStatusResponse = {
3955
+ ok: true;
3956
+ incidentSummary?: RAGRetrievalComparisonRuntime["incidentSummary"];
3957
+ incidentClassificationSummary?: RAGRetrievalIncidentClassificationSummary;
3958
+ releaseLaneIncidentSummaries?: RAGRetrievalComparisonRuntime["releaseLaneIncidentSummaries"];
3959
+ recentIncidents?: RAGRetrievalComparisonRuntime["recentIncidents"];
3960
+ recentIncidentRemediationDecisions?: RAGRetrievalComparisonRuntime["recentIncidentRemediationDecisions"];
3961
+ recentIncidentRemediationExecutions?: RAGRetrievalComparisonRuntime["recentIncidentRemediationExecutions"];
3962
+ incidentRemediationExecutionSummary?: RAGRetrievalComparisonRuntime["incidentRemediationExecutionSummary"];
3963
+ recentReleaseLaneEscalationPolicyHistory?: RAGRetrievalComparisonRuntime["recentReleaseLaneEscalationPolicyHistory"];
3964
+ };
3965
+ export type RAGRetrievalIncidentRemediationStatusResponse = {
3966
+ ok: true;
3967
+ incidentClassificationSummary?: RAGRetrievalIncidentClassificationSummary;
3968
+ recentIncidentRemediationExecutions?: RAGRetrievalComparisonRuntime["recentIncidentRemediationExecutions"];
3969
+ incidentRemediationExecutionSummary?: RAGRetrievalComparisonRuntime["incidentRemediationExecutionSummary"];
3970
+ };
3971
+ export type RAGRetrievalIncidentClassificationSummary = {
3972
+ totalGeneralCount: number;
3973
+ totalMultiVectorCount: number;
3974
+ totalRuntimeCount: number;
3975
+ totalEvidenceCount: number;
3976
+ totalCueCount: number;
3977
+ openGeneralCount: number;
3978
+ openMultiVectorCount: number;
3979
+ openRuntimeCount: number;
3980
+ openEvidenceCount: number;
3981
+ openCueCount: number;
3982
+ resolvedGeneralCount: number;
3983
+ resolvedMultiVectorCount: number;
3984
+ resolvedRuntimeCount: number;
3985
+ resolvedEvidenceCount: number;
3986
+ resolvedCueCount: number;
3987
+ };
3988
+ export type RAGRetrievalReleaseEvent = {
3989
+ kind: "incident_opened" | "incident_resolved";
3990
+ incident: RAGRetrievalReleaseIncidentRecord;
3991
+ };
3992
+ export type RAGRetrievalReleasePolicySummary = RAGRetrievalReleasePolicy & {
3993
+ groupKey: string;
3994
+ rolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
3995
+ };
3996
+ export type RAGRetrievalReleaseDecisionStore = {
3997
+ saveDecision: (record: RAGRetrievalReleaseDecisionRecord) => Promise<void> | void;
3998
+ listDecisions: (input?: {
3999
+ corpusGroupKey?: string;
4000
+ groupKey?: string;
4001
+ limit?: number;
4002
+ kind?: RAGRetrievalReleaseDecisionRecord["kind"];
4003
+ }) => Promise<RAGRetrievalReleaseDecisionRecord[]> | RAGRetrievalReleaseDecisionRecord[];
4004
+ };
4005
+ export type RAGRetrievalReleaseDecisionActionRequest = {
4006
+ corpusGroupKey?: string;
4007
+ groupKey: string;
4008
+ sourceRunId: string;
4009
+ targetRolloutLabel?: RAGRetrievalBaselineRecord["rolloutLabel"];
4010
+ retrievalId?: string;
4011
+ decidedBy?: string;
4012
+ decidedAt?: number;
4013
+ notes?: string;
4014
+ overrideGate?: boolean;
4015
+ overrideReason?: string;
4016
+ };
4017
+ export type RAGRetrievalReleaseDecisionResponse = {
4018
+ ok: boolean;
4019
+ decision?: RAGRetrievalReleaseDecisionRecord;
4020
+ error?: string;
4021
+ };
4022
+ export type RAGRetrievalReleaseDecisionListResponse = {
4023
+ ok: boolean;
4024
+ decisions?: RAGRetrievalReleaseDecisionRecord[];
4025
+ error?: string;
4026
+ };
4027
+ export type RAGRetrievalLaneHandoffDecisionRecord = {
4028
+ id: string;
4029
+ corpusGroupKey?: string;
4030
+ groupKey: string;
4031
+ sourceRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
4032
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
4033
+ kind: "approve" | "reject" | "complete";
4034
+ decidedAt: number;
4035
+ decidedBy?: string;
4036
+ notes?: string;
4037
+ candidateRetrievalId?: string;
4038
+ sourceBaselineRetrievalId?: string;
4039
+ targetBaselineRetrievalId?: string;
4040
+ sourceRunId?: string;
4041
+ };
4042
+ export type RAGRetrievalLaneHandoffDecisionStore = {
4043
+ saveDecision: (record: RAGRetrievalLaneHandoffDecisionRecord) => Promise<void> | void;
4044
+ listDecisions: (input?: {
4045
+ corpusGroupKey?: string;
4046
+ groupKey?: string;
4047
+ sourceRolloutLabel?: RAGRetrievalLaneHandoffDecisionRecord["sourceRolloutLabel"];
4048
+ targetRolloutLabel?: RAGRetrievalLaneHandoffDecisionRecord["targetRolloutLabel"];
4049
+ kind?: RAGRetrievalLaneHandoffDecisionRecord["kind"];
4050
+ limit?: number;
4051
+ }) => Promise<RAGRetrievalLaneHandoffDecisionRecord[]> | RAGRetrievalLaneHandoffDecisionRecord[];
4052
+ };
4053
+ export type RAGRetrievalLaneHandoffDecisionRequest = {
4054
+ corpusGroupKey?: string;
4055
+ groupKey: string;
4056
+ sourceRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
4057
+ targetRolloutLabel: Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>;
4058
+ kind: RAGRetrievalLaneHandoffDecisionRecord["kind"];
4059
+ decidedBy?: string;
4060
+ decidedAt?: number;
4061
+ notes?: string;
4062
+ candidateRetrievalId?: string;
4063
+ sourceRunId?: string;
4064
+ executePromotion?: boolean;
4065
+ };
4066
+ export type RAGRetrievalLaneHandoffDecisionResponse = {
4067
+ ok: boolean;
4068
+ decision?: RAGRetrievalLaneHandoffDecisionRecord;
4069
+ baseline?: RAGRetrievalBaselineRecord;
4070
+ rolloutState?: RAGRetrievalLanePromotionStateSummary;
4071
+ error?: string;
4072
+ };
4073
+ export type RAGRetrievalLaneHandoffDecisionListResponse = {
4074
+ ok: boolean;
4075
+ decisions?: RAGRetrievalLaneHandoffDecisionRecord[];
4076
+ error?: string;
4077
+ };
4078
+ export type RAGRetrievalLaneHandoffListResponse = {
4079
+ ok: boolean;
4080
+ handoffs?: RAGRetrievalReleaseLaneHandoffSummary[];
4081
+ error?: string;
4082
+ };
4083
+ export type RAGRetrievalReleaseGroupHistoryResponse = {
4084
+ ok: boolean;
4085
+ corpusGroupKey?: string;
4086
+ groupKey?: string;
4087
+ decisions?: RAGRetrievalReleaseDecisionRecord[];
4088
+ baselines?: RAGRetrievalBaselineRecord[];
4089
+ runs?: RAGRetrievalComparisonRun[];
4090
+ timeline?: RAGRetrievalReleaseTimelineSummary;
4091
+ presentation?: RAGRetrievalReleaseGroupHistoryPresentation;
4092
+ adaptiveNativePlannerBenchmark?: RAGAdaptiveNativePlannerBenchmarkRuntime;
4093
+ nativeBackendComparisonBenchmark?: RAGNativeBackendComparisonBenchmarkRuntime;
4094
+ presentationCueBenchmark?: RAGPresentationCueBenchmarkRuntime;
4095
+ spreadsheetCueBenchmark?: RAGSpreadsheetCueBenchmarkRuntime;
4096
+ error?: string;
4097
+ };
4098
+ export type RAGRetrievalPromotionCandidateListResponse = {
4099
+ ok: boolean;
4100
+ candidates?: RAGRetrievalPromotionCandidate[];
4101
+ error?: string;
4102
+ };
4103
+ export type RAGRetrievalComparisonLatestSummary = {
4104
+ id: string;
4105
+ label: string;
4106
+ suiteId: string;
4107
+ suiteLabel: string;
4108
+ corpusGroupKey?: string;
4109
+ groupKey?: string;
4110
+ tags?: string[];
4111
+ finishedAt: number;
4112
+ elapsedMs: number;
4113
+ bestByPassingRate?: string;
4114
+ bestByAverageF1?: string;
4115
+ fastest?: string;
4116
+ bestByPresentationTitleCueCases?: string;
4117
+ bestByPresentationBodyCueCases?: string;
4118
+ bestByPresentationNotesCueCases?: string;
4119
+ bestBySpreadsheetSheetCueCases?: string;
4120
+ bestBySpreadsheetTableCueCases?: string;
4121
+ bestBySpreadsheetColumnCueCases?: string;
4122
+ bestByMultivectorCollapsedCases?: string;
4123
+ bestByMultivectorLexicalHitCases?: string;
4124
+ bestByMultivectorVectorHitCases?: string;
4125
+ bestByEvidenceReconcileCases?: string;
4126
+ bestByOfficeEvidenceReconcileCases?: string;
4127
+ bestByOfficeParagraphEvidenceReconcileCases?: string;
4128
+ bestByOfficeListEvidenceReconcileCases?: string;
4129
+ bestByOfficeTableEvidenceReconcileCases?: string;
4130
+ bestByPDFEvidenceReconcileCases?: string;
4131
+ bestByLowestRuntimeCandidateBudgetExhaustedCases?: string;
4132
+ bestByLowestRuntimeUnderfilledTopKCases?: string;
4133
+ decisionSummary?: RAGRetrievalComparisonDecisionSummary;
4134
+ releaseVerdict?: RAGRetrievalReleaseVerdict;
4135
+ };
4136
+ export type RAGRetrievalComparisonWinnerTrend = {
4137
+ retrievalId: string;
4138
+ runCount: number;
4139
+ latestFinishedAt: number;
4140
+ };
4141
+ export type RAGRetrievalComparisonAlert = {
4142
+ kind: "stable_winner_changed" | "baseline_regression" | "baseline_gate_failed" | "handoff_auto_complete_policy_drift" | "handoff_auto_complete_stale_approval" | "handoff_auto_complete_source_lane_missing" | "handoff_auto_complete_gate_blocked" | "handoff_auto_complete_approval_missing";
4143
+ severity: "info" | "warning";
4144
+ message: string;
4145
+ latestRunId: string;
4146
+ retrievalId?: string;
4147
+ corpusGroupKey?: string;
4148
+ groupKey?: string;
4149
+ tag?: string;
4150
+ baselineRetrievalId?: string;
4151
+ candidateRetrievalId?: string;
4152
+ delta?: RAGRetrievalComparisonDecisionDelta;
4153
+ gate?: RAGRetrievalComparisonGateResult;
4154
+ classification?: "general" | "multivector" | "runtime" | "evidence" | "cue";
4155
+ };
4156
+ export type RAGRetrievalComparisonRuntime = {
4157
+ configured: boolean;
4158
+ recentRuns?: RAGRetrievalComparisonRun[];
4159
+ latest?: RAGRetrievalComparisonLatestSummary;
4160
+ adaptiveNativePlannerBenchmark?: RAGAdaptiveNativePlannerBenchmarkRuntime;
4161
+ nativeBackendComparisonBenchmark?: RAGNativeBackendComparisonBenchmarkRuntime;
4162
+ presentationCueBenchmark?: RAGPresentationCueBenchmarkRuntime;
4163
+ spreadsheetCueBenchmark?: RAGSpreadsheetCueBenchmarkRuntime;
4164
+ stableWinnerByPassingRate?: RAGRetrievalComparisonWinnerTrend;
4165
+ alerts?: RAGRetrievalComparisonAlert[];
4166
+ activeBaselines?: RAGRetrievalBaselineRecord[];
4167
+ baselineHistory?: RAGRetrievalBaselineRecord[];
4168
+ recentDecisions?: RAGRetrievalReleaseDecisionRecord[];
4169
+ latestRejectedCandidate?: RAGRetrievalReleaseDecisionRecord;
4170
+ readyToPromote?: RAGRetrievalPromotionReadiness;
4171
+ readyToPromoteByLane?: RAGRetrievalPromotionReadiness[];
4172
+ promotionCandidates?: RAGRetrievalPromotionCandidate[];
4173
+ releaseGroups?: RAGRetrievalReleaseGroupSummary[];
4174
+ releasePolicies?: RAGRetrievalReleasePolicySummary[];
4175
+ releaseLanePolicies?: RAGRetrievalReleaseLanePolicySummary[];
4176
+ releaseGatePolicies?: RAGRetrievalBaselineGatePolicySummary[];
4177
+ releaseTimelines?: RAGRetrievalReleaseTimelineSummary[];
4178
+ releaseLaneTimelines?: RAGRetrievalReleaseLaneTimelineSummary[];
4179
+ releaseLaneDecisions?: RAGRetrievalReleaseLaneDecisionSummary[];
4180
+ approvalScopes?: RAGRetrievalReleaseApprovalScopeSummary[];
4181
+ releaseLaneEscalationPolicies?: RAGRetrievalReleaseLaneEscalationPolicySummary[];
4182
+ releaseLaneAudits?: RAGRetrievalReleaseLaneAuditSummary[];
4183
+ releaseLaneRecommendations?: RAGRetrievalReleaseLaneRecommendationSummary[];
4184
+ releaseLaneIncidentSummaries?: RAGRetrievalReleaseLaneIncidentSummary[];
4185
+ releaseLaneHandoffs?: RAGRetrievalReleaseLaneHandoffSummary[];
4186
+ recentLaneHandoffDecisions?: RAGRetrievalLaneHandoffDecisionRecord[];
4187
+ recentLaneHandoffIncidents?: RAGRetrievalLaneHandoffIncidentRecord[];
4188
+ handoffFreshnessWindows?: RAGRetrievalLaneHandoffFreshnessWindow[];
4189
+ handoffAutoComplete?: RAGRetrievalLaneHandoffAutoCompleteSummary[];
4190
+ handoffAutoCompletePolicies?: RAGRetrievalLaneHandoffAutoCompletePolicySummary[];
4191
+ handoffAutoCompleteSafety?: RAGRetrievalLaneAutoCompleteSafetySummary[];
4192
+ handoffDriftRollups?: RAGRetrievalLaneHandoffDriftRollup[];
4193
+ handoffDriftCountsByLane?: RAGRetrievalLaneHandoffDriftCountByLane[];
4194
+ recentHandoffAutoCompletePolicyHistory?: RAGRetrievalLaneHandoffAutoCompletePolicyHistoryRecord[];
4195
+ recentReleaseLanePolicyHistory?: RAGRetrievalReleaseLanePolicyHistoryRecord[];
4196
+ recentBaselineGatePolicyHistory?: RAGRetrievalBaselineGatePolicyHistoryRecord[];
4197
+ recentReleaseLaneEscalationPolicyHistory?: RAGRetrievalReleaseLaneEscalationPolicyHistoryRecord[];
4198
+ recentLaneHandoffIncidentHistory?: RAGRetrievalLaneHandoffIncidentHistoryRecord[];
4199
+ recentIncidents?: RAGRetrievalReleaseIncidentRecord[];
4200
+ recentIncidentRemediationDecisions?: RAGRetrievalIncidentRemediationDecisionRecord[];
4201
+ recentIncidentRemediationExecutions?: RAGRetrievalIncidentRemediationExecutionHistoryRecord[];
4202
+ incidentRemediationExecutionSummary?: RAGRetrievalIncidentRemediationExecutionSummary;
4203
+ incidentSummary?: RAGRetrievalReleaseIncidentSummary;
4204
+ relatedSearchTraces?: RAGSearchTraceStats;
4205
+ relatedPruneRun?: RAGSearchTracePruneRun;
4206
+ };
4207
+ export type RAGIngestSourceInput = {
4208
+ /**
4209
+ * Stable identifier the consumer owns for this document/source. All chunk ids
4210
+ * are derived deterministically from it (`${sourceId}#${index}`) and it is
4211
+ * stamped into every chunk's metadata as `sourceId`, so the whole set can be
4212
+ * deleted or replaced later without the consumer tracking individual ids.
4213
+ */
4214
+ sourceId: string;
4215
+ /** Ingest from in-memory file bytes (any extractor-supported type). */
4216
+ upload?: RAGDocumentUploadInput;
4217
+ /** Ingest from a URL (fetched + extracted by content type). */
4218
+ url?: RAGDocumentUrlInput;
4219
+ /** Ingest from an already-extracted text document. */
4220
+ document?: RAGIngestDocument;
4221
+ /** Extra metadata merged into every chunk (alongside `sourceId`). */
4222
+ metadata?: Record<string, unknown>;
4223
+ /** Chunking options applied to this source. */
4224
+ chunking?: RAGChunkingOptions;
4225
+ chunkingRegistry?: RAGChunkingRegistryLike;
4226
+ /** Custom file extractors (for upload/url ingest). */
4227
+ extractors?: RAGFileExtractor[];
4228
+ extractorRegistry?: RAGFileExtractorRegistryLike;
4229
+ /**
4230
+ * Override the embedding `kind` used for the chunks. Defaults to `"passage"`
4231
+ * so asymmetric embedders index document text with the document/passage
4232
+ * embedding while search continues to use the query embedding.
4233
+ */
4234
+ embedKind?: RAGEmbeddingKind;
4235
+ /**
4236
+ * Whether to remove any existing chunks for this sourceId before ingesting
4237
+ * (idempotent replace). Defaults to `true`.
4238
+ */
4239
+ replace?: boolean;
4240
+ /**
4241
+ * Chunk count from a prior ingest of this sourceId. Used when replacing on
4242
+ * stores that cannot metadata-filter-delete, so the previous deterministic id
4243
+ * set is removed even if the new ingest produces fewer chunks.
4244
+ */
4245
+ previousChunkCount?: number;
4246
+ };
4247
+ export type RAGIngestSourceResult = {
4248
+ sourceId: string;
4249
+ chunkCount: number;
4250
+ chunkIds: string[];
4251
+ };
4252
+ export type RAGRemoveSourceInput = {
4253
+ sourceId: string;
4254
+ /**
4255
+ * Number of chunks the source produced (from `RAGIngestSourceResult`).
4256
+ * Required to delete by deterministic id on stores that cannot
4257
+ * metadata-filter-delete (e.g. Pinecone serverless).
4258
+ */
4259
+ chunkCount?: number;
4260
+ /** Explicit chunk ids to delete (takes precedence over `chunkCount`). */
4261
+ chunkIds?: string[];
4262
+ /**
4263
+ * Also issue a metadata-filter delete on `{ sourceId }`. Defaults to `true`;
4264
+ * harmless (and cheap) on filter-capable stores, ignored when unsupported.
4265
+ */
4266
+ filterDelete?: boolean;
4267
+ };
4268
+ export type RAGRemoveSourceResult = {
4269
+ sourceId: string;
4270
+ deleted: number;
4271
+ };
4272
+ export type RAGCollection = {
4273
+ store: RAGVectorStore;
4274
+ search: (input: RAGCollectionSearchParams) => Promise<RAGQueryResult[]>;
4275
+ searchWithTrace: (input: RAGCollectionSearchParams) => Promise<RAGCollectionSearchResult>;
4276
+ ingest: (input: RAGUpsertInput) => Promise<void>;
4277
+ /**
4278
+ * Ingest a single document as a tracked source: extract → chunk → embed with
4279
+ * the passage/document kind → upsert with deterministic, source-derived chunk
4280
+ * ids. Returns the ids/count so the set is deletable via `removeSource`.
4281
+ */
4282
+ ingestSource: (input: RAGIngestSourceInput) => Promise<RAGIngestSourceResult>;
4283
+ /** Delete every chunk previously ingested under `sourceId`. */
4284
+ removeSource: (input: RAGRemoveSourceInput) => Promise<RAGRemoveSourceResult>;
4285
+ clear?: () => Promise<void> | void;
4286
+ getStatus?: () => RAGVectorStoreStatus;
4287
+ getCapabilities?: () => RAGBackendCapabilities;
4288
+ };
4289
+ export type RAGIndexManager = {
4290
+ listDocuments: (input?: {
4291
+ kind?: string;
4292
+ }) => Promise<RAGIndexedDocument[]> | RAGIndexedDocument[];
4293
+ createDocument?: (input: RAGIngestDocument) => Promise<RAGMutationResponse> | RAGMutationResponse;
4294
+ getDocumentChunks: (id: string) => Promise<RAGDocumentChunkPreview | null> | RAGDocumentChunkPreview | null;
4295
+ deleteDocument?: (id: string) => Promise<boolean> | boolean;
4296
+ reindexDocument?: (id: string) => Promise<RAGMutationResponse | void> | RAGMutationResponse | void;
4297
+ reindexSource?: (source: string) => Promise<RAGMutationResponse | void> | RAGMutationResponse | void;
4298
+ listSyncSources?: () => Promise<RAGSyncSourceRecord[]> | RAGSyncSourceRecord[];
4299
+ syncSource?: (id: string, options?: RAGSyncRunOptions) => Promise<RAGSyncResponse | void> | RAGSyncResponse | void;
4300
+ syncAllSources?: (options?: RAGSyncRunOptions) => Promise<RAGSyncResponse | void> | RAGSyncResponse | void;
4301
+ reseed?: () => Promise<RAGMutationResponse | void> | RAGMutationResponse | void;
4302
+ reset?: () => Promise<RAGMutationResponse | void> | RAGMutationResponse | void;
4303
+ listBackends?: () => Promise<Omit<RAGBackendsResponse, "ok"> | RAGBackendDescriptor[]> | Omit<RAGBackendsResponse, "ok"> | RAGBackendDescriptor[];
4304
+ };
4305
+ export type RAGHTMXWorkflowRenderConfig = {
4306
+ status?: (input: {
4307
+ admin?: RAGAdminCapabilities;
4308
+ adminActions?: RAGAdminActionRecord[];
4309
+ adminJobs?: RAGAdminJobRecord[];
4310
+ maintenance?: RAGBackendMaintenanceSummary;
4311
+ retrievalComparisons?: RAGOperationsResponse["retrievalComparisons"];
4312
+ path?: string;
4313
+ status?: RAGVectorStoreStatus;
4314
+ capabilities?: RAGBackendCapabilities;
4315
+ documents?: RAGDocumentSummary;
4316
+ }) => string;
4317
+ maintenance?: (input: {
4318
+ admin?: RAGAdminCapabilities;
4319
+ adminActions?: RAGAdminActionRecord[];
4320
+ adminJobs?: RAGAdminJobRecord[];
4321
+ maintenance?: RAGBackendMaintenanceSummary;
4322
+ path?: string;
4323
+ status?: RAGVectorStoreStatus;
4324
+ }) => string;
4325
+ searchResults?: (input: {
4326
+ query: string;
4327
+ results: RAGSource[];
4328
+ trace?: RAGRetrievalTrace;
4329
+ }) => string;
4330
+ searchResultItem?: (source: RAGSource, index: number) => string;
4331
+ documents?: (input: {
4332
+ documents: RAGIndexedDocument[];
4333
+ }) => string;
4334
+ documentItem?: (document: RAGIndexedDocument, index: number) => string;
4335
+ chunkPreview?: (input: RAGDocumentChunkPreview) => string;
4336
+ evaluateResult?: (input: {
4337
+ cases: RAGEvaluationCaseResult[];
4338
+ summary: RAGEvaluationSummary;
4339
+ }) => string;
4340
+ adaptiveNativePlannerBenchmark?: (input: RAGAdaptiveNativePlannerBenchmarkResponse) => string;
4341
+ nativeBackendComparisonBenchmark?: (input: RAGNativeBackendComparisonBenchmarkResponse) => string;
4342
+ presentationCueBenchmark?: (input: RAGPresentationCueBenchmarkResponse) => string;
4343
+ spreadsheetCueBenchmark?: (input: RAGSpreadsheetCueBenchmarkResponse) => string;
4344
+ adaptiveNativePlannerBenchmarkSnapshot?: (input: RAGAdaptiveNativePlannerBenchmarkSnapshotResponse) => string;
4345
+ nativeBackendComparisonBenchmarkSnapshot?: (input: RAGNativeBackendComparisonBenchmarkSnapshotResponse) => string;
4346
+ presentationCueBenchmarkSnapshot?: (input: RAGPresentationCueBenchmarkSnapshotResponse) => string;
4347
+ spreadsheetCueBenchmarkSnapshot?: (input: RAGSpreadsheetCueBenchmarkSnapshotResponse) => string;
4348
+ mutationResult?: (input: RAGMutationResponse) => string;
4349
+ emptyState?: (kind: "documents" | "searchResults" | "chunkPreview" | "status" | "evaluation") => string;
4350
+ error?: (message: string) => string;
4351
+ };
4352
+ export type RAGHTMXConfig = {
4353
+ render?: AIHTMXRenderConfig;
4354
+ workflowRender?: RAGHTMXWorkflowRenderConfig;
4355
+ /** @deprecated Use workflowRender instead. */
4356
+ workflow?: {
4357
+ render?: RAGHTMXWorkflowRenderConfig;
4358
+ };
4359
+ };
4360
+ export type RAGChatPluginConfig = AIChatPluginConfig & {
4361
+ path?: string;
4362
+ ragStore?: RAGVectorStore;
4363
+ collection?: RAGCollection;
4364
+ jobStateStore?: RAGJobStateStore;
4365
+ evaluationSuiteSnapshotHistoryStore?: RAGEvaluationSuiteSnapshotHistoryStore;
4366
+ authorizeRAGAction?: RAGAuthorizationProvider;
4367
+ resolveRAGAccessScope?: RAGAccessScopeProvider;
4368
+ jobHistoryRetention?: RAGJobHistoryRetention;
4369
+ searchTraceStore?: RAGSearchTraceStore;
4370
+ searchTraceRetention?: RAGSearchTracePruneInput;
4371
+ searchTraceRetentionSchedule?: RAGSearchTraceRetentionSchedule;
4372
+ searchTracePruneHistoryStore?: RAGSearchTracePruneHistoryStore;
4373
+ retrievalComparisonHistoryStore?: RAGRetrievalComparisonHistoryStore;
4374
+ retrievalBaselineStore?: RAGRetrievalBaselineStore;
4375
+ retrievalReleaseDecisionStore?: RAGRetrievalReleaseDecisionStore;
4376
+ retrievalLaneHandoffDecisionStore?: RAGRetrievalLaneHandoffDecisionStore;
4377
+ retrievalLaneHandoffIncidentStore?: RAGRetrievalLaneHandoffIncidentStore;
4378
+ retrievalLaneHandoffIncidentHistoryStore?: RAGRetrievalLaneHandoffIncidentHistoryStore;
4379
+ retrievalLaneHandoffAutoCompletePolicyHistoryStore?: RAGRetrievalLaneHandoffAutoCompletePolicyHistoryStore;
4380
+ retrievalReleaseLanePolicyHistoryStore?: RAGRetrievalReleaseLanePolicyHistoryStore;
4381
+ retrievalBaselineGatePolicyHistoryStore?: RAGRetrievalBaselineGatePolicyHistoryStore;
4382
+ retrievalReleaseLaneEscalationPolicyHistoryStore?: RAGRetrievalReleaseLaneEscalationPolicyHistoryStore;
4383
+ retrievalReleaseIncidentStore?: RAGRetrievalReleaseIncidentStore;
4384
+ retrievalIncidentRemediationDecisionStore?: RAGRetrievalIncidentRemediationDecisionStore;
4385
+ retrievalIncidentRemediationExecutionHistoryStore?: RAGRetrievalIncidentRemediationExecutionHistoryStore;
4386
+ retrievalLaneHandoffAutoCompletePoliciesByGroupAndTargetRolloutLabel?: Record<string, Partial<Record<Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>, RAGRetrievalLaneHandoffAutoCompletePolicy>>>;
4387
+ retrievalReleasePolicies?: Record<string, RAGRetrievalReleasePolicy>;
4388
+ retrievalReleasePoliciesByRolloutLabel?: Partial<Record<Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>, RAGRetrievalReleasePolicy>>;
4389
+ retrievalReleasePoliciesByGroupAndRolloutLabel?: Record<string, Partial<Record<Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>, RAGRetrievalReleasePolicy>>>;
4390
+ retrievalBaselineGatePoliciesByRolloutLabel?: Partial<Record<Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>, RAGRetrievalBaselineGatePolicy>>;
4391
+ retrievalBaselineGatePoliciesByGroup?: Record<string, RAGRetrievalBaselineGatePolicy>;
4392
+ retrievalBaselineGatePoliciesByGroupAndRolloutLabel?: Record<string, Partial<Record<Exclude<RAGRetrievalBaselineRecord["rolloutLabel"], undefined>, RAGRetrievalBaselineGatePolicy>>>;
4393
+ onRetrievalReleaseEvent?: (event: RAGRetrievalReleaseEvent) => void | Promise<void>;
4394
+ extractors?: RAGFileExtractor[];
4395
+ embedding?: RAGEmbeddingProviderLike;
4396
+ embeddingModel?: string;
4397
+ readinessProviderName?: string;
4398
+ rerank?: RAGRerankerProviderLike;
4399
+ indexManager?: RAGIndexManager;
4400
+ topK?: number;
4401
+ scoreThreshold?: number;
4402
+ staleAfterMs?: number;
4403
+ ragCompleteSources?: boolean;
4404
+ systemPrompt?: string;
4405
+ htmx?: boolean | RAGHTMXConfig;
4406
+ onComplete?: (conversationId: string, fullResponse: string, usage?: AIUsage, sources?: RAGSource[]) => void;
4407
+ };