@karmaniverous/jeeves-watcher 0.1.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.
- package/LICENSE +28 -0
- package/README.md +236 -0
- package/dist/cjs/index.js +1577 -0
- package/dist/cli/jeeves-watcher/index.js +1765 -0
- package/dist/index.d.ts +615 -0
- package/dist/index.iife.js +1562 -0
- package/dist/index.iife.min.js +1 -0
- package/dist/mjs/index.js +1537 -0
- package/package.json +169 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
import pino from 'pino';
|
|
3
|
+
import { Stats } from 'node:fs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Watch configuration for file system monitoring.
|
|
7
|
+
*/
|
|
8
|
+
interface WatchConfig {
|
|
9
|
+
/** Glob patterns to watch. */
|
|
10
|
+
paths: string[];
|
|
11
|
+
/** Glob patterns to ignore. */
|
|
12
|
+
ignored?: string[];
|
|
13
|
+
/** Polling interval in milliseconds. */
|
|
14
|
+
pollIntervalMs?: number;
|
|
15
|
+
/** Whether to use polling instead of native watchers. */
|
|
16
|
+
usePolling?: boolean;
|
|
17
|
+
/** Debounce delay in milliseconds for file change events. */
|
|
18
|
+
debounceMs?: number;
|
|
19
|
+
/** Time in milliseconds a file must be stable before processing. */
|
|
20
|
+
stabilityThresholdMs?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Configuration watch settings.
|
|
24
|
+
*/
|
|
25
|
+
interface ConfigWatchConfig {
|
|
26
|
+
/** Whether config file watching is enabled. */
|
|
27
|
+
enabled?: boolean;
|
|
28
|
+
/** Debounce delay in milliseconds for config change events. */
|
|
29
|
+
debounceMs?: number;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Embedding model configuration.
|
|
33
|
+
*/
|
|
34
|
+
interface EmbeddingConfig {
|
|
35
|
+
/** The embedding model provider. */
|
|
36
|
+
provider: string;
|
|
37
|
+
/** The embedding model name. */
|
|
38
|
+
model: string;
|
|
39
|
+
/** Maximum tokens per chunk for splitting. */
|
|
40
|
+
chunkSize?: number;
|
|
41
|
+
/** Overlap between chunks in tokens. */
|
|
42
|
+
chunkOverlap?: number;
|
|
43
|
+
/** Embedding vector dimensions. */
|
|
44
|
+
dimensions?: number;
|
|
45
|
+
/** API key for the embedding provider. */
|
|
46
|
+
apiKey?: string;
|
|
47
|
+
/** Maximum embedding requests per minute. */
|
|
48
|
+
rateLimitPerMinute?: number;
|
|
49
|
+
/** Maximum concurrent embedding requests. */
|
|
50
|
+
concurrency?: number;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Vector store configuration for Qdrant.
|
|
54
|
+
*/
|
|
55
|
+
interface VectorStoreConfig {
|
|
56
|
+
/** Qdrant server URL. */
|
|
57
|
+
url: string;
|
|
58
|
+
/** Qdrant collection name. */
|
|
59
|
+
collectionName: string;
|
|
60
|
+
/** Qdrant API key. */
|
|
61
|
+
apiKey?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* API server configuration.
|
|
65
|
+
*/
|
|
66
|
+
interface ApiConfig {
|
|
67
|
+
/** Host to bind to. */
|
|
68
|
+
host?: string;
|
|
69
|
+
/** Port to listen on. */
|
|
70
|
+
port?: number;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Logging configuration.
|
|
74
|
+
*/
|
|
75
|
+
interface LoggingConfig {
|
|
76
|
+
/** Log level. */
|
|
77
|
+
level?: string;
|
|
78
|
+
/** Log file path. */
|
|
79
|
+
file?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* An inference rule that enriches document metadata.
|
|
83
|
+
*/
|
|
84
|
+
interface InferenceRule {
|
|
85
|
+
/** JSON Schema object to match against document metadata. */
|
|
86
|
+
match: Record<string, unknown>;
|
|
87
|
+
/** Metadata fields to set when the rule matches. */
|
|
88
|
+
set: Record<string, unknown>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Top-level configuration for jeeves-watcher.
|
|
92
|
+
*/
|
|
93
|
+
interface JeevesWatcherConfig {
|
|
94
|
+
/** File system watch configuration. */
|
|
95
|
+
watch: WatchConfig;
|
|
96
|
+
/** Configuration file watch settings. */
|
|
97
|
+
configWatch?: ConfigWatchConfig;
|
|
98
|
+
/** Embedding model configuration. */
|
|
99
|
+
embedding: EmbeddingConfig;
|
|
100
|
+
/** Vector store configuration. */
|
|
101
|
+
vectorStore: VectorStoreConfig;
|
|
102
|
+
/** Directory for persisted metadata. */
|
|
103
|
+
metadataDir?: string;
|
|
104
|
+
/** API server configuration. */
|
|
105
|
+
api?: ApiConfig;
|
|
106
|
+
/** Extractor configurations keyed by name. */
|
|
107
|
+
extractors?: Record<string, unknown>;
|
|
108
|
+
/** Rules for inferring metadata from document properties. */
|
|
109
|
+
inferenceRules?: InferenceRule[];
|
|
110
|
+
/** Logging configuration. */
|
|
111
|
+
logging?: LoggingConfig;
|
|
112
|
+
/** Timeout in milliseconds for graceful shutdown. */
|
|
113
|
+
shutdownTimeoutMs?: number;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* An embedding provider that converts text into vector representations.
|
|
118
|
+
*/
|
|
119
|
+
interface EmbeddingProvider {
|
|
120
|
+
/** Generate embedding vectors for the given texts. */
|
|
121
|
+
embed(texts: string[]): Promise<number[][]>;
|
|
122
|
+
/** The dimensionality of the embedding vectors. */
|
|
123
|
+
dimensions: number;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Create an embedding provider based on the given configuration.
|
|
127
|
+
*
|
|
128
|
+
* @param config - The embedding configuration.
|
|
129
|
+
* @returns An {@link EmbeddingProvider} instance.
|
|
130
|
+
* @throws If the configured provider is not supported.
|
|
131
|
+
*/
|
|
132
|
+
declare function createEmbeddingProvider(config: EmbeddingConfig): EmbeddingProvider;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Attributes derived from a watched file for rule matching.
|
|
136
|
+
*/
|
|
137
|
+
interface FileAttributes {
|
|
138
|
+
/** File-level properties. */
|
|
139
|
+
file: {
|
|
140
|
+
/** Full file path (forward slashes). */
|
|
141
|
+
path: string;
|
|
142
|
+
/** Directory containing the file. */
|
|
143
|
+
directory: string;
|
|
144
|
+
/** File name with extension. */
|
|
145
|
+
filename: string;
|
|
146
|
+
/** File extension including the leading dot. */
|
|
147
|
+
extension: string;
|
|
148
|
+
/** File size in bytes. */
|
|
149
|
+
sizeBytes: number;
|
|
150
|
+
/** ISO-8601 last-modified timestamp. */
|
|
151
|
+
modified: string;
|
|
152
|
+
};
|
|
153
|
+
/** Extracted YAML frontmatter, if any. */
|
|
154
|
+
frontmatter?: Record<string, unknown>;
|
|
155
|
+
/** Parsed JSON content, if any. */
|
|
156
|
+
json?: Record<string, unknown>;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* A compiled inference rule ready for evaluation.
|
|
160
|
+
*/
|
|
161
|
+
interface CompiledRule {
|
|
162
|
+
/** The original rule definition. */
|
|
163
|
+
rule: InferenceRule;
|
|
164
|
+
/** The compiled ajv validate function. */
|
|
165
|
+
validate: (data: unknown) => boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Build {@link FileAttributes} from a file path and stat info.
|
|
169
|
+
*
|
|
170
|
+
* @param filePath - The file path.
|
|
171
|
+
* @param stats - The file stats.
|
|
172
|
+
* @param extractedFrontmatter - Optional extracted frontmatter.
|
|
173
|
+
* @param extractedJson - Optional parsed JSON content.
|
|
174
|
+
* @returns The constructed file attributes.
|
|
175
|
+
*/
|
|
176
|
+
declare function buildAttributes(filePath: string, stats: Stats, extractedFrontmatter?: Record<string, unknown>, extractedJson?: Record<string, unknown>): FileAttributes;
|
|
177
|
+
/**
|
|
178
|
+
* Compile an array of inference rules into executable validators.
|
|
179
|
+
*
|
|
180
|
+
* @param rules - The inference rule definitions.
|
|
181
|
+
* @returns An array of compiled rules.
|
|
182
|
+
*/
|
|
183
|
+
declare function compileRules(rules: InferenceRule[]): CompiledRule[];
|
|
184
|
+
/**
|
|
185
|
+
* Apply compiled inference rules to file attributes, returning merged metadata.
|
|
186
|
+
*
|
|
187
|
+
* Rules are evaluated in order; later rules override earlier ones.
|
|
188
|
+
*
|
|
189
|
+
* @param compiledRules - The compiled rules to evaluate.
|
|
190
|
+
* @param attributes - The file attributes to match against.
|
|
191
|
+
* @returns The merged metadata from all matching rules.
|
|
192
|
+
*/
|
|
193
|
+
declare function applyRules(compiledRules: CompiledRule[], attributes: FileAttributes): Record<string, unknown>;
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* A point to upsert into the vector store.
|
|
197
|
+
*/
|
|
198
|
+
interface VectorPoint {
|
|
199
|
+
/** The point ID. */
|
|
200
|
+
id: string;
|
|
201
|
+
/** The embedding vector. */
|
|
202
|
+
vector: number[];
|
|
203
|
+
/** The payload metadata. */
|
|
204
|
+
payload: Record<string, unknown>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* A search result from the vector store.
|
|
208
|
+
*/
|
|
209
|
+
interface SearchResult {
|
|
210
|
+
/** The point ID. */
|
|
211
|
+
id: string;
|
|
212
|
+
/** The similarity score. */
|
|
213
|
+
score: number;
|
|
214
|
+
/** The payload metadata. */
|
|
215
|
+
payload: Record<string, unknown>;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* A scrolled point from the vector store.
|
|
219
|
+
*/
|
|
220
|
+
interface ScrolledPoint {
|
|
221
|
+
/** The point ID. */
|
|
222
|
+
id: string;
|
|
223
|
+
/** The payload metadata. */
|
|
224
|
+
payload: Record<string, unknown>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Client wrapper for Qdrant vector store operations.
|
|
228
|
+
*/
|
|
229
|
+
declare class VectorStoreClient {
|
|
230
|
+
private readonly client;
|
|
231
|
+
private readonly collectionName;
|
|
232
|
+
private readonly dims;
|
|
233
|
+
/**
|
|
234
|
+
* Create a new VectorStoreClient.
|
|
235
|
+
*
|
|
236
|
+
* @param config - Vector store configuration.
|
|
237
|
+
* @param dimensions - The embedding vector dimensions.
|
|
238
|
+
*/
|
|
239
|
+
constructor(config: VectorStoreConfig, dimensions: number);
|
|
240
|
+
/**
|
|
241
|
+
* Ensure the collection exists with correct dimensions and Cosine distance.
|
|
242
|
+
*/
|
|
243
|
+
ensureCollection(): Promise<void>;
|
|
244
|
+
/**
|
|
245
|
+
* Upsert points into the collection.
|
|
246
|
+
*
|
|
247
|
+
* @param points - The points to upsert.
|
|
248
|
+
*/
|
|
249
|
+
upsert(points: VectorPoint[]): Promise<void>;
|
|
250
|
+
/**
|
|
251
|
+
* Delete points by their IDs.
|
|
252
|
+
*
|
|
253
|
+
* @param ids - The point IDs to delete.
|
|
254
|
+
*/
|
|
255
|
+
delete(ids: string[]): Promise<void>;
|
|
256
|
+
/**
|
|
257
|
+
* Set payload fields for the specified point IDs.
|
|
258
|
+
*
|
|
259
|
+
* This merges the given payload object into each point's existing payload.
|
|
260
|
+
*
|
|
261
|
+
* @param ids - Point IDs to update.
|
|
262
|
+
* @param payload - Payload fields to set.
|
|
263
|
+
*/
|
|
264
|
+
setPayload(ids: string[], payload: Record<string, unknown>): Promise<void>;
|
|
265
|
+
/**
|
|
266
|
+
* Get the payload of a point by ID.
|
|
267
|
+
*
|
|
268
|
+
* @param id - The point ID.
|
|
269
|
+
* @returns The payload, or `null` if the point doesn't exist.
|
|
270
|
+
*/
|
|
271
|
+
getPayload(id: string): Promise<Record<string, unknown> | null>;
|
|
272
|
+
/**
|
|
273
|
+
* Search for similar vectors.
|
|
274
|
+
*
|
|
275
|
+
* @param vector - The query vector.
|
|
276
|
+
* @param limit - Maximum results to return.
|
|
277
|
+
* @param filter - Optional Qdrant filter.
|
|
278
|
+
* @returns An array of search results.
|
|
279
|
+
*/
|
|
280
|
+
search(vector: number[], limit: number, filter?: Record<string, unknown>): Promise<SearchResult[]>;
|
|
281
|
+
/**
|
|
282
|
+
* Scroll through all points matching a filter.
|
|
283
|
+
*
|
|
284
|
+
* @param filter - Optional Qdrant filter.
|
|
285
|
+
* @param limit - Page size for scrolling.
|
|
286
|
+
* @yields Scrolled points.
|
|
287
|
+
*/
|
|
288
|
+
scroll(filter?: Record<string, unknown>, limit?: number): AsyncGenerator<ScrolledPoint>;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Core document processing pipeline.
|
|
293
|
+
*
|
|
294
|
+
* Handles extracting text, computing embeddings, and syncing with the vector store.
|
|
295
|
+
*/
|
|
296
|
+
declare class DocumentProcessor {
|
|
297
|
+
private readonly config;
|
|
298
|
+
private readonly embeddingProvider;
|
|
299
|
+
private readonly vectorStore;
|
|
300
|
+
private compiledRules;
|
|
301
|
+
private readonly logger;
|
|
302
|
+
private readonly metadataDir;
|
|
303
|
+
/**
|
|
304
|
+
* Create a new DocumentProcessor.
|
|
305
|
+
*
|
|
306
|
+
* @param config - The application configuration.
|
|
307
|
+
* @param embeddingProvider - The embedding provider.
|
|
308
|
+
* @param vectorStore - The vector store client.
|
|
309
|
+
* @param compiledRules - The compiled inference rules.
|
|
310
|
+
* @param logger - The logger instance.
|
|
311
|
+
*/
|
|
312
|
+
constructor(config: JeevesWatcherConfig, embeddingProvider: EmbeddingProvider, vectorStore: VectorStoreClient, compiledRules: CompiledRule[], logger: pino.Logger);
|
|
313
|
+
/**
|
|
314
|
+
* Process a file through the full pipeline: extract, hash, chunk, embed, upsert.
|
|
315
|
+
*
|
|
316
|
+
* @param filePath - The file to process.
|
|
317
|
+
*/
|
|
318
|
+
processFile(filePath: string): Promise<void>;
|
|
319
|
+
/**
|
|
320
|
+
* Delete all chunks for a file from the vector store and remove metadata.
|
|
321
|
+
*
|
|
322
|
+
* @param filePath - The file to delete.
|
|
323
|
+
*/
|
|
324
|
+
deleteFile(filePath: string): Promise<void>;
|
|
325
|
+
/**
|
|
326
|
+
* Process a metadata update: merge metadata, write to disk, update Qdrant payloads (no re-embed).
|
|
327
|
+
*
|
|
328
|
+
* @param filePath - The file whose metadata to update.
|
|
329
|
+
* @param metadata - The new metadata to merge.
|
|
330
|
+
* @returns The merged payload, or `null` if the file is not indexed.
|
|
331
|
+
*/
|
|
332
|
+
processMetadataUpdate(filePath: string, metadata: Record<string, unknown>): Promise<Record<string, unknown> | null>;
|
|
333
|
+
/**
|
|
334
|
+
* Re-apply inference rules to a file without re-embedding.
|
|
335
|
+
* Reads file attributes, applies current rules, merges with enrichment metadata,
|
|
336
|
+
* and updates Qdrant payloads.
|
|
337
|
+
*
|
|
338
|
+
* @param filePath - The file to update.
|
|
339
|
+
* @returns The merged metadata, or `null` if the file is not indexed.
|
|
340
|
+
*/
|
|
341
|
+
processRulesUpdate(filePath: string): Promise<Record<string, unknown> | null>;
|
|
342
|
+
/**
|
|
343
|
+
* Update compiled inference rules for subsequent file processing.
|
|
344
|
+
*
|
|
345
|
+
* @param compiledRules - The newly compiled rules.
|
|
346
|
+
*/
|
|
347
|
+
updateRules(compiledRules: CompiledRule[]): void;
|
|
348
|
+
/**
|
|
349
|
+
* Create the appropriate text splitter for the given file extension.
|
|
350
|
+
*
|
|
351
|
+
* @param ext - File extension.
|
|
352
|
+
* @param chunkSize - Maximum chunk size in characters.
|
|
353
|
+
* @param chunkOverlap - Overlap between chunks in characters.
|
|
354
|
+
* @returns A text splitter instance.
|
|
355
|
+
*/
|
|
356
|
+
private createSplitter;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* A watch event.
|
|
361
|
+
*/
|
|
362
|
+
type WatchEvent = {
|
|
363
|
+
/** Event type. */
|
|
364
|
+
type: 'create' | 'modify' | 'delete';
|
|
365
|
+
/** File path associated with the event. */
|
|
366
|
+
path: string;
|
|
367
|
+
/** Event priority. */
|
|
368
|
+
priority: 'normal' | 'low';
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* Function invoked when a queued event is processed.
|
|
372
|
+
*/
|
|
373
|
+
type ProcessFn = (event: WatchEvent) => Promise<void> | void;
|
|
374
|
+
/**
|
|
375
|
+
* Options for {@link EventQueue}.
|
|
376
|
+
*/
|
|
377
|
+
interface EventQueueOptions {
|
|
378
|
+
/** Debounce delay in milliseconds (applied per path+priority key). */
|
|
379
|
+
debounceMs: number;
|
|
380
|
+
/** Maximum number of concurrent processors. */
|
|
381
|
+
concurrency: number;
|
|
382
|
+
/** Optional max processed events per minute (token bucket). */
|
|
383
|
+
rateLimitPerMinute?: number;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* A debounced, rate-limited, concurrent event queue.
|
|
387
|
+
*/
|
|
388
|
+
declare class EventQueue {
|
|
389
|
+
private readonly debounceMs;
|
|
390
|
+
private readonly concurrency;
|
|
391
|
+
private readonly rateLimitPerMinute?;
|
|
392
|
+
private started;
|
|
393
|
+
private active;
|
|
394
|
+
private readonly debounceTimers;
|
|
395
|
+
private readonly latestByKey;
|
|
396
|
+
private readonly normalQueue;
|
|
397
|
+
private readonly lowQueue;
|
|
398
|
+
private tokens;
|
|
399
|
+
private lastRefillMs;
|
|
400
|
+
private drainWaiters;
|
|
401
|
+
/**
|
|
402
|
+
* Create an event queue.
|
|
403
|
+
*
|
|
404
|
+
* @param options - Queue options.
|
|
405
|
+
*/
|
|
406
|
+
constructor(options: EventQueueOptions);
|
|
407
|
+
/**
|
|
408
|
+
* Enqueue an event, debounced per path+priority.
|
|
409
|
+
*
|
|
410
|
+
* @param event - The watch event.
|
|
411
|
+
* @param fn - The processing function to invoke when dequeued.
|
|
412
|
+
*/
|
|
413
|
+
enqueue(event: WatchEvent, fn: ProcessFn): void;
|
|
414
|
+
/**
|
|
415
|
+
* Start processing events.
|
|
416
|
+
*/
|
|
417
|
+
process(): void;
|
|
418
|
+
/**
|
|
419
|
+
* Wait for the queue to become idle (no pending debounces, no queued items, no active work).
|
|
420
|
+
*
|
|
421
|
+
* @returns A promise that resolves when the queue is drained.
|
|
422
|
+
*/
|
|
423
|
+
drain(): Promise<void>;
|
|
424
|
+
private push;
|
|
425
|
+
private refillTokens;
|
|
426
|
+
private takeToken;
|
|
427
|
+
private nextItem;
|
|
428
|
+
private pump;
|
|
429
|
+
private isIdle;
|
|
430
|
+
private maybeResolveDrain;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Options for {@link createApiServer}.
|
|
435
|
+
*/
|
|
436
|
+
interface ApiServerOptions {
|
|
437
|
+
/** The document processor. */
|
|
438
|
+
processor: DocumentProcessor;
|
|
439
|
+
/** The vector store client. */
|
|
440
|
+
vectorStore: VectorStoreClient;
|
|
441
|
+
/** The embedding provider. */
|
|
442
|
+
embeddingProvider: EmbeddingProvider;
|
|
443
|
+
/** The event queue. */
|
|
444
|
+
queue: EventQueue;
|
|
445
|
+
/** The application configuration. */
|
|
446
|
+
config: JeevesWatcherConfig;
|
|
447
|
+
/** The logger instance. */
|
|
448
|
+
logger: pino.Logger;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Create the Fastify API server with all routes registered.
|
|
452
|
+
*
|
|
453
|
+
* The returned instance is not yet listening — call `server.listen()` to start.
|
|
454
|
+
*
|
|
455
|
+
* @param options - The server options.
|
|
456
|
+
* @returns A configured Fastify instance.
|
|
457
|
+
*/
|
|
458
|
+
declare function createApiServer(options: ApiServerOptions): FastifyInstance;
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* Main application class that wires together all components.
|
|
462
|
+
*/
|
|
463
|
+
declare class JeevesWatcher {
|
|
464
|
+
private config;
|
|
465
|
+
private readonly configPath?;
|
|
466
|
+
private logger;
|
|
467
|
+
private watcher;
|
|
468
|
+
private queue;
|
|
469
|
+
private server;
|
|
470
|
+
private processor;
|
|
471
|
+
private configWatcher;
|
|
472
|
+
private configDebounce;
|
|
473
|
+
/**
|
|
474
|
+
* Create a new JeevesWatcher instance.
|
|
475
|
+
*
|
|
476
|
+
* @param config - The application configuration.
|
|
477
|
+
* @param configPath - Optional config file path to watch for changes.
|
|
478
|
+
*/
|
|
479
|
+
constructor(config: JeevesWatcherConfig, configPath?: string);
|
|
480
|
+
/**
|
|
481
|
+
* Start the watcher, API server, and all components.
|
|
482
|
+
*/
|
|
483
|
+
start(): Promise<void>;
|
|
484
|
+
/**
|
|
485
|
+
* Gracefully stop all components.
|
|
486
|
+
*/
|
|
487
|
+
stop(): Promise<void>;
|
|
488
|
+
private startConfigWatch;
|
|
489
|
+
private stopConfigWatch;
|
|
490
|
+
private reloadConfig;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Create and start a JeevesWatcher from a config file path.
|
|
494
|
+
*
|
|
495
|
+
* @param configPath - Optional path to the configuration file.
|
|
496
|
+
* @returns The running JeevesWatcher instance.
|
|
497
|
+
*/
|
|
498
|
+
declare function startFromConfig(configPath?: string): Promise<JeevesWatcher>;
|
|
499
|
+
|
|
500
|
+
/**
|
|
501
|
+
* Load the jeeves-watcher configuration.
|
|
502
|
+
*
|
|
503
|
+
* @param configPath - Optional explicit path to a config file.
|
|
504
|
+
* @returns The loaded configuration.
|
|
505
|
+
* @throws If no configuration is found or validation fails.
|
|
506
|
+
*/
|
|
507
|
+
declare function loadConfig(configPath?: string): Promise<JeevesWatcherConfig>;
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Result of extracting text and structured data from a file.
|
|
511
|
+
*/
|
|
512
|
+
interface ExtractedText {
|
|
513
|
+
/** Extracted plain text content. */
|
|
514
|
+
text: string;
|
|
515
|
+
/** Extracted YAML frontmatter (Markdown). */
|
|
516
|
+
frontmatter?: Record<string, unknown>;
|
|
517
|
+
/** Parsed JSON object (JSON files). */
|
|
518
|
+
json?: Record<string, unknown>;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Extract text from a file based on extension.
|
|
522
|
+
*
|
|
523
|
+
* @param filePath - Path to the file.
|
|
524
|
+
* @param extension - File extension (including leading dot).
|
|
525
|
+
* @returns Extracted text and optional structured data.
|
|
526
|
+
*/
|
|
527
|
+
declare function extractText(filePath: string, extension: string): Promise<ExtractedText>;
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Compute a SHA-256 hex digest of the given text.
|
|
531
|
+
*
|
|
532
|
+
* @param text - The input text to hash.
|
|
533
|
+
* @returns The hex-encoded SHA-256 hash.
|
|
534
|
+
*/
|
|
535
|
+
declare function contentHash(text: string): string;
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Create a pino logger instance.
|
|
539
|
+
*
|
|
540
|
+
* @param config - Optional logging configuration.
|
|
541
|
+
* @returns A configured pino logger.
|
|
542
|
+
*/
|
|
543
|
+
declare function createLogger(config?: LoggingConfig): pino.Logger;
|
|
544
|
+
|
|
545
|
+
/**
|
|
546
|
+
* Derive a deterministic `.meta.json` path for a given file.
|
|
547
|
+
*
|
|
548
|
+
* @param filePath - The watched file path.
|
|
549
|
+
* @param metadataDir - The root metadata directory.
|
|
550
|
+
* @returns The full path to the metadata file.
|
|
551
|
+
*/
|
|
552
|
+
declare function metadataPath(filePath: string, metadataDir: string): string;
|
|
553
|
+
/**
|
|
554
|
+
* Read persisted metadata for a file.
|
|
555
|
+
*
|
|
556
|
+
* @param filePath - The watched file path.
|
|
557
|
+
* @param metadataDir - The root metadata directory.
|
|
558
|
+
* @returns The parsed metadata object, or `null` if not found.
|
|
559
|
+
*/
|
|
560
|
+
declare function readMetadata(filePath: string, metadataDir: string): Promise<Record<string, unknown> | null>;
|
|
561
|
+
/**
|
|
562
|
+
* Write metadata for a file.
|
|
563
|
+
*
|
|
564
|
+
* @param filePath - The watched file path.
|
|
565
|
+
* @param metadataDir - The root metadata directory.
|
|
566
|
+
* @param metadata - The metadata to persist.
|
|
567
|
+
*/
|
|
568
|
+
declare function writeMetadata(filePath: string, metadataDir: string, metadata: Record<string, unknown>): Promise<void>;
|
|
569
|
+
/**
|
|
570
|
+
* Delete metadata for a file.
|
|
571
|
+
*
|
|
572
|
+
* @param filePath - The watched file path.
|
|
573
|
+
* @param metadataDir - The root metadata directory.
|
|
574
|
+
*/
|
|
575
|
+
declare function deleteMetadata(filePath: string, metadataDir: string): Promise<void>;
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* Generate a deterministic UUID v5 point ID for a file (and optional chunk index).
|
|
579
|
+
*
|
|
580
|
+
* @param filePath - The file path.
|
|
581
|
+
* @param chunkIndex - Optional chunk index within the file.
|
|
582
|
+
* @returns A deterministic UUID v5 string.
|
|
583
|
+
*/
|
|
584
|
+
declare function pointId(filePath: string, chunkIndex?: number): string;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Filesystem watcher that maps chokidar events to the processing queue.
|
|
588
|
+
*/
|
|
589
|
+
declare class FileSystemWatcher {
|
|
590
|
+
private readonly config;
|
|
591
|
+
private readonly queue;
|
|
592
|
+
private readonly processor;
|
|
593
|
+
private readonly logger;
|
|
594
|
+
private watcher;
|
|
595
|
+
/**
|
|
596
|
+
* Create a new FileSystemWatcher.
|
|
597
|
+
*
|
|
598
|
+
* @param config - Watch configuration.
|
|
599
|
+
* @param queue - The event queue.
|
|
600
|
+
* @param processor - The document processor.
|
|
601
|
+
* @param logger - The logger instance.
|
|
602
|
+
*/
|
|
603
|
+
constructor(config: WatchConfig, queue: EventQueue, processor: DocumentProcessor, logger: pino.Logger);
|
|
604
|
+
/**
|
|
605
|
+
* Start watching the filesystem and processing events.
|
|
606
|
+
*/
|
|
607
|
+
start(): void;
|
|
608
|
+
/**
|
|
609
|
+
* Stop the filesystem watcher.
|
|
610
|
+
*/
|
|
611
|
+
stop(): Promise<void>;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
export { DocumentProcessor, EventQueue, FileSystemWatcher, JeevesWatcher, VectorStoreClient, applyRules, buildAttributes, compileRules, contentHash, createApiServer, createEmbeddingProvider, createLogger, deleteMetadata, extractText, loadConfig, metadataPath, pointId, readMetadata, startFromConfig, writeMetadata };
|
|
615
|
+
export type { ApiConfig, ApiServerOptions, CompiledRule, ConfigWatchConfig, EmbeddingConfig, EmbeddingProvider, EventQueueOptions, ExtractedText, FileAttributes, InferenceRule, JeevesWatcherConfig, LoggingConfig, ProcessFn, ScrolledPoint, SearchResult, VectorPoint, VectorStoreConfig, WatchConfig, WatchEvent };
|