@retrivora-ai/rag-engine 2.2.9 → 2.3.1
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.
- package/dist/{LicenseValidator-CENvo9o2.d.mts → BatchProcessor-7yV-UCHW.d.mts} +142 -3
- package/dist/{LicenseValidator-CsjJp2PP.d.ts → BatchProcessor-BfzuU4cK.d.ts} +142 -3
- package/dist/handlers/index.d.mts +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +883 -328
- package/dist/handlers/index.mjs +883 -328
- package/dist/index-DR_O_B-W.d.ts +394 -0
- package/dist/index-fnpaCuma.d.mts +394 -0
- package/dist/index.css +58 -0
- package/dist/index.d.mts +63 -3
- package/dist/index.d.ts +63 -3
- package/dist/index.js +456 -37
- package/dist/index.mjs +455 -39
- package/dist/server.d.mts +35 -73
- package/dist/server.d.ts +35 -73
- package/dist/server.js +914 -342
- package/dist/server.mjs +914 -342
- package/package.json +1 -1
- package/src/components/ChatWidget.tsx +147 -46
- package/src/components/ChatWindow.tsx +52 -8
- package/src/core/BatchProcessor.ts +42 -4
- package/src/core/CircuitBreaker.ts +118 -0
- package/src/core/DatabaseStorage.ts +55 -24
- package/src/core/FreeTierLimitsGuard.ts +281 -0
- package/src/core/LicenseValidator.ts +69 -3
- package/src/core/LicenseVerifier.ts +43 -14
- package/src/core/VectorPlugin.ts +30 -0
- package/src/handlers/index.ts +495 -38
- package/src/index.css +58 -0
- package/src/index.ts +4 -0
- package/src/server.ts +1 -0
- package/dist/index-BPJ3KDYI.d.ts +0 -195
- package/dist/index-Dmq5lH0j.d.mts +0 -195
package/src/index.css
CHANGED
|
@@ -1869,6 +1869,9 @@
|
|
|
1869
1869
|
.opacity-30 {
|
|
1870
1870
|
opacity: 30%;
|
|
1871
1871
|
}
|
|
1872
|
+
.opacity-60 {
|
|
1873
|
+
opacity: 60%;
|
|
1874
|
+
}
|
|
1872
1875
|
.opacity-100 {
|
|
1873
1876
|
opacity: 100%;
|
|
1874
1877
|
}
|
|
@@ -1928,6 +1931,10 @@
|
|
|
1928
1931
|
--tw-drop-shadow: drop-shadow(var(--drop-shadow-2xl));
|
|
1929
1932
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1930
1933
|
}
|
|
1934
|
+
.grayscale {
|
|
1935
|
+
--tw-grayscale: grayscale(100%);
|
|
1936
|
+
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1937
|
+
}
|
|
1931
1938
|
.filter {
|
|
1932
1939
|
filter: var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,);
|
|
1933
1940
|
}
|
|
@@ -2354,6 +2361,11 @@
|
|
|
2354
2361
|
opacity: 30%;
|
|
2355
2362
|
}
|
|
2356
2363
|
}
|
|
2364
|
+
.disabled\:opacity-40 {
|
|
2365
|
+
&:disabled {
|
|
2366
|
+
opacity: 40%;
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2357
2369
|
.disabled\:opacity-50 {
|
|
2358
2370
|
&:disabled {
|
|
2359
2371
|
opacity: 50%;
|
|
@@ -2371,6 +2383,24 @@
|
|
|
2371
2383
|
}
|
|
2372
2384
|
}
|
|
2373
2385
|
}
|
|
2386
|
+
.disabled\:hover\:text-slate-400 {
|
|
2387
|
+
&:disabled {
|
|
2388
|
+
&:hover {
|
|
2389
|
+
@media (hover: hover) {
|
|
2390
|
+
color: var(--color-slate-400);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
.disabled\:hover\:text-slate-600 {
|
|
2396
|
+
&:disabled {
|
|
2397
|
+
&:hover {
|
|
2398
|
+
@media (hover: hover) {
|
|
2399
|
+
color: var(--color-slate-600);
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
}
|
|
2374
2404
|
.disabled\:active\:scale-100 {
|
|
2375
2405
|
&:disabled {
|
|
2376
2406
|
&:active {
|
|
@@ -3549,6 +3579,34 @@
|
|
|
3549
3579
|
}
|
|
3550
3580
|
}
|
|
3551
3581
|
}
|
|
3582
|
+
.dark\:disabled\:hover\:text-white\/40 {
|
|
3583
|
+
@media (prefers-color-scheme: dark) {
|
|
3584
|
+
&:disabled {
|
|
3585
|
+
&:hover {
|
|
3586
|
+
@media (hover: hover) {
|
|
3587
|
+
color: color-mix(in srgb, #fff 40%, transparent);
|
|
3588
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
3589
|
+
color: color-mix(in oklab, var(--color-white) 40%, transparent);
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
.dark\:disabled\:hover\:text-white\/60 {
|
|
3597
|
+
@media (prefers-color-scheme: dark) {
|
|
3598
|
+
&:disabled {
|
|
3599
|
+
&:hover {
|
|
3600
|
+
@media (hover: hover) {
|
|
3601
|
+
color: color-mix(in srgb, #fff 60%, transparent);
|
|
3602
|
+
@supports (color: color-mix(in lab, red, red)) {
|
|
3603
|
+
color: color-mix(in oklab, var(--color-white) 60%, transparent);
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
}
|
|
3552
3610
|
}
|
|
3553
3611
|
@layer base {
|
|
3554
3612
|
:root {
|
package/src/index.ts
CHANGED
|
@@ -65,6 +65,10 @@ export type { Retrivora } from './core/Retrivora';
|
|
|
65
65
|
export type { RetrivoraErrorCode } from './exceptions';
|
|
66
66
|
export { LicenseValidator } from './core/LicenseValidator';
|
|
67
67
|
export type { LicenseValidationRequest, LicenseValidationResponse } from './core/LicenseValidator';
|
|
68
|
+
export { CircuitBreaker } from './core/CircuitBreaker';
|
|
69
|
+
export type { CircuitBreakerOptions } from './core/CircuitBreaker';
|
|
70
|
+
export { BatchProcessor, isTransientError } from './core/BatchProcessor';
|
|
71
|
+
export type { BatchOptions, BatchResult } from './core/BatchProcessor';
|
|
68
72
|
export {
|
|
69
73
|
RetrivoraError,
|
|
70
74
|
ProviderNotFoundException,
|
package/src/server.ts
CHANGED
|
@@ -27,6 +27,7 @@ export type { HealthCheckResult, IProviderValidator, IProviderHealthChecker } fr
|
|
|
27
27
|
export type { ValidationError } from './core/ConfigValidator';
|
|
28
28
|
export type { LicensePayload } from './core/LicenseVerifier';
|
|
29
29
|
export type { BatchOptions, BatchResult } from './core/BatchProcessor';
|
|
30
|
+
export type { HandlerOptions } from './handlers';
|
|
30
31
|
|
|
31
32
|
// ── Core Orchestration ─────────────────────────────────────────
|
|
32
33
|
export { Retrivora } from './core/Retrivora';
|
package/dist/index-BPJ3KDYI.d.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { NextRequest } from 'next/server';
|
|
2
|
-
import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-teTNQ1lh.js';
|
|
3
|
-
|
|
4
|
-
interface ValidationError {
|
|
5
|
-
field: string;
|
|
6
|
-
message: string;
|
|
7
|
-
suggestion?: string;
|
|
8
|
-
severity: 'error' | 'warning';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* ConfigValidator.ts — Comprehensive configuration validation.
|
|
12
|
-
* Uses a pluggable architecture to delegate provider-specific checks.
|
|
13
|
-
*/
|
|
14
|
-
declare class ConfigValidator {
|
|
15
|
-
/**
|
|
16
|
-
* Validates the entire RagConfig object.
|
|
17
|
-
*/
|
|
18
|
-
static validate(config: RagConfig): Promise<ValidationError[]>;
|
|
19
|
-
private static validateVectorDbConfig;
|
|
20
|
-
private static validateLLMConfig;
|
|
21
|
-
private static validateEmbeddingConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Temporary fallbacks for providers not yet migrated to the pluggable architecture.
|
|
24
|
-
*/
|
|
25
|
-
private static fallbackVectorValidation;
|
|
26
|
-
private static fallbackLLMValidation;
|
|
27
|
-
private static fallbackEmbeddingValidation;
|
|
28
|
-
private static validateUIConfig;
|
|
29
|
-
private static validateRAGConfig;
|
|
30
|
-
private static isValidCSSColor;
|
|
31
|
-
static validateAndThrow(config: RagConfig): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Interface for provider-specific configuration validation logic.
|
|
36
|
-
*/
|
|
37
|
-
interface IProviderValidator {
|
|
38
|
-
/**
|
|
39
|
-
* Validates the configuration for a specific provider.
|
|
40
|
-
* @param config - The configuration object to validate.
|
|
41
|
-
* @returns An array of validation errors (empty if valid).
|
|
42
|
-
*/
|
|
43
|
-
validate(config: Record<string, unknown>): ValidationError[];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Result of a provider health check.
|
|
47
|
-
*/
|
|
48
|
-
interface HealthCheckResult {
|
|
49
|
-
healthy: boolean;
|
|
50
|
-
provider: string;
|
|
51
|
-
version?: string;
|
|
52
|
-
capabilities?: Record<string, unknown>;
|
|
53
|
-
error?: string;
|
|
54
|
-
timestamp: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Interface for provider-specific health checking logic.
|
|
58
|
-
*/
|
|
59
|
-
interface IProviderHealthChecker {
|
|
60
|
-
/**
|
|
61
|
-
* Performs a health check for a specific provider.
|
|
62
|
-
* @param config - The configuration object used to connect to the provider.
|
|
63
|
-
* @returns A promise that resolves to the health check result.
|
|
64
|
-
*/
|
|
65
|
-
check(config: Record<string, unknown>): Promise<HealthCheckResult>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* VectorPlugin — main orchestrator class.
|
|
70
|
-
* This is the primary interface for host applications.
|
|
71
|
-
*
|
|
72
|
-
* Features:
|
|
73
|
-
* - Configuration resolution from host + environment
|
|
74
|
-
* - Configuration validation with detailed error messages
|
|
75
|
-
* - Provider health checks before initialization
|
|
76
|
-
* - Multi-provider support (Vector DBs & LLMs)
|
|
77
|
-
* - Per-tenant data isolation via namespacing
|
|
78
|
-
*/
|
|
79
|
-
declare class VectorPlugin {
|
|
80
|
-
private config;
|
|
81
|
-
private pipeline;
|
|
82
|
-
private validationPromise;
|
|
83
|
-
constructor(hostConfig?: Partial<RagConfig>);
|
|
84
|
-
/**
|
|
85
|
-
* Get the current resolved configuration.
|
|
86
|
-
*/
|
|
87
|
-
getConfig(): RagConfig;
|
|
88
|
-
/**
|
|
89
|
-
* Get the initialized LLM provider (available after the first request).
|
|
90
|
-
* Used by handlers to pass to UITransformer.analyzeAndDecide() for
|
|
91
|
-
* LLM-driven visualization decisions.
|
|
92
|
-
*/
|
|
93
|
-
getLLMProvider(): ILLMProvider | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Perform pre-flight health checks on all configured providers.
|
|
96
|
-
* Useful to verify connectivity before running operations.
|
|
97
|
-
*
|
|
98
|
-
* @returns Health status for vector DB, LLM, and embedding providers
|
|
99
|
-
*/
|
|
100
|
-
checkHealth(): Promise<{
|
|
101
|
-
vectorDb: HealthCheckResult;
|
|
102
|
-
llm: HealthCheckResult;
|
|
103
|
-
embedding?: HealthCheckResult;
|
|
104
|
-
allHealthy: boolean;
|
|
105
|
-
}>;
|
|
106
|
-
/**
|
|
107
|
-
* Run a chat query.
|
|
108
|
-
*/
|
|
109
|
-
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
110
|
-
/**
|
|
111
|
-
* Run a streaming chat query.
|
|
112
|
-
*/
|
|
113
|
-
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, unknown>;
|
|
114
|
-
/**
|
|
115
|
-
* Ingest documents into the vector database.
|
|
116
|
-
*/
|
|
117
|
-
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
118
|
-
docId: string | number;
|
|
119
|
-
chunksIngested: number;
|
|
120
|
-
}>>;
|
|
121
|
-
/**
|
|
122
|
-
* Get auto-suggestions based on a query prefix.
|
|
123
|
-
*/
|
|
124
|
-
getSuggestions(query: string, namespace?: string): Promise<string[]>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
interface HandlerOptions {
|
|
128
|
-
onAuthorize?: (req: NextRequest) => boolean | Promise<boolean> | Response | Promise<Response>;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Encode a payload as a Server-Sent Events frame.
|
|
132
|
-
* data: <json>\n\n
|
|
133
|
-
*/
|
|
134
|
-
declare function sseFrame(payload: unknown): string;
|
|
135
|
-
/** Encode a plain text chunk as an SSE frame. */
|
|
136
|
-
declare function sseTextFrame(text: string): string;
|
|
137
|
-
/** Encode the retrieval metadata with UI transformation as an SSE frame. */
|
|
138
|
-
declare function sseMetaFrame(meta: unknown): string;
|
|
139
|
-
/** Encode the UI transformation result as an SSE frame. */
|
|
140
|
-
declare function sseUIFrame(uiTransformation: unknown): string;
|
|
141
|
-
/** Encode the observability trace as an SSE frame. */
|
|
142
|
-
declare function sseObservabilityFrame(trace: unknown): string;
|
|
143
|
-
/** Encode a stream error as an SSE frame. */
|
|
144
|
-
declare function sseErrorFrame(message: string): string;
|
|
145
|
-
/**
|
|
146
|
-
* createChatHandler — factory that returns a Next.js App Router POST handler.
|
|
147
|
-
*/
|
|
148
|
-
declare function createChatHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
149
|
-
/**
|
|
150
|
-
* createStreamHandler — factory for a streaming SSE Next.js App Router POST handler.
|
|
151
|
-
*/
|
|
152
|
-
declare function createStreamHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
153
|
-
/**
|
|
154
|
-
* createIngestHandler — factory for the document ingestion endpoint.
|
|
155
|
-
*/
|
|
156
|
-
declare function createIngestHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
157
|
-
/**
|
|
158
|
-
* createHealthHandler — factory for the health-check endpoint.
|
|
159
|
-
*/
|
|
160
|
-
declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
|
|
161
|
-
/**
|
|
162
|
-
* createLicenseHandler — factory for the license validation endpoint (/v1/license/validate).
|
|
163
|
-
*/
|
|
164
|
-
declare function createLicenseHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
165
|
-
/**
|
|
166
|
-
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
167
|
-
*/
|
|
168
|
-
declare function createUploadHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
169
|
-
/**
|
|
170
|
-
* createSuggestionsHandler — factory for the auto-suggestions endpoint.
|
|
171
|
-
* Supports both POST (JSON body) and GET (URL search parameters).
|
|
172
|
-
*/
|
|
173
|
-
declare function createSuggestionsHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
174
|
-
/**
|
|
175
|
-
* createHistoryHandler — factory for GET /api/retrivora/history and POST /api/retrivora/history/clear.
|
|
176
|
-
*/
|
|
177
|
-
declare function createHistoryHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
178
|
-
/**
|
|
179
|
-
* createFeedbackHandler — factory for POST /api/retrivora/feedback.
|
|
180
|
-
*/
|
|
181
|
-
declare function createFeedbackHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
182
|
-
/**
|
|
183
|
-
* createSessionsHandler — factory for GET /api/retrivora/sessions.
|
|
184
|
-
*/
|
|
185
|
-
declare function createSessionsHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
|
|
186
|
-
/**
|
|
187
|
-
* createRagHandler — factory that returns GET and POST handlers for a catch-all route
|
|
188
|
-
* (e.g. `src/app/api/retrivora/[[...retrivora]]/route.ts`).
|
|
189
|
-
*/
|
|
190
|
-
declare function createRagHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): {
|
|
191
|
-
GET: (req: any, context?: any) => Promise<any>;
|
|
192
|
-
POST: (req: any, context?: any) => Promise<any>;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createLicenseHandler as p, createSuggestionsHandler as q, sseObservabilityFrame as r, sseErrorFrame as s, sseUIFrame as t };
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { NextRequest } from 'next/server';
|
|
2
|
-
import { i as RagConfig, I as ILLMProvider, C as ChatMessage, c as ChatResponse, f as IngestDocument } from './ILLMProvider-teTNQ1lh.mjs';
|
|
3
|
-
|
|
4
|
-
interface ValidationError {
|
|
5
|
-
field: string;
|
|
6
|
-
message: string;
|
|
7
|
-
suggestion?: string;
|
|
8
|
-
severity: 'error' | 'warning';
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* ConfigValidator.ts — Comprehensive configuration validation.
|
|
12
|
-
* Uses a pluggable architecture to delegate provider-specific checks.
|
|
13
|
-
*/
|
|
14
|
-
declare class ConfigValidator {
|
|
15
|
-
/**
|
|
16
|
-
* Validates the entire RagConfig object.
|
|
17
|
-
*/
|
|
18
|
-
static validate(config: RagConfig): Promise<ValidationError[]>;
|
|
19
|
-
private static validateVectorDbConfig;
|
|
20
|
-
private static validateLLMConfig;
|
|
21
|
-
private static validateEmbeddingConfig;
|
|
22
|
-
/**
|
|
23
|
-
* Temporary fallbacks for providers not yet migrated to the pluggable architecture.
|
|
24
|
-
*/
|
|
25
|
-
private static fallbackVectorValidation;
|
|
26
|
-
private static fallbackLLMValidation;
|
|
27
|
-
private static fallbackEmbeddingValidation;
|
|
28
|
-
private static validateUIConfig;
|
|
29
|
-
private static validateRAGConfig;
|
|
30
|
-
private static isValidCSSColor;
|
|
31
|
-
static validateAndThrow(config: RagConfig): Promise<void>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Interface for provider-specific configuration validation logic.
|
|
36
|
-
*/
|
|
37
|
-
interface IProviderValidator {
|
|
38
|
-
/**
|
|
39
|
-
* Validates the configuration for a specific provider.
|
|
40
|
-
* @param config - The configuration object to validate.
|
|
41
|
-
* @returns An array of validation errors (empty if valid).
|
|
42
|
-
*/
|
|
43
|
-
validate(config: Record<string, unknown>): ValidationError[];
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Result of a provider health check.
|
|
47
|
-
*/
|
|
48
|
-
interface HealthCheckResult {
|
|
49
|
-
healthy: boolean;
|
|
50
|
-
provider: string;
|
|
51
|
-
version?: string;
|
|
52
|
-
capabilities?: Record<string, unknown>;
|
|
53
|
-
error?: string;
|
|
54
|
-
timestamp: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Interface for provider-specific health checking logic.
|
|
58
|
-
*/
|
|
59
|
-
interface IProviderHealthChecker {
|
|
60
|
-
/**
|
|
61
|
-
* Performs a health check for a specific provider.
|
|
62
|
-
* @param config - The configuration object used to connect to the provider.
|
|
63
|
-
* @returns A promise that resolves to the health check result.
|
|
64
|
-
*/
|
|
65
|
-
check(config: Record<string, unknown>): Promise<HealthCheckResult>;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* VectorPlugin — main orchestrator class.
|
|
70
|
-
* This is the primary interface for host applications.
|
|
71
|
-
*
|
|
72
|
-
* Features:
|
|
73
|
-
* - Configuration resolution from host + environment
|
|
74
|
-
* - Configuration validation with detailed error messages
|
|
75
|
-
* - Provider health checks before initialization
|
|
76
|
-
* - Multi-provider support (Vector DBs & LLMs)
|
|
77
|
-
* - Per-tenant data isolation via namespacing
|
|
78
|
-
*/
|
|
79
|
-
declare class VectorPlugin {
|
|
80
|
-
private config;
|
|
81
|
-
private pipeline;
|
|
82
|
-
private validationPromise;
|
|
83
|
-
constructor(hostConfig?: Partial<RagConfig>);
|
|
84
|
-
/**
|
|
85
|
-
* Get the current resolved configuration.
|
|
86
|
-
*/
|
|
87
|
-
getConfig(): RagConfig;
|
|
88
|
-
/**
|
|
89
|
-
* Get the initialized LLM provider (available after the first request).
|
|
90
|
-
* Used by handlers to pass to UITransformer.analyzeAndDecide() for
|
|
91
|
-
* LLM-driven visualization decisions.
|
|
92
|
-
*/
|
|
93
|
-
getLLMProvider(): ILLMProvider | undefined;
|
|
94
|
-
/**
|
|
95
|
-
* Perform pre-flight health checks on all configured providers.
|
|
96
|
-
* Useful to verify connectivity before running operations.
|
|
97
|
-
*
|
|
98
|
-
* @returns Health status for vector DB, LLM, and embedding providers
|
|
99
|
-
*/
|
|
100
|
-
checkHealth(): Promise<{
|
|
101
|
-
vectorDb: HealthCheckResult;
|
|
102
|
-
llm: HealthCheckResult;
|
|
103
|
-
embedding?: HealthCheckResult;
|
|
104
|
-
allHealthy: boolean;
|
|
105
|
-
}>;
|
|
106
|
-
/**
|
|
107
|
-
* Run a chat query.
|
|
108
|
-
*/
|
|
109
|
-
chat(message: string, history?: ChatMessage[], namespace?: string): Promise<ChatResponse>;
|
|
110
|
-
/**
|
|
111
|
-
* Run a streaming chat query.
|
|
112
|
-
*/
|
|
113
|
-
chatStream(message: string, history?: ChatMessage[], namespace?: string): AsyncGenerator<string | ChatResponse, void, unknown>;
|
|
114
|
-
/**
|
|
115
|
-
* Ingest documents into the vector database.
|
|
116
|
-
*/
|
|
117
|
-
ingest(documents: IngestDocument[], namespace?: string): Promise<Array<{
|
|
118
|
-
docId: string | number;
|
|
119
|
-
chunksIngested: number;
|
|
120
|
-
}>>;
|
|
121
|
-
/**
|
|
122
|
-
* Get auto-suggestions based on a query prefix.
|
|
123
|
-
*/
|
|
124
|
-
getSuggestions(query: string, namespace?: string): Promise<string[]>;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
interface HandlerOptions {
|
|
128
|
-
onAuthorize?: (req: NextRequest) => boolean | Promise<boolean> | Response | Promise<Response>;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Encode a payload as a Server-Sent Events frame.
|
|
132
|
-
* data: <json>\n\n
|
|
133
|
-
*/
|
|
134
|
-
declare function sseFrame(payload: unknown): string;
|
|
135
|
-
/** Encode a plain text chunk as an SSE frame. */
|
|
136
|
-
declare function sseTextFrame(text: string): string;
|
|
137
|
-
/** Encode the retrieval metadata with UI transformation as an SSE frame. */
|
|
138
|
-
declare function sseMetaFrame(meta: unknown): string;
|
|
139
|
-
/** Encode the UI transformation result as an SSE frame. */
|
|
140
|
-
declare function sseUIFrame(uiTransformation: unknown): string;
|
|
141
|
-
/** Encode the observability trace as an SSE frame. */
|
|
142
|
-
declare function sseObservabilityFrame(trace: unknown): string;
|
|
143
|
-
/** Encode a stream error as an SSE frame. */
|
|
144
|
-
declare function sseErrorFrame(message: string): string;
|
|
145
|
-
/**
|
|
146
|
-
* createChatHandler — factory that returns a Next.js App Router POST handler.
|
|
147
|
-
*/
|
|
148
|
-
declare function createChatHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
149
|
-
/**
|
|
150
|
-
* createStreamHandler — factory for a streaming SSE Next.js App Router POST handler.
|
|
151
|
-
*/
|
|
152
|
-
declare function createStreamHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
153
|
-
/**
|
|
154
|
-
* createIngestHandler — factory for the document ingestion endpoint.
|
|
155
|
-
*/
|
|
156
|
-
declare function createIngestHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
157
|
-
/**
|
|
158
|
-
* createHealthHandler — factory for the health-check endpoint.
|
|
159
|
-
*/
|
|
160
|
-
declare function createHealthHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
|
|
161
|
-
/**
|
|
162
|
-
* createLicenseHandler — factory for the license validation endpoint (/v1/license/validate).
|
|
163
|
-
*/
|
|
164
|
-
declare function createLicenseHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
165
|
-
/**
|
|
166
|
-
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
167
|
-
*/
|
|
168
|
-
declare function createUploadHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: any, context?: any) => Promise<any>;
|
|
169
|
-
/**
|
|
170
|
-
* createSuggestionsHandler — factory for the auto-suggestions endpoint.
|
|
171
|
-
* Supports both POST (JSON body) and GET (URL search parameters).
|
|
172
|
-
*/
|
|
173
|
-
declare function createSuggestionsHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
174
|
-
/**
|
|
175
|
-
* createHistoryHandler — factory for GET /api/retrivora/history and POST /api/retrivora/history/clear.
|
|
176
|
-
*/
|
|
177
|
-
declare function createHistoryHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
178
|
-
/**
|
|
179
|
-
* createFeedbackHandler — factory for POST /api/retrivora/feedback.
|
|
180
|
-
*/
|
|
181
|
-
declare function createFeedbackHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req: NextRequest) => Promise<any>;
|
|
182
|
-
/**
|
|
183
|
-
* createSessionsHandler — factory for GET /api/retrivora/sessions.
|
|
184
|
-
*/
|
|
185
|
-
declare function createSessionsHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): (req?: NextRequest) => Promise<any>;
|
|
186
|
-
/**
|
|
187
|
-
* createRagHandler — factory that returns GET and POST handlers for a catch-all route
|
|
188
|
-
* (e.g. `src/app/api/retrivora/[[...retrivora]]/route.ts`).
|
|
189
|
-
*/
|
|
190
|
-
declare function createRagHandler(configOrPlugin?: Partial<RagConfig> | VectorPlugin, options?: HandlerOptions): {
|
|
191
|
-
GET: (req: any, context?: any) => Promise<any>;
|
|
192
|
-
POST: (req: any, context?: any) => Promise<any>;
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
export { ConfigValidator as C, type HealthCheckResult as H, type IProviderValidator as I, type ValidationError as V, type IProviderHealthChecker as a, VectorPlugin as b, createChatHandler as c, createFeedbackHandler as d, createHealthHandler as e, createHistoryHandler as f, createIngestHandler as g, createRagHandler as h, createSessionsHandler as i, createStreamHandler as j, createUploadHandler as k, sseFrame as l, sseMetaFrame as m, sseTextFrame as n, type HandlerOptions as o, createLicenseHandler as p, createSuggestionsHandler as q, sseObservabilityFrame as r, sseErrorFrame as s, sseUIFrame as t };
|