@absolutejs/ai 0.0.18 → 0.0.19

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