@nice-tools/fake-llm 1.3.0

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,349 @@
1
+ /**
2
+ * Runtime connection configuration (passed at agent creation, NOT in config files)
3
+ */
4
+ interface AdapterConnections {
5
+ cosmos?: {
6
+ endpoint: string;
7
+ key: string;
8
+ };
9
+ blob?: {
10
+ connectionString?: string;
11
+ sasToken?: string;
12
+ accountKey?: string;
13
+ };
14
+ gcs?: {
15
+ projectId: string;
16
+ keyFilePath: string;
17
+ };
18
+ mockCosmos?: {
19
+ basePath: string;
20
+ };
21
+ fallbackLLM?: {
22
+ enabled: boolean;
23
+ endpoint: string;
24
+ apiKey: string;
25
+ model: string;
26
+ };
27
+ }
28
+ /**
29
+ * Describes where configuration files are stored
30
+ */
31
+ interface ConfigSource {
32
+ type: 'local' | 'blob' | 'cosmos' | 'gcs';
33
+ location: {
34
+ container?: string;
35
+ databaseId?: string;
36
+ bucket?: string;
37
+ path?: string;
38
+ };
39
+ }
40
+ /**
41
+ * A keyword defines a domain concept (e.g., "habit", "skill", "moral")
42
+ */
43
+ interface KeywordEntry {
44
+ keyword: string;
45
+ aliases: string[];
46
+ category: string;
47
+ data_source: string;
48
+ source_kind?: 'cosmos' | 'blob' | 'logs' | 'static';
49
+ schema?: Record<string, string>;
50
+ }
51
+ interface StoryContract {
52
+ source_kind: 'cosmos' | 'blob' | 'logs' | 'cross-source';
53
+ sources: string[];
54
+ patterns?: string[];
55
+ query_examples?: string[];
56
+ notes?: string;
57
+ }
58
+ /**
59
+ * A story defines how keywords relate and how to resolve queries
60
+ */
61
+ interface Story {
62
+ story_id: string;
63
+ description: string;
64
+ keywords: string[];
65
+ relations: Relation[];
66
+ resolution_steps: ResolutionStep[];
67
+ contract?: StoryContract;
68
+ }
69
+ interface Relation {
70
+ from_keyword: string;
71
+ to_keyword: string;
72
+ cardinality: 'one-to-one' | 'one-to-many' | 'many-to-many';
73
+ join_via?: string;
74
+ }
75
+ interface ResolutionStep {
76
+ step: number;
77
+ action: 'fetch' | 'filter' | 'enrich' | 'compare' | 'diff';
78
+ keyword?: string;
79
+ from_source?: string;
80
+ on?: string;
81
+ left?: string;
82
+ right?: string;
83
+ }
84
+ /**
85
+ * Parsed user intent from NLP
86
+ */
87
+ interface Intent {
88
+ action: 'list' | 'find' | 'compare' | 'diff' | 'explain';
89
+ keywords: string[];
90
+ filters: Record<string, any>;
91
+ confidence: number;
92
+ }
93
+ interface QueryParams {
94
+ source: string;
95
+ filters?: Record<string, any>;
96
+ limit?: number;
97
+ orderBy?: string;
98
+ }
99
+ interface AnswerDebugStep {
100
+ step: number;
101
+ action: string;
102
+ source?: string;
103
+ queryParams?: QueryParams;
104
+ builtFilter?: string;
105
+ generatedQuery?: string;
106
+ searchPattern?: string;
107
+ rowsReturned: number;
108
+ sampleRows: any[];
109
+ }
110
+ interface AnswerDebug {
111
+ rawQuery: string;
112
+ intent: Intent;
113
+ resolvedKeywords: KeywordEntry[];
114
+ unresolvedTerms: string[];
115
+ storyCandidates: Array<{
116
+ storyId: string;
117
+ score: number;
118
+ matchedKeywords: string[];
119
+ storyKeywords: string[];
120
+ }>;
121
+ selectedStory?: {
122
+ storyId: string;
123
+ score: number;
124
+ };
125
+ threshold: number;
126
+ decision: 'matched-story' | 'no-story-fallback-llm' | 'no-story-no-results' | 'fallback-llm-error';
127
+ steps: AnswerDebugStep[];
128
+ totals: {
129
+ results: number;
130
+ durationMs: number;
131
+ };
132
+ }
133
+ /**
134
+ * Resolved answer from the engine
135
+ */
136
+ interface Answer {
137
+ intent: Intent;
138
+ story?: Story;
139
+ results: any[];
140
+ summary: string;
141
+ metadata: {
142
+ execution_time_ms: number;
143
+ source: 'mock-llm' | 'fallback-llm';
144
+ };
145
+ debug?: AnswerDebug;
146
+ }
147
+
148
+ /**
149
+ * Base adapter interface for data sources
150
+ */
151
+ interface IDataAdapter {
152
+ query(params: QueryParams): Promise<any[]>;
153
+ getById(id: string): Promise<any>;
154
+ }
155
+
156
+ declare abstract class BaseAdapter implements IDataAdapter {
157
+ abstract query(params: QueryParams): Promise<any[]>;
158
+ abstract getById(id: string): Promise<any>;
159
+ protected buildWhereClause(filters: Record<string, any>): string;
160
+ }
161
+
162
+ declare class NLPMatcher {
163
+ parseQuery(query: string): Intent;
164
+ private extractAction;
165
+ private extractKeywords;
166
+ private extractFilters;
167
+ }
168
+
169
+ declare class KeywordResolver {
170
+ private keywords;
171
+ constructor(keywords: KeywordEntry[]);
172
+ resolve(term: string): KeywordEntry | undefined;
173
+ /**
174
+ * Resolves a list of NLP-extracted terms AND also checks the full original query
175
+ * against all keyword aliases (to handle multi-word alias phrases).
176
+ */
177
+ resolveAll(terms: string[], fullQuery?: string): KeywordEntry[];
178
+ getRelatedKeywords(keyword: KeywordEntry): KeywordEntry[];
179
+ }
180
+
181
+ interface StoryMatch {
182
+ story: Story;
183
+ score: number;
184
+ matchedKeywords: string[];
185
+ }
186
+ interface StoryScore {
187
+ storyId: string;
188
+ score: number;
189
+ matchedKeywords: string[];
190
+ storyKeywords: string[];
191
+ }
192
+ declare const STORY_THRESHOLD = 0.1;
193
+ declare class StoryResolver {
194
+ private stories;
195
+ constructor(stories: Story[]);
196
+ scoreAll(intent: Intent, resolvedKeywords: KeywordEntry[]): StoryScore[];
197
+ findBestStory(intent: Intent, resolvedKeywords: KeywordEntry[]): StoryMatch | undefined;
198
+ private scoreStory;
199
+ }
200
+
201
+ declare class QueryBuilder {
202
+ buildQuery(step: ResolutionStep, intent: Intent): QueryParams;
203
+ buildQueryPreview(step: ResolutionStep, intent: Intent, resolvedKeywords?: string[]): {
204
+ generatedQuery: string;
205
+ searchPattern: string;
206
+ };
207
+ buildSQLWhere(filters: Record<string, any>): string;
208
+ }
209
+
210
+ declare class ResponseBuilder {
211
+ buildAnswer(intent: Intent, story: Story | undefined, results: any[], executionTime: number, source: 'mock-llm' | 'fallback-llm'): Answer;
212
+ private buildSummary;
213
+ }
214
+
215
+ interface FetchConfigLoaderOptions {
216
+ /** URL to a pre-aggregated JSON array of all keyword entries, e.g. '/data/keywords.json' */
217
+ keywordsUrl: string;
218
+ /** URL to a pre-aggregated JSON array of all story definitions, e.g. '/data/stories.json' */
219
+ storiesUrl: string;
220
+ }
221
+ /**
222
+ * Isomorphic config loader that fetches keyword and story definitions from
223
+ * pre-aggregated JSON files via `fetch()`.
224
+ *
225
+ * Works in both browser and Node.js (≥ 18) environments with no file-system
226
+ * dependencies. Intended for use with `BrowserMockLLM` and static hosting
227
+ * (e.g. GitHub Pages, CDN, or any HTTP server that can serve JSON files).
228
+ *
229
+ * The expected JSON format for each URL is either:
230
+ * - An array: `[{ keyword: "sky", ... }, ...]`
231
+ * - A single object: `{ keyword: "sky", ... }` (wrapped into a one-element array)
232
+ */
233
+ declare class FetchConfigLoader {
234
+ private options;
235
+ constructor(options: FetchConfigLoaderOptions);
236
+ loadKeywords(): Promise<KeywordEntry[]>;
237
+ loadStories(): Promise<Story[]>;
238
+ }
239
+
240
+ interface HttpMockAdapterOptions {
241
+ /**
242
+ * Base URL for all data-source JSON files, e.g. `'https://example.com/data'`
243
+ * or `'/data'` for a relative path on the same origin.
244
+ *
245
+ * A query for `source: 'knowledge/science'` fetches
246
+ * `{baseUrl}/knowledge/science.json`.
247
+ */
248
+ baseUrl: string;
249
+ }
250
+ /**
251
+ * Isomorphic data adapter that retrieves pre-aggregated JSON from a static
252
+ * HTTP endpoint via `fetch()`.
253
+ *
254
+ * Works in both browser and Node.js (≥ 18) environments with no file-system
255
+ * dependencies. Intended for use with `BrowserMockLLM` and static hosting
256
+ * (e.g. GitHub Pages, CDN, or any HTTP server that can serve JSON files).
257
+ *
258
+ * Filtering and limiting are applied client-side after fetching the full
259
+ * collection, matching the behaviour of `MockCosmosAdapter`.
260
+ */
261
+ declare class HttpMockAdapter extends BaseAdapter {
262
+ private options;
263
+ constructor(options: HttpMockAdapterOptions);
264
+ query(params: QueryParams): Promise<any[]>;
265
+ getById(_id: string): Promise<any>;
266
+ private matchesFilters;
267
+ private getNestedValue;
268
+ }
269
+
270
+ interface QueryOptions {
271
+ debug?: boolean;
272
+ }
273
+ interface FallbackLLMConfig {
274
+ enabled: boolean;
275
+ endpoint: string;
276
+ apiKey: string;
277
+ model: string;
278
+ }
279
+ /**
280
+ * Isomorphic query engine — works in both Node.js and browser environments.
281
+ *
282
+ * Constructed with already-loaded keywords, stories, a data adapter, and an
283
+ * optional fallback-LLM config. Both `MockLLM` (server) and `BrowserMockLLM`
284
+ * (browser) delegate all query logic to this class.
285
+ */
286
+ declare class MockLLMEngine {
287
+ private keywords;
288
+ private stories;
289
+ private adapter;
290
+ private fallbackLLM?;
291
+ private nlpMatcher;
292
+ private keywordResolver;
293
+ private storyResolver;
294
+ private queryBuilder;
295
+ private responseBuilder;
296
+ constructor(keywords: KeywordEntry[], stories: Story[], adapter: BaseAdapter, fallbackLLM?: FallbackLLMConfig | undefined);
297
+ getKeywords(): KeywordEntry[];
298
+ getStories(): Story[];
299
+ listDataSources(): string[];
300
+ getDataSourceSnapshot(source: string, limit?: number): Promise<any[]>;
301
+ query(userQuery: string, opts?: QueryOptions): Promise<Answer>;
302
+ private queryFallbackLLM;
303
+ }
304
+
305
+ interface BrowserMockLLMOptions {
306
+ /** URL to a pre-aggregated JSON array of all keyword entries, e.g. '/data/keywords.json' */
307
+ keywordsUrl: string;
308
+ /** URL to a pre-aggregated JSON array of all story definitions, e.g. '/data/stories.json' */
309
+ storiesUrl: string;
310
+ /**
311
+ * Base URL for data-source JSON files. A query for `source: 'knowledge/science'`
312
+ * fetches `{dataBaseUrl}/knowledge/science.json`.
313
+ */
314
+ dataBaseUrl: string;
315
+ fallbackLLM?: FallbackLLMConfig;
316
+ }
317
+ /**
318
+ * Browser-safe orchestrator for the mock-LLM engine.
319
+ *
320
+ * Loads configuration and data via `fetch()` with no file-system dependencies.
321
+ * Import from `@nice-tools/mock-llm/browser` to keep bundlers from pulling in
322
+ * Node.js-only modules (`fs`, `path`, `@google-cloud/storage`, etc.).
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * import { BrowserMockLLM } from '@nice-tools/mock-llm/browser';
327
+ *
328
+ * const llm = new BrowserMockLLM({
329
+ * keywordsUrl: '/data/keywords.json',
330
+ * storiesUrl: '/data/stories.json',
331
+ * dataBaseUrl: '/data',
332
+ * });
333
+ * await llm.initialize();
334
+ * const answer = await llm.query('what is the color of sky');
335
+ * ```
336
+ */
337
+ declare class BrowserMockLLM {
338
+ private options;
339
+ private engine;
340
+ constructor(options: BrowserMockLLMOptions);
341
+ initialize(): Promise<void>;
342
+ getKeywords(): KeywordEntry[];
343
+ getStories(): Story[];
344
+ listDataSources(): string[];
345
+ getDataSourceSnapshot(source: string, limit?: number): Promise<any[]>;
346
+ query(userQuery: string, opts?: QueryOptions): Promise<Answer>;
347
+ }
348
+
349
+ export { type AdapterConnections, type Answer, type AnswerDebug, type AnswerDebugStep, BaseAdapter, BrowserMockLLM, type BrowserMockLLMOptions, type ConfigSource, type FallbackLLMConfig, FetchConfigLoader, type FetchConfigLoaderOptions, HttpMockAdapter, type HttpMockAdapterOptions, type IDataAdapter, type Intent, type KeywordEntry, KeywordResolver, MockLLMEngine, NLPMatcher, QueryBuilder, type QueryOptions, type QueryParams, type Relation, type ResolutionStep, ResponseBuilder, STORY_THRESHOLD, type Story, type StoryContract, type StoryMatch, StoryResolver, type StoryScore };
@@ -0,0 +1,349 @@
1
+ /**
2
+ * Runtime connection configuration (passed at agent creation, NOT in config files)
3
+ */
4
+ interface AdapterConnections {
5
+ cosmos?: {
6
+ endpoint: string;
7
+ key: string;
8
+ };
9
+ blob?: {
10
+ connectionString?: string;
11
+ sasToken?: string;
12
+ accountKey?: string;
13
+ };
14
+ gcs?: {
15
+ projectId: string;
16
+ keyFilePath: string;
17
+ };
18
+ mockCosmos?: {
19
+ basePath: string;
20
+ };
21
+ fallbackLLM?: {
22
+ enabled: boolean;
23
+ endpoint: string;
24
+ apiKey: string;
25
+ model: string;
26
+ };
27
+ }
28
+ /**
29
+ * Describes where configuration files are stored
30
+ */
31
+ interface ConfigSource {
32
+ type: 'local' | 'blob' | 'cosmos' | 'gcs';
33
+ location: {
34
+ container?: string;
35
+ databaseId?: string;
36
+ bucket?: string;
37
+ path?: string;
38
+ };
39
+ }
40
+ /**
41
+ * A keyword defines a domain concept (e.g., "habit", "skill", "moral")
42
+ */
43
+ interface KeywordEntry {
44
+ keyword: string;
45
+ aliases: string[];
46
+ category: string;
47
+ data_source: string;
48
+ source_kind?: 'cosmos' | 'blob' | 'logs' | 'static';
49
+ schema?: Record<string, string>;
50
+ }
51
+ interface StoryContract {
52
+ source_kind: 'cosmos' | 'blob' | 'logs' | 'cross-source';
53
+ sources: string[];
54
+ patterns?: string[];
55
+ query_examples?: string[];
56
+ notes?: string;
57
+ }
58
+ /**
59
+ * A story defines how keywords relate and how to resolve queries
60
+ */
61
+ interface Story {
62
+ story_id: string;
63
+ description: string;
64
+ keywords: string[];
65
+ relations: Relation[];
66
+ resolution_steps: ResolutionStep[];
67
+ contract?: StoryContract;
68
+ }
69
+ interface Relation {
70
+ from_keyword: string;
71
+ to_keyword: string;
72
+ cardinality: 'one-to-one' | 'one-to-many' | 'many-to-many';
73
+ join_via?: string;
74
+ }
75
+ interface ResolutionStep {
76
+ step: number;
77
+ action: 'fetch' | 'filter' | 'enrich' | 'compare' | 'diff';
78
+ keyword?: string;
79
+ from_source?: string;
80
+ on?: string;
81
+ left?: string;
82
+ right?: string;
83
+ }
84
+ /**
85
+ * Parsed user intent from NLP
86
+ */
87
+ interface Intent {
88
+ action: 'list' | 'find' | 'compare' | 'diff' | 'explain';
89
+ keywords: string[];
90
+ filters: Record<string, any>;
91
+ confidence: number;
92
+ }
93
+ interface QueryParams {
94
+ source: string;
95
+ filters?: Record<string, any>;
96
+ limit?: number;
97
+ orderBy?: string;
98
+ }
99
+ interface AnswerDebugStep {
100
+ step: number;
101
+ action: string;
102
+ source?: string;
103
+ queryParams?: QueryParams;
104
+ builtFilter?: string;
105
+ generatedQuery?: string;
106
+ searchPattern?: string;
107
+ rowsReturned: number;
108
+ sampleRows: any[];
109
+ }
110
+ interface AnswerDebug {
111
+ rawQuery: string;
112
+ intent: Intent;
113
+ resolvedKeywords: KeywordEntry[];
114
+ unresolvedTerms: string[];
115
+ storyCandidates: Array<{
116
+ storyId: string;
117
+ score: number;
118
+ matchedKeywords: string[];
119
+ storyKeywords: string[];
120
+ }>;
121
+ selectedStory?: {
122
+ storyId: string;
123
+ score: number;
124
+ };
125
+ threshold: number;
126
+ decision: 'matched-story' | 'no-story-fallback-llm' | 'no-story-no-results' | 'fallback-llm-error';
127
+ steps: AnswerDebugStep[];
128
+ totals: {
129
+ results: number;
130
+ durationMs: number;
131
+ };
132
+ }
133
+ /**
134
+ * Resolved answer from the engine
135
+ */
136
+ interface Answer {
137
+ intent: Intent;
138
+ story?: Story;
139
+ results: any[];
140
+ summary: string;
141
+ metadata: {
142
+ execution_time_ms: number;
143
+ source: 'mock-llm' | 'fallback-llm';
144
+ };
145
+ debug?: AnswerDebug;
146
+ }
147
+
148
+ /**
149
+ * Base adapter interface for data sources
150
+ */
151
+ interface IDataAdapter {
152
+ query(params: QueryParams): Promise<any[]>;
153
+ getById(id: string): Promise<any>;
154
+ }
155
+
156
+ declare abstract class BaseAdapter implements IDataAdapter {
157
+ abstract query(params: QueryParams): Promise<any[]>;
158
+ abstract getById(id: string): Promise<any>;
159
+ protected buildWhereClause(filters: Record<string, any>): string;
160
+ }
161
+
162
+ declare class NLPMatcher {
163
+ parseQuery(query: string): Intent;
164
+ private extractAction;
165
+ private extractKeywords;
166
+ private extractFilters;
167
+ }
168
+
169
+ declare class KeywordResolver {
170
+ private keywords;
171
+ constructor(keywords: KeywordEntry[]);
172
+ resolve(term: string): KeywordEntry | undefined;
173
+ /**
174
+ * Resolves a list of NLP-extracted terms AND also checks the full original query
175
+ * against all keyword aliases (to handle multi-word alias phrases).
176
+ */
177
+ resolveAll(terms: string[], fullQuery?: string): KeywordEntry[];
178
+ getRelatedKeywords(keyword: KeywordEntry): KeywordEntry[];
179
+ }
180
+
181
+ interface StoryMatch {
182
+ story: Story;
183
+ score: number;
184
+ matchedKeywords: string[];
185
+ }
186
+ interface StoryScore {
187
+ storyId: string;
188
+ score: number;
189
+ matchedKeywords: string[];
190
+ storyKeywords: string[];
191
+ }
192
+ declare const STORY_THRESHOLD = 0.1;
193
+ declare class StoryResolver {
194
+ private stories;
195
+ constructor(stories: Story[]);
196
+ scoreAll(intent: Intent, resolvedKeywords: KeywordEntry[]): StoryScore[];
197
+ findBestStory(intent: Intent, resolvedKeywords: KeywordEntry[]): StoryMatch | undefined;
198
+ private scoreStory;
199
+ }
200
+
201
+ declare class QueryBuilder {
202
+ buildQuery(step: ResolutionStep, intent: Intent): QueryParams;
203
+ buildQueryPreview(step: ResolutionStep, intent: Intent, resolvedKeywords?: string[]): {
204
+ generatedQuery: string;
205
+ searchPattern: string;
206
+ };
207
+ buildSQLWhere(filters: Record<string, any>): string;
208
+ }
209
+
210
+ declare class ResponseBuilder {
211
+ buildAnswer(intent: Intent, story: Story | undefined, results: any[], executionTime: number, source: 'mock-llm' | 'fallback-llm'): Answer;
212
+ private buildSummary;
213
+ }
214
+
215
+ interface FetchConfigLoaderOptions {
216
+ /** URL to a pre-aggregated JSON array of all keyword entries, e.g. '/data/keywords.json' */
217
+ keywordsUrl: string;
218
+ /** URL to a pre-aggregated JSON array of all story definitions, e.g. '/data/stories.json' */
219
+ storiesUrl: string;
220
+ }
221
+ /**
222
+ * Isomorphic config loader that fetches keyword and story definitions from
223
+ * pre-aggregated JSON files via `fetch()`.
224
+ *
225
+ * Works in both browser and Node.js (≥ 18) environments with no file-system
226
+ * dependencies. Intended for use with `BrowserMockLLM` and static hosting
227
+ * (e.g. GitHub Pages, CDN, or any HTTP server that can serve JSON files).
228
+ *
229
+ * The expected JSON format for each URL is either:
230
+ * - An array: `[{ keyword: "sky", ... }, ...]`
231
+ * - A single object: `{ keyword: "sky", ... }` (wrapped into a one-element array)
232
+ */
233
+ declare class FetchConfigLoader {
234
+ private options;
235
+ constructor(options: FetchConfigLoaderOptions);
236
+ loadKeywords(): Promise<KeywordEntry[]>;
237
+ loadStories(): Promise<Story[]>;
238
+ }
239
+
240
+ interface HttpMockAdapterOptions {
241
+ /**
242
+ * Base URL for all data-source JSON files, e.g. `'https://example.com/data'`
243
+ * or `'/data'` for a relative path on the same origin.
244
+ *
245
+ * A query for `source: 'knowledge/science'` fetches
246
+ * `{baseUrl}/knowledge/science.json`.
247
+ */
248
+ baseUrl: string;
249
+ }
250
+ /**
251
+ * Isomorphic data adapter that retrieves pre-aggregated JSON from a static
252
+ * HTTP endpoint via `fetch()`.
253
+ *
254
+ * Works in both browser and Node.js (≥ 18) environments with no file-system
255
+ * dependencies. Intended for use with `BrowserMockLLM` and static hosting
256
+ * (e.g. GitHub Pages, CDN, or any HTTP server that can serve JSON files).
257
+ *
258
+ * Filtering and limiting are applied client-side after fetching the full
259
+ * collection, matching the behaviour of `MockCosmosAdapter`.
260
+ */
261
+ declare class HttpMockAdapter extends BaseAdapter {
262
+ private options;
263
+ constructor(options: HttpMockAdapterOptions);
264
+ query(params: QueryParams): Promise<any[]>;
265
+ getById(_id: string): Promise<any>;
266
+ private matchesFilters;
267
+ private getNestedValue;
268
+ }
269
+
270
+ interface QueryOptions {
271
+ debug?: boolean;
272
+ }
273
+ interface FallbackLLMConfig {
274
+ enabled: boolean;
275
+ endpoint: string;
276
+ apiKey: string;
277
+ model: string;
278
+ }
279
+ /**
280
+ * Isomorphic query engine — works in both Node.js and browser environments.
281
+ *
282
+ * Constructed with already-loaded keywords, stories, a data adapter, and an
283
+ * optional fallback-LLM config. Both `MockLLM` (server) and `BrowserMockLLM`
284
+ * (browser) delegate all query logic to this class.
285
+ */
286
+ declare class MockLLMEngine {
287
+ private keywords;
288
+ private stories;
289
+ private adapter;
290
+ private fallbackLLM?;
291
+ private nlpMatcher;
292
+ private keywordResolver;
293
+ private storyResolver;
294
+ private queryBuilder;
295
+ private responseBuilder;
296
+ constructor(keywords: KeywordEntry[], stories: Story[], adapter: BaseAdapter, fallbackLLM?: FallbackLLMConfig | undefined);
297
+ getKeywords(): KeywordEntry[];
298
+ getStories(): Story[];
299
+ listDataSources(): string[];
300
+ getDataSourceSnapshot(source: string, limit?: number): Promise<any[]>;
301
+ query(userQuery: string, opts?: QueryOptions): Promise<Answer>;
302
+ private queryFallbackLLM;
303
+ }
304
+
305
+ interface BrowserMockLLMOptions {
306
+ /** URL to a pre-aggregated JSON array of all keyword entries, e.g. '/data/keywords.json' */
307
+ keywordsUrl: string;
308
+ /** URL to a pre-aggregated JSON array of all story definitions, e.g. '/data/stories.json' */
309
+ storiesUrl: string;
310
+ /**
311
+ * Base URL for data-source JSON files. A query for `source: 'knowledge/science'`
312
+ * fetches `{dataBaseUrl}/knowledge/science.json`.
313
+ */
314
+ dataBaseUrl: string;
315
+ fallbackLLM?: FallbackLLMConfig;
316
+ }
317
+ /**
318
+ * Browser-safe orchestrator for the mock-LLM engine.
319
+ *
320
+ * Loads configuration and data via `fetch()` with no file-system dependencies.
321
+ * Import from `@nice-tools/mock-llm/browser` to keep bundlers from pulling in
322
+ * Node.js-only modules (`fs`, `path`, `@google-cloud/storage`, etc.).
323
+ *
324
+ * @example
325
+ * ```ts
326
+ * import { BrowserMockLLM } from '@nice-tools/mock-llm/browser';
327
+ *
328
+ * const llm = new BrowserMockLLM({
329
+ * keywordsUrl: '/data/keywords.json',
330
+ * storiesUrl: '/data/stories.json',
331
+ * dataBaseUrl: '/data',
332
+ * });
333
+ * await llm.initialize();
334
+ * const answer = await llm.query('what is the color of sky');
335
+ * ```
336
+ */
337
+ declare class BrowserMockLLM {
338
+ private options;
339
+ private engine;
340
+ constructor(options: BrowserMockLLMOptions);
341
+ initialize(): Promise<void>;
342
+ getKeywords(): KeywordEntry[];
343
+ getStories(): Story[];
344
+ listDataSources(): string[];
345
+ getDataSourceSnapshot(source: string, limit?: number): Promise<any[]>;
346
+ query(userQuery: string, opts?: QueryOptions): Promise<Answer>;
347
+ }
348
+
349
+ export { type AdapterConnections, type Answer, type AnswerDebug, type AnswerDebugStep, BaseAdapter, BrowserMockLLM, type BrowserMockLLMOptions, type ConfigSource, type FallbackLLMConfig, FetchConfigLoader, type FetchConfigLoaderOptions, HttpMockAdapter, type HttpMockAdapterOptions, type IDataAdapter, type Intent, type KeywordEntry, KeywordResolver, MockLLMEngine, NLPMatcher, QueryBuilder, type QueryOptions, type QueryParams, type Relation, type ResolutionStep, ResponseBuilder, STORY_THRESHOLD, type Story, type StoryContract, type StoryMatch, StoryResolver, type StoryScore };