@cue-dev/retrieval-core 0.1.3

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.
@@ -0,0 +1,673 @@
1
+ import type { EnhancePromptInput, EnhancePromptOutput, EnhancePromptStyle, SearchContextInput, SearchContextOutput } from "@cue-dev/contracts";
2
+ import { type CandidateScoreWeights, type IndexRepository, type QueryCache, type WorkspaceRecord } from "@cue-dev/data-plane";
3
+ import { type Observability } from "@cue-dev/observability";
4
+ import { type ChunkingStrategy } from "./chunking.js";
5
+ type ContextRef = EnhancePromptOutput["context_refs"][number];
6
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_BASE_URL = "https://router.tumuer.me/v1";
7
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_MODEL = "Qwen/Qwen3-Embedding-4B";
8
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_DIMENSIONS = 2560;
9
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_TIMEOUT_MS = 10000;
10
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_BATCH_SIZE = 64;
11
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_MAX_RETRIES = 2;
12
+ export declare const DEFAULT_OPENAI_COMPATIBLE_EMBEDDING_TRANSIENT_403_MAX_RETRIES = 4;
13
+ export declare const DEFAULT_OPENAI_COMPATIBLE_RERANKER_BASE_URL = "https://router.tumuer.me/v1";
14
+ export declare const DEFAULT_OPENAI_COMPATIBLE_RERANKER_MODEL = "Qwen/Qwen3-Reranker-4B";
15
+ export declare const DEFAULT_OPENAI_COMPATIBLE_RERANKER_TIMEOUT_MS = 2500;
16
+ export declare const DEFAULT_SEARCH_RERANKER_TOP_N = 30;
17
+ export declare const DEFAULT_PROVIDER_MAX_REQUESTS_PER_MINUTE = 90;
18
+ export declare const DEFAULT_PROVIDER_LIMIT_INDEX_MAX_WAIT_MS = 120000;
19
+ export declare const DEFAULT_PROVIDER_LIMIT_QUERY_MAX_WAIT_MS = 1000;
20
+ export declare const DEFAULT_PROVIDER_LIMIT_RERANK_MAX_WAIT_MS = 500;
21
+ export declare const DEFAULT_CLAUDE_ENHANCER_MODEL = "claude-3-5-sonnet-latest";
22
+ export interface RetrievalPathBiasConfig {
23
+ source_path_boost: number;
24
+ low_priority_prefix_penalty: number;
25
+ low_priority_substring_penalty: number;
26
+ low_priority_asset_penalty: number;
27
+ lockfile_penalty: number;
28
+ doc_intent_docs_boost: number;
29
+ doc_intent_markdown_boost: number;
30
+ docs_without_doc_intent_penalty: number;
31
+ non_doc_markdown_penalty: number;
32
+ code_intent_docs_penalty: number;
33
+ doc_intent_source_penalty: number;
34
+ workspace_manifest_root_boost: number;
35
+ workspace_manifest_nested_boost: number;
36
+ ui_component_tsx_boost: number;
37
+ ui_component_css_penalty: number;
38
+ docs_archive_penalty: number;
39
+ public_path_penalty: number;
40
+ test_path_penalty: number;
41
+ example_path_penalty: number;
42
+ declaration_file_penalty: number;
43
+ test_intent_test_boost: number;
44
+ example_intent_example_boost: number;
45
+ filename_token_match_boost: number;
46
+ negation_avoid_docs_penalty: number;
47
+ negation_avoid_tests_penalty: number;
48
+ negation_avoid_examples_penalty: number;
49
+ negation_avoid_archive_penalty: number;
50
+ security_trace_meta_penalty: number;
51
+ literal_path_boost: number;
52
+ literal_snippet_boost: number;
53
+ literal_max_boost: number;
54
+ min_total_bias: number;
55
+ max_total_bias: number;
56
+ }
57
+ export interface RetrievalRerankConfig {
58
+ low_information_penalty: number;
59
+ max_chunks_per_path_default: number;
60
+ max_chunks_per_path_file_lookup: number;
61
+ same_directory_penalty: number;
62
+ same_extension_penalty: number;
63
+ merge_overlapping_chunks_enabled: boolean;
64
+ merge_gap_lines: number;
65
+ merge_max_span_lines: number;
66
+ smart_cutoff_enabled: boolean;
67
+ smart_cutoff_min_k: number;
68
+ smart_cutoff_max_k: number;
69
+ smart_cutoff_min_score: number;
70
+ smart_cutoff_top_ratio: number;
71
+ smart_cutoff_delta_abs: number;
72
+ }
73
+ export interface RetrievalScoringConfig {
74
+ candidate_weights: CandidateScoreWeights;
75
+ path_bias: RetrievalPathBiasConfig;
76
+ rerank: RetrievalRerankConfig;
77
+ }
78
+ export interface RetrievalEnhancerConfig {
79
+ max_expansion_hints: number;
80
+ max_candidates_pre_rerank: number;
81
+ rerank_timeout_ms: number;
82
+ }
83
+ export type EnhancerToolMode = "none" | "read_only";
84
+ export interface RetrievalEnhancerGenerationConfig {
85
+ timeout_ms: number;
86
+ max_retries: number;
87
+ tool_mode: EnhancerToolMode;
88
+ max_context_snippets: number;
89
+ }
90
+ export interface RetrievalChunkingConfig {
91
+ strategy: ChunkingStrategy;
92
+ fallback_strategy: "sliding";
93
+ target_chunk_tokens: number;
94
+ chunk_overlap_tokens: number;
95
+ budget_tokenizer: "ranking" | "lightweight";
96
+ boundary_strictness: "legacy" | "semantic_js_ts";
97
+ parse_timeout_ms: number;
98
+ enabled_languages: string[];
99
+ recursive_semantic_chunking_enabled: boolean;
100
+ semantic_merge_gap_lines: number;
101
+ semantic_merge_max_span_lines: number;
102
+ comment_forward_absorb_enabled: boolean;
103
+ embedding_context_prefix_enabled: boolean;
104
+ }
105
+ export interface RetrievalContextPackingConfig {
106
+ enabled: boolean;
107
+ max_spans_per_result: number;
108
+ max_gap_lines: number;
109
+ max_snippet_chars: number;
110
+ enhancer_snippet_char_limit: number;
111
+ }
112
+ export interface RetrievalSnippetIntegrityConfig {
113
+ enabled: boolean;
114
+ target_languages: string[];
115
+ max_contiguous_gap_lines: number;
116
+ marker_template_version: "v1";
117
+ repair_enabled: boolean;
118
+ repair_max_envelope_lines: number;
119
+ repair_max_snippet_chars: number;
120
+ }
121
+ export type RetrievalScoringConfigInput = Partial<{
122
+ candidate_weights: Partial<CandidateScoreWeights>;
123
+ path_bias: Partial<RetrievalPathBiasConfig>;
124
+ rerank: Partial<RetrievalRerankConfig>;
125
+ }>;
126
+ export type RetrievalEnhancerConfigInput = Partial<RetrievalEnhancerConfig>;
127
+ export type RetrievalEnhancerGenerationConfigInput = Partial<RetrievalEnhancerGenerationConfig>;
128
+ export type RetrievalChunkingConfigInput = Partial<{
129
+ strategy: ChunkingStrategy;
130
+ fallback_strategy: "sliding";
131
+ target_chunk_tokens: number;
132
+ chunk_overlap_tokens: number;
133
+ budget_tokenizer: "ranking" | "lightweight";
134
+ boundary_strictness: "legacy" | "semantic_js_ts";
135
+ parse_timeout_ms: number;
136
+ enabled_languages: string[];
137
+ recursive_semantic_chunking_enabled: boolean;
138
+ semantic_merge_gap_lines: number;
139
+ semantic_merge_max_span_lines: number;
140
+ comment_forward_absorb_enabled: boolean;
141
+ embedding_context_prefix_enabled: boolean;
142
+ }>;
143
+ export type RetrievalContextPackingConfigInput = Partial<RetrievalContextPackingConfig>;
144
+ export type RetrievalSnippetIntegrityConfigInput = Partial<{
145
+ enabled: boolean;
146
+ target_languages: string[];
147
+ max_contiguous_gap_lines: number;
148
+ marker_template_version: "v1";
149
+ repair_enabled: boolean;
150
+ repair_max_envelope_lines: number;
151
+ repair_max_snippet_chars: number;
152
+ }>;
153
+ export declare const BASELINE_RETRIEVAL_SCORING_CONFIG: RetrievalScoringConfig;
154
+ export declare const CONSERVATIVE_RETRIEVAL_SCORING_CONFIG: RetrievalScoringConfig;
155
+ export declare const DEFAULT_RETRIEVAL_ENHANCER_CONFIG: RetrievalEnhancerConfig;
156
+ export declare const DEFAULT_RETRIEVAL_ENHANCER_GENERATION_CONFIG: RetrievalEnhancerGenerationConfig;
157
+ export declare const DEFAULT_RETRIEVAL_CHUNKING_CONFIG: RetrievalChunkingConfig;
158
+ export declare const DEFAULT_RETRIEVAL_CONTEXT_PACKING_CONFIG: RetrievalContextPackingConfig;
159
+ export declare const DEFAULT_RETRIEVAL_SNIPPET_INTEGRITY_CONFIG: RetrievalSnippetIntegrityConfig;
160
+ declare const BUILTIN_RETRIEVAL_SCORING_PROFILES: {
161
+ readonly baseline: RetrievalScoringConfig;
162
+ readonly conservative: RetrievalScoringConfig;
163
+ };
164
+ export type BuiltinRetrievalScoringProfileId = keyof typeof BUILTIN_RETRIEVAL_SCORING_PROFILES;
165
+ export declare function resolveRetrievalScoringProfile(profile_id: string | undefined): {
166
+ profile_id: BuiltinRetrievalScoringProfileId;
167
+ config: RetrievalScoringConfig;
168
+ };
169
+ export declare function mergeRetrievalScoringConfig(base: RetrievalScoringConfig, overrides?: RetrievalScoringConfigInput): RetrievalScoringConfig;
170
+ export declare function mergeRetrievalEnhancerConfig(base: RetrievalEnhancerConfig, overrides?: RetrievalEnhancerConfigInput): RetrievalEnhancerConfig;
171
+ export declare function mergeRetrievalEnhancerGenerationConfig(base: RetrievalEnhancerGenerationConfig, overrides?: RetrievalEnhancerGenerationConfigInput): RetrievalEnhancerGenerationConfig;
172
+ export declare function mergeRetrievalChunkingConfig(base: RetrievalChunkingConfig, overrides?: RetrievalChunkingConfigInput): RetrievalChunkingConfig;
173
+ export declare function mergeRetrievalContextPackingConfig(base: RetrievalContextPackingConfig, overrides?: RetrievalContextPackingConfigInput): RetrievalContextPackingConfig;
174
+ export declare function mergeRetrievalSnippetIntegrityConfig(base: RetrievalSnippetIntegrityConfig, overrides?: RetrievalSnippetIntegrityConfigInput): RetrievalSnippetIntegrityConfig;
175
+ declare const REASON_STRINGS: readonly ["semantic match", "exact literal match", "path token overlap", "recently modified relevant module"];
176
+ export type RetrievalReason = (typeof REASON_STRINGS)[number];
177
+ export declare class RetrievalError extends Error {
178
+ readonly code: "INVALID_ARGUMENT" | "NOT_FOUND" | "RATE_LIMITED" | "UPSTREAM_FAILURE";
179
+ constructor(code: "INVALID_ARGUMENT" | "NOT_FOUND" | "RATE_LIMITED" | "UPSTREAM_FAILURE", message: string);
180
+ }
181
+ export interface RawFile {
182
+ path: string;
183
+ content: string;
184
+ language?: string;
185
+ updated_at?: string;
186
+ generated?: boolean;
187
+ binary?: boolean;
188
+ }
189
+ export interface IndexUploadArtifact {
190
+ tenant_id: string;
191
+ workspace_id: string;
192
+ index_version: string;
193
+ files: RawFile[];
194
+ manifest?: {
195
+ object_key: string;
196
+ checksum: string;
197
+ };
198
+ }
199
+ export interface IndexDeltaArtifact {
200
+ tenant_id: string;
201
+ workspace_id: string;
202
+ index_version: string;
203
+ base_index_version?: string;
204
+ upsert_files: RawFile[];
205
+ deleted_paths: string[];
206
+ }
207
+ interface ReadyIndex {
208
+ index_id: string;
209
+ tenant_id: string;
210
+ workspace_id: string;
211
+ index_version: string;
212
+ status: "indexing" | "ready" | "failed";
213
+ created_at: string;
214
+ updated_at: string;
215
+ }
216
+ interface PersistedFile {
217
+ file_id: string;
218
+ repo_path: string;
219
+ content_hash: string;
220
+ language?: string;
221
+ }
222
+ export interface IndexingWarning {
223
+ path: string;
224
+ reason: string;
225
+ category: "secret_exclusion" | "filter_exclusion";
226
+ }
227
+ export interface IndexingReport {
228
+ workspace_id: string;
229
+ index_version: string;
230
+ status: "ready";
231
+ counts: {
232
+ added: number;
233
+ modified: number;
234
+ deleted: number;
235
+ unchanged: number;
236
+ skipped: number;
237
+ };
238
+ skipped_files: Array<{
239
+ path: string;
240
+ reason: string;
241
+ }>;
242
+ warnings: IndexingWarning[];
243
+ }
244
+ export interface RetrievalCoreOptions {
245
+ cacheTtlSeconds?: number;
246
+ internalCandidateDepth?: number;
247
+ indexPrepConcurrency?: number;
248
+ indexPrepWindowSize?: number;
249
+ embeddingProvider?: EmbeddingProvider;
250
+ embeddingDescriptor?: EmbeddingDescriptor;
251
+ rerankerProvider?: RerankerProvider;
252
+ rerankerTopN?: number;
253
+ enhancerProvider?: EnhancerGenerationProvider;
254
+ observability?: Observability;
255
+ scoringProfile?: BuiltinRetrievalScoringProfileId;
256
+ scoringProfileId?: string;
257
+ scoringConfig?: RetrievalScoringConfigInput;
258
+ enhancerConfig?: RetrievalEnhancerConfigInput;
259
+ enhancerGenerationConfig?: RetrievalEnhancerGenerationConfigInput;
260
+ chunkingConfig?: RetrievalChunkingConfigInput;
261
+ contextPackingConfig?: RetrievalContextPackingConfigInput;
262
+ snippetIntegrityConfig?: RetrievalSnippetIntegrityConfigInput;
263
+ enhancerDecisionTraceEnabled?: boolean;
264
+ }
265
+ export interface EmbeddingDescriptor {
266
+ provider: string;
267
+ model?: string;
268
+ dimensions: number;
269
+ version?: string;
270
+ }
271
+ export type EmbeddingPurpose = "index" | "query";
272
+ export interface EmbeddingProvider {
273
+ embed(input: {
274
+ texts: string[];
275
+ purpose: EmbeddingPurpose;
276
+ }): Promise<number[][]>;
277
+ describe?(): EmbeddingDescriptor;
278
+ }
279
+ export interface RerankerDescriptor {
280
+ provider: string;
281
+ model?: string;
282
+ }
283
+ export interface RerankerResult {
284
+ index: number;
285
+ relevance_score: number;
286
+ }
287
+ export interface RerankerProvider {
288
+ rerank(input: {
289
+ query: string;
290
+ documents: string[];
291
+ top_n: number;
292
+ }): Promise<RerankerResult[]>;
293
+ describe?(): RerankerDescriptor;
294
+ }
295
+ export type EnhancerIntent = "bugfix" | "feature" | "refactor" | "docs" | "tests" | "unknown";
296
+ export type EnhancerOutputLanguage = "en" | "es" | "zh";
297
+ type ResolvedEnhancerPromptStyle = Exclude<EnhancePromptStyle, "auto">;
298
+ export interface EnhancerContextSnippet {
299
+ path: string;
300
+ start_line: number;
301
+ end_line: number;
302
+ reason: string;
303
+ snippet: string;
304
+ score: number;
305
+ }
306
+ export interface EnhancerGenerationRequest {
307
+ trace_id: string;
308
+ tenant_id: string;
309
+ workspace_id?: string;
310
+ request: EnhancePromptInput;
311
+ style_requested: EnhancePromptStyle;
312
+ style_resolved: ResolvedEnhancerPromptStyle;
313
+ intent: EnhancerIntent;
314
+ query_intent: "symbol-heavy" | "impl-focused" | "conceptual";
315
+ language: EnhancerOutputLanguage;
316
+ context_refs: ContextRef[];
317
+ context_snippets: EnhancerContextSnippet[];
318
+ warnings: string[];
319
+ questions: string[];
320
+ tool_mode: EnhancerToolMode;
321
+ abort_signal?: AbortSignal;
322
+ on_progress?: () => void;
323
+ }
324
+ export interface EnhancerGenerationResult {
325
+ enhanced_prompt: string;
326
+ }
327
+ export interface EnhancerProviderDescriptor {
328
+ provider: string;
329
+ model?: string;
330
+ }
331
+ export interface EnhancerGenerationProvider {
332
+ generate(input: EnhancerGenerationRequest): Promise<EnhancerGenerationResult>;
333
+ describe?(): EnhancerProviderDescriptor;
334
+ }
335
+ export interface DeterministicEmbeddingProviderOptions {
336
+ dimensions?: number;
337
+ model?: string;
338
+ version?: string;
339
+ }
340
+ export interface OpenAICompatibleEmbeddingProviderOptions {
341
+ base_url: string;
342
+ api_key: string;
343
+ model?: string;
344
+ dimensions?: number;
345
+ timeout_ms?: number;
346
+ batch_size?: number;
347
+ max_retries?: number;
348
+ transient_forbidden_max_retries?: number;
349
+ request_limiter?: ProviderRequestLimiter;
350
+ request_limit_scope_id?: string;
351
+ max_requests_per_minute?: number;
352
+ index_max_wait_ms?: number;
353
+ query_max_wait_ms?: number;
354
+ observability?: Observability;
355
+ }
356
+ export interface OpenAICompatibleRerankerProviderOptions {
357
+ base_url: string;
358
+ api_key: string;
359
+ model?: string;
360
+ timeout_ms?: number;
361
+ request_limiter?: ProviderRequestLimiter;
362
+ request_limit_scope_id?: string;
363
+ max_requests_per_minute?: number;
364
+ rerank_max_wait_ms?: number;
365
+ observability?: Observability;
366
+ }
367
+ export interface ClaudeAgentEnhancerProviderOptions {
368
+ api_key: string;
369
+ model?: string;
370
+ base_url?: string;
371
+ max_tokens?: number;
372
+ path_to_claude_code_executable?: string;
373
+ permission_mode?: ClaudeCodePermissionMode;
374
+ }
375
+ export type ClaudeCodePermissionMode = "default" | "acceptEdits" | "bypassPermissions" | "plan";
376
+ export interface ProviderRateLimitAcquireInput {
377
+ scope: string;
378
+ max_requests_per_minute: number;
379
+ max_wait_ms: number;
380
+ }
381
+ export interface ProviderRateLimitAcquireResult {
382
+ wait_ms: number;
383
+ }
384
+ export interface ProviderRequestLimiter {
385
+ readonly mode?: "local" | "redis" | "custom";
386
+ acquire(input: ProviderRateLimitAcquireInput): Promise<ProviderRateLimitAcquireResult>;
387
+ }
388
+ export interface RedisProviderRequestLimiterClient {
389
+ eval(script: string, numKeys: number, ...args: Array<string | number>): Promise<unknown>;
390
+ }
391
+ export interface RedisProviderRequestLimiterOptions {
392
+ redis: RedisProviderRequestLimiterClient;
393
+ key_prefix?: string;
394
+ window_ms?: number;
395
+ now?: () => number;
396
+ sleeper?: (ms: number) => Promise<void>;
397
+ }
398
+ export declare class ProviderRateLimitExceededError extends Error {
399
+ readonly retry_after_ms: number;
400
+ constructor(message: string, retry_after_ms: number);
401
+ }
402
+ export declare class LocalProviderRequestLimiter implements ProviderRequestLimiter {
403
+ readonly mode: "local";
404
+ private readonly buckets;
405
+ private readonly now;
406
+ private readonly sleeper;
407
+ constructor(options?: {
408
+ now?: () => number;
409
+ sleeper?: (ms: number) => Promise<void>;
410
+ });
411
+ acquire(input: ProviderRateLimitAcquireInput): Promise<ProviderRateLimitAcquireResult>;
412
+ }
413
+ export declare class RedisProviderRequestLimiter implements ProviderRequestLimiter {
414
+ readonly mode: "redis";
415
+ private readonly redis;
416
+ private readonly keyPrefix;
417
+ private readonly windowMs;
418
+ private readonly now;
419
+ private readonly sleeper;
420
+ constructor(options: RedisProviderRequestLimiterOptions);
421
+ acquire(input: ProviderRateLimitAcquireInput): Promise<ProviderRateLimitAcquireResult>;
422
+ private reserveAttempt;
423
+ }
424
+ export declare class DeterministicEmbeddingProvider implements EmbeddingProvider {
425
+ private readonly dimensions;
426
+ private readonly model;
427
+ private readonly version;
428
+ constructor(options?: DeterministicEmbeddingProviderOptions);
429
+ embed(input: {
430
+ texts: string[];
431
+ purpose: EmbeddingPurpose;
432
+ }): Promise<number[][]>;
433
+ describe(): EmbeddingDescriptor;
434
+ }
435
+ export declare class OpenAICompatibleEmbeddingProvider implements EmbeddingProvider {
436
+ private readonly baseUrl;
437
+ private readonly endpoint;
438
+ private readonly apiKey;
439
+ private readonly model;
440
+ private readonly dimensions;
441
+ private readonly timeoutMs;
442
+ private readonly batchSize;
443
+ private readonly maxRetries;
444
+ private readonly transientForbiddenMaxRetries;
445
+ private readonly requestLimiter?;
446
+ private readonly requestLimitScope;
447
+ private readonly maxRequestsPerMinute;
448
+ private readonly indexMaxWaitMs;
449
+ private readonly queryMaxWaitMs;
450
+ private readonly observability;
451
+ constructor(options: OpenAICompatibleEmbeddingProviderOptions);
452
+ describe(): EmbeddingDescriptor;
453
+ embed(input: {
454
+ texts: string[];
455
+ purpose: EmbeddingPurpose;
456
+ }): Promise<number[][]>;
457
+ private embedBatchWithRetries;
458
+ private enforceRequestLimit;
459
+ private embedBatchOnce;
460
+ private maxRetriesForReason;
461
+ private retryDelayMs;
462
+ private isTransientForbidden;
463
+ private toProviderFailure;
464
+ }
465
+ export declare class OpenAICompatibleRerankerProvider implements RerankerProvider {
466
+ private readonly endpoint;
467
+ private readonly apiKey;
468
+ private readonly model;
469
+ private readonly timeoutMs;
470
+ private readonly requestLimiter?;
471
+ private readonly requestLimitScope;
472
+ private readonly maxRequestsPerMinute;
473
+ private readonly rerankMaxWaitMs;
474
+ private readonly observability;
475
+ constructor(options: OpenAICompatibleRerankerProviderOptions);
476
+ describe(): RerankerDescriptor;
477
+ rerank(input: {
478
+ query: string;
479
+ documents: string[];
480
+ top_n: number;
481
+ }): Promise<RerankerResult[]>;
482
+ private enforceRequestLimit;
483
+ }
484
+ export declare class ClaudeAgentEnhancerProvider implements EnhancerGenerationProvider {
485
+ private readonly apiKey;
486
+ private readonly model;
487
+ private readonly maxTokens;
488
+ private readonly baseUrl?;
489
+ private readonly pathToClaudeCodeExecutable?;
490
+ private readonly permissionMode;
491
+ constructor(options: ClaudeAgentEnhancerProviderOptions);
492
+ describe(): EnhancerProviderDescriptor;
493
+ generate(input: EnhancerGenerationRequest): Promise<EnhancerGenerationResult>;
494
+ }
495
+ export declare function __applySmartCutoffCandidatesForTests(input: {
496
+ candidates: SearchContextOutput["results"];
497
+ config: RetrievalRerankConfig;
498
+ }): SearchContextOutput["results"];
499
+ export declare class InMemoryIndexStore implements IndexRepository {
500
+ private readonly workspaces;
501
+ private readonly workspacesByPath;
502
+ private readonly indexes;
503
+ private readonly workspaceIndexes;
504
+ private readonly filesByIndex;
505
+ private readonly chunksByFile;
506
+ private readonly indexMetadata;
507
+ migrate(): Promise<void>;
508
+ upsertWorkspace(input: WorkspaceRecord): Promise<void>;
509
+ resolveWorkspaceByProjectRoot(tenant_id: string, project_root_path: string): Promise<WorkspaceRecord | undefined>;
510
+ resolveWorkspaceByWorkspaceId(tenant_id: string, workspace_id: string): Promise<WorkspaceRecord | undefined>;
511
+ createIndexVersion(input: {
512
+ tenant_id: string;
513
+ workspace_id: string;
514
+ index_version: string;
515
+ status?: "indexing" | "ready" | "failed";
516
+ }): Promise<ReadyIndex>;
517
+ markIndexStatus(input: {
518
+ tenant_id: string;
519
+ workspace_id: string;
520
+ index_id: string;
521
+ status: "indexing" | "ready" | "failed";
522
+ }): Promise<void>;
523
+ getIndexByVersion(input: {
524
+ tenant_id: string;
525
+ workspace_id: string;
526
+ index_version: string;
527
+ }): Promise<ReadyIndex | undefined>;
528
+ resetIndexContent(input: {
529
+ tenant_id: string;
530
+ index_id: string;
531
+ }): Promise<void>;
532
+ getLatestReadyIndex(input: {
533
+ tenant_id: string;
534
+ workspace_id: string;
535
+ }): Promise<ReadyIndex | undefined>;
536
+ getFilesByIndex(input: {
537
+ tenant_id: string;
538
+ index_id: string;
539
+ }): Promise<PersistedFile[]>;
540
+ copyFileFromIndex(input: {
541
+ tenant_id: string;
542
+ source_index_id: string;
543
+ target_index_id: string;
544
+ repo_path: string;
545
+ }): Promise<void>;
546
+ upsertFile(input: {
547
+ tenant_id: string;
548
+ index_id: string;
549
+ repo_path: string;
550
+ content_hash: string;
551
+ size_bytes: number;
552
+ language?: string;
553
+ }): Promise<{
554
+ file_id: string;
555
+ }>;
556
+ replaceFileChunks(input: {
557
+ tenant_id: string;
558
+ file_id: string;
559
+ repo_path: string;
560
+ chunks: Array<{
561
+ start_line: number;
562
+ end_line: number;
563
+ snippet: string;
564
+ embedding: number[];
565
+ generated?: boolean;
566
+ updated_at?: string;
567
+ }>;
568
+ }): Promise<void>;
569
+ saveManifest(): Promise<void>;
570
+ saveIndexMetadata(input: {
571
+ tenant_id: string;
572
+ index_id: string;
573
+ embedding_provider: string;
574
+ embedding_model?: string;
575
+ embedding_dimensions: number;
576
+ embedding_version?: string;
577
+ chunking_strategy: "language_aware" | "sliding";
578
+ chunking_fallback_strategy: "sliding";
579
+ }): Promise<void>;
580
+ getIndexMetadata(input: {
581
+ tenant_id: string;
582
+ index_id: string;
583
+ }): Promise<{
584
+ embedding_provider: string;
585
+ embedding_model?: string;
586
+ embedding_dimensions: number;
587
+ embedding_version?: string;
588
+ chunking_strategy: "language_aware" | "sliding";
589
+ chunking_fallback_strategy: "sliding";
590
+ created_at: string;
591
+ } | undefined>;
592
+ listChunksByIndex(input: {
593
+ tenant_id: string;
594
+ index_id: string;
595
+ filters?: {
596
+ language?: string;
597
+ path_prefix?: string;
598
+ glob?: string;
599
+ };
600
+ }): Promise<Array<{
601
+ chunk_id: string;
602
+ file_id: string;
603
+ path: string;
604
+ start_line: number;
605
+ end_line: number;
606
+ snippet: string;
607
+ language?: string;
608
+ generated?: boolean;
609
+ updated_at: string;
610
+ embedding: number[];
611
+ }>>;
612
+ }
613
+ export declare class RetrievalCore {
614
+ private readonly store;
615
+ private readonly cache;
616
+ private readonly cacheTtlSeconds;
617
+ private readonly internalCandidateDepth;
618
+ private readonly embeddingProvider;
619
+ private readonly embeddingDescriptor;
620
+ private readonly rerankerProvider?;
621
+ private readonly rerankerDescriptor?;
622
+ private readonly rerankerTopN;
623
+ private readonly rerankerCacheVariant;
624
+ private readonly observability;
625
+ private readonly scoringConfig;
626
+ private readonly scoringProfileId;
627
+ private readonly scoringConfigChecksum;
628
+ private readonly enhancerProvider?;
629
+ private readonly enhancerProviderDescriptor?;
630
+ private readonly enhancerConfig;
631
+ private readonly enhancerGenerationConfig;
632
+ private readonly chunkingConfig;
633
+ private readonly contextPackingConfig;
634
+ private readonly snippetIntegrityConfig;
635
+ private readonly enhancerDecisionTraceEnabled;
636
+ private readonly indexPrepConcurrency;
637
+ private readonly indexPrepWindowSize;
638
+ private cacheHits;
639
+ private cacheMisses;
640
+ constructor(store: IndexRepository, cache: QueryCache, options?: RetrievalCoreOptions);
641
+ private prepareFileForIndexing;
642
+ private prepareFilesForIndexing;
643
+ indexArtifact(artifact: IndexUploadArtifact): Promise<IndexingReport>;
644
+ indexArtifactDelta(artifact: IndexDeltaArtifact): Promise<IndexingReport>;
645
+ getIndexVersion(input: {
646
+ tenant_id: string;
647
+ workspace_id: string;
648
+ index_version: string;
649
+ }): Promise<{
650
+ index_id: string;
651
+ status: "indexing" | "ready" | "failed";
652
+ } | undefined>;
653
+ private applyLearnedReranker;
654
+ searchContext(input: {
655
+ trace_id: string;
656
+ tenant_id: string;
657
+ workspace_id: string;
658
+ request: SearchContextInput;
659
+ }): Promise<SearchContextOutput>;
660
+ private enhancerProviderLabels;
661
+ private buildEnhancerContextSnippets;
662
+ private generateEnhancedPrompt;
663
+ enhancePrompt(input: {
664
+ trace_id: string;
665
+ tenant_id: string;
666
+ workspace_id?: string;
667
+ request: EnhancePromptInput;
668
+ }): Promise<EnhancePromptOutput>;
669
+ }
670
+ export declare function createDefaultRetrievalCore(): RetrievalCore;
671
+ export declare function seedWorkspaceIndex(core: RetrievalCore, artifact: IndexUploadArtifact): Promise<IndexingReport>;
672
+ export * from "./remote-sync.js";
673
+ export * from "./indexing-ignore.js";