@karmaniverous/jeeves-watcher 0.2.3 → 0.2.5
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/README.md +15 -0
- package/config.schema.json +117 -81
- package/dist/cjs/index.js +422 -10
- package/dist/cli/jeeves-watcher/index.js +421 -11
- package/dist/index.d.ts +150 -5
- package/dist/index.iife.js +422 -12
- package/dist/index.iife.min.js +1 -1
- package/dist/mjs/index.js +422 -12
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const watchConfigSchema: z.ZodObject<{
|
|
|
15
15
|
usePolling: z.ZodOptional<z.ZodBoolean>;
|
|
16
16
|
debounceMs: z.ZodOptional<z.ZodNumber>;
|
|
17
17
|
stabilityThresholdMs: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
respectGitignore: z.ZodOptional<z.ZodBoolean>;
|
|
18
19
|
}, z.core.$strip>;
|
|
19
20
|
/** Watch configuration for file system monitoring paths, ignore patterns, and debounce/stability settings. */
|
|
20
21
|
type WatchConfig = z.infer<typeof watchConfigSchema>;
|
|
@@ -91,6 +92,7 @@ declare const jeevesWatcherConfigSchema: z.ZodObject<{
|
|
|
91
92
|
usePolling: z.ZodOptional<z.ZodBoolean>;
|
|
92
93
|
debounceMs: z.ZodOptional<z.ZodNumber>;
|
|
93
94
|
stabilityThresholdMs: z.ZodOptional<z.ZodNumber>;
|
|
95
|
+
respectGitignore: z.ZodOptional<z.ZodBoolean>;
|
|
94
96
|
}, z.core.$strip>;
|
|
95
97
|
configWatch: z.ZodOptional<z.ZodObject<{
|
|
96
98
|
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -128,6 +130,8 @@ declare const jeevesWatcherConfigSchema: z.ZodObject<{
|
|
|
128
130
|
file: z.ZodOptional<z.ZodString>;
|
|
129
131
|
}, z.core.$strip>>;
|
|
130
132
|
shutdownTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
maxRetries: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
maxBackoffMs: z.ZodOptional<z.ZodNumber>;
|
|
131
135
|
}, z.core.$strip>;
|
|
132
136
|
/** Top-level jeeves-watcher configuration: watch paths, embedding, vector store, rules, maps, API, and logging. */
|
|
133
137
|
type JeevesWatcherConfig = z.infer<typeof jeevesWatcherConfigSchema>;
|
|
@@ -541,6 +545,114 @@ declare function createApiServer(options: ApiServerOptions): FastifyInstance;
|
|
|
541
545
|
*/
|
|
542
546
|
declare function createLogger(config?: LoggingConfig): pino.Logger;
|
|
543
547
|
|
|
548
|
+
/**
|
|
549
|
+
* @module gitignore
|
|
550
|
+
* Processor-level gitignore filtering. Scans watched paths for `.gitignore` files in git repos, caches parsed patterns, and exposes `isIgnored()` for path checking.
|
|
551
|
+
*/
|
|
552
|
+
/**
|
|
553
|
+
* Processor-level gitignore filter. Checks file paths against the nearest
|
|
554
|
+
* `.gitignore` chain in git repositories.
|
|
555
|
+
*/
|
|
556
|
+
declare class GitignoreFilter {
|
|
557
|
+
private repos;
|
|
558
|
+
/**
|
|
559
|
+
* Create a GitignoreFilter by scanning watched paths for `.gitignore` files.
|
|
560
|
+
*
|
|
561
|
+
* @param watchPaths - Absolute paths being watched (directories or globs resolved to roots).
|
|
562
|
+
*/
|
|
563
|
+
constructor(watchPaths: string[]);
|
|
564
|
+
/**
|
|
565
|
+
* Scan paths for git repos and their `.gitignore` files.
|
|
566
|
+
*/
|
|
567
|
+
private scan;
|
|
568
|
+
/**
|
|
569
|
+
* Check whether a file path is ignored by any applicable `.gitignore`.
|
|
570
|
+
*
|
|
571
|
+
* @param filePath - Absolute file path to check.
|
|
572
|
+
* @returns `true` if the file should be ignored.
|
|
573
|
+
*/
|
|
574
|
+
isIgnored(filePath: string): boolean;
|
|
575
|
+
/**
|
|
576
|
+
* Invalidate and re-parse a specific `.gitignore` file.
|
|
577
|
+
* Call when a `.gitignore` file is added, changed, or removed.
|
|
578
|
+
*
|
|
579
|
+
* @param gitignorePath - Absolute path to the `.gitignore` file that changed.
|
|
580
|
+
*/
|
|
581
|
+
invalidate(gitignorePath: string): void;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* @module health
|
|
586
|
+
* Tracks consecutive system-level failures and applies exponential backoff.
|
|
587
|
+
* Triggers fatal error callback when maxRetries is exceeded.
|
|
588
|
+
*/
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Options for {@link SystemHealth}.
|
|
592
|
+
*/
|
|
593
|
+
interface SystemHealthOptions {
|
|
594
|
+
/** Maximum consecutive failures before fatal. Default: Infinity. */
|
|
595
|
+
maxRetries?: number;
|
|
596
|
+
/** Maximum backoff delay in milliseconds. Default: 60000. */
|
|
597
|
+
maxBackoffMs?: number;
|
|
598
|
+
/** Base delay in milliseconds for exponential backoff. Default: 1000. */
|
|
599
|
+
baseDelayMs?: number;
|
|
600
|
+
/** Called when maxRetries is exceeded. If not set, throws. */
|
|
601
|
+
onFatalError?: (error: unknown) => void;
|
|
602
|
+
/** Logger instance. */
|
|
603
|
+
logger: pino.Logger;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Tracks system health via consecutive failure count and exponential backoff.
|
|
607
|
+
*/
|
|
608
|
+
declare class SystemHealth {
|
|
609
|
+
private consecutiveFailures;
|
|
610
|
+
private readonly maxRetries;
|
|
611
|
+
private readonly maxBackoffMs;
|
|
612
|
+
private readonly baseDelayMs;
|
|
613
|
+
private readonly onFatalError?;
|
|
614
|
+
private readonly logger;
|
|
615
|
+
constructor(options: SystemHealthOptions);
|
|
616
|
+
/**
|
|
617
|
+
* Record a successful system operation. Resets the failure counter.
|
|
618
|
+
*/
|
|
619
|
+
recordSuccess(): void;
|
|
620
|
+
/**
|
|
621
|
+
* Record a system-level failure. If maxRetries is exceeded, triggers fatal error.
|
|
622
|
+
*
|
|
623
|
+
* @param error - The error that occurred.
|
|
624
|
+
* @returns Whether the watcher should continue (false = fatal).
|
|
625
|
+
*/
|
|
626
|
+
recordFailure(error: unknown): boolean;
|
|
627
|
+
/**
|
|
628
|
+
* Compute the current backoff delay based on consecutive failures.
|
|
629
|
+
*
|
|
630
|
+
* @returns Delay in milliseconds.
|
|
631
|
+
*/
|
|
632
|
+
get currentBackoffMs(): number;
|
|
633
|
+
/**
|
|
634
|
+
* Sleep for the current backoff duration.
|
|
635
|
+
*
|
|
636
|
+
* @param signal - Optional abort signal.
|
|
637
|
+
*/
|
|
638
|
+
backoff(signal?: AbortSignal): Promise<void>;
|
|
639
|
+
/** Current consecutive failure count. */
|
|
640
|
+
get failures(): number;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Options for {@link FileSystemWatcher} beyond basic config.
|
|
645
|
+
*/
|
|
646
|
+
interface FileSystemWatcherOptions {
|
|
647
|
+
/** Maximum consecutive system-level failures before fatal error. */
|
|
648
|
+
maxRetries?: number;
|
|
649
|
+
/** Maximum backoff delay in milliseconds for system errors. */
|
|
650
|
+
maxBackoffMs?: number;
|
|
651
|
+
/** Callback invoked on unrecoverable system error. If not set, throws. */
|
|
652
|
+
onFatalError?: (error: unknown) => void;
|
|
653
|
+
/** Optional gitignore filter for processor-level filtering. */
|
|
654
|
+
gitignoreFilter?: GitignoreFilter;
|
|
655
|
+
}
|
|
544
656
|
/**
|
|
545
657
|
* Filesystem watcher that maps chokidar events to the processing queue.
|
|
546
658
|
*/
|
|
@@ -549,6 +661,8 @@ declare class FileSystemWatcher {
|
|
|
549
661
|
private readonly queue;
|
|
550
662
|
private readonly processor;
|
|
551
663
|
private readonly logger;
|
|
664
|
+
private readonly health;
|
|
665
|
+
private readonly gitignoreFilter?;
|
|
552
666
|
private watcher;
|
|
553
667
|
/**
|
|
554
668
|
* Create a new FileSystemWatcher.
|
|
@@ -557,8 +671,9 @@ declare class FileSystemWatcher {
|
|
|
557
671
|
* @param queue - The event queue.
|
|
558
672
|
* @param processor - The document processor.
|
|
559
673
|
* @param logger - The logger instance.
|
|
674
|
+
* @param options - Optional health/fatal error options.
|
|
560
675
|
*/
|
|
561
|
-
constructor(config: WatchConfig, queue: EventQueue, processor: DocumentProcessor, logger: pino.Logger);
|
|
676
|
+
constructor(config: WatchConfig, queue: EventQueue, processor: DocumentProcessor, logger: pino.Logger, options?: FileSystemWatcherOptions);
|
|
562
677
|
/**
|
|
563
678
|
* Start watching the filesystem and processing events.
|
|
564
679
|
*/
|
|
@@ -567,6 +682,24 @@ declare class FileSystemWatcher {
|
|
|
567
682
|
* Stop the filesystem watcher.
|
|
568
683
|
*/
|
|
569
684
|
stop(): Promise<void>;
|
|
685
|
+
/**
|
|
686
|
+
* Get the system health tracker.
|
|
687
|
+
*/
|
|
688
|
+
get systemHealth(): SystemHealth;
|
|
689
|
+
/**
|
|
690
|
+
* Check if a path is gitignored and should be skipped.
|
|
691
|
+
*/
|
|
692
|
+
private isGitignored;
|
|
693
|
+
/**
|
|
694
|
+
* If the changed file is a `.gitignore`, invalidate the filter cache.
|
|
695
|
+
*/
|
|
696
|
+
private handleGitignoreChange;
|
|
697
|
+
/**
|
|
698
|
+
* Wrap a processing operation with health tracking.
|
|
699
|
+
* On success, resets the failure counter.
|
|
700
|
+
* On failure, records the failure and applies backoff.
|
|
701
|
+
*/
|
|
702
|
+
private wrapProcessing;
|
|
570
703
|
}
|
|
571
704
|
|
|
572
705
|
/**
|
|
@@ -588,10 +721,20 @@ interface JeevesWatcherFactories {
|
|
|
588
721
|
/** Create an event queue for batching file-system events. */
|
|
589
722
|
createEventQueue: (options: ConstructorParameters<typeof EventQueue>[0]) => EventQueue;
|
|
590
723
|
/** Create a file-system watcher for the configured watch paths. */
|
|
591
|
-
createFileSystemWatcher: (config: JeevesWatcherConfig['watch'], queue: EventQueue, processor: DocumentProcessor, logger: pino.Logger) => FileSystemWatcher;
|
|
724
|
+
createFileSystemWatcher: (config: JeevesWatcherConfig['watch'], queue: EventQueue, processor: DocumentProcessor, logger: pino.Logger, options?: FileSystemWatcherOptions) => FileSystemWatcher;
|
|
592
725
|
/** Create the HTTP API server. */
|
|
593
726
|
createApiServer: typeof createApiServer;
|
|
594
727
|
}
|
|
728
|
+
/**
|
|
729
|
+
* Main application class that wires together all components.
|
|
730
|
+
*/
|
|
731
|
+
/**
|
|
732
|
+
* Runtime options for {@link JeevesWatcher} that aren't serializable in config.
|
|
733
|
+
*/
|
|
734
|
+
interface JeevesWatcherRuntimeOptions {
|
|
735
|
+
/** Callback invoked on unrecoverable system error. If not set, throws. */
|
|
736
|
+
onFatalError?: (error: unknown) => void;
|
|
737
|
+
}
|
|
595
738
|
/**
|
|
596
739
|
* Main application class that wires together all components.
|
|
597
740
|
*/
|
|
@@ -599,6 +742,7 @@ declare class JeevesWatcher {
|
|
|
599
742
|
private config;
|
|
600
743
|
private readonly configPath?;
|
|
601
744
|
private readonly factories;
|
|
745
|
+
private readonly runtimeOptions;
|
|
602
746
|
private logger;
|
|
603
747
|
private watcher;
|
|
604
748
|
private queue;
|
|
@@ -611,8 +755,9 @@ declare class JeevesWatcher {
|
|
|
611
755
|
* @param config - The application configuration.
|
|
612
756
|
* @param configPath - Optional config file path to watch for changes.
|
|
613
757
|
* @param factories - Optional component factories (for dependency injection).
|
|
758
|
+
* @param runtimeOptions - Optional runtime-only options (e.g., onFatalError).
|
|
614
759
|
*/
|
|
615
|
-
constructor(config: JeevesWatcherConfig, configPath?: string, factories?: Partial<JeevesWatcherFactories
|
|
760
|
+
constructor(config: JeevesWatcherConfig, configPath?: string, factories?: Partial<JeevesWatcherFactories>, runtimeOptions?: JeevesWatcherRuntimeOptions);
|
|
616
761
|
/**
|
|
617
762
|
* Start the watcher, API server, and all components.
|
|
618
763
|
*/
|
|
@@ -716,5 +861,5 @@ declare function deleteMetadata(filePath: string, metadataDir: string): Promise<
|
|
|
716
861
|
*/
|
|
717
862
|
declare function pointId(filePath: string, chunkIndex?: number): string;
|
|
718
863
|
|
|
719
|
-
export { DocumentProcessor, EventQueue, FileSystemWatcher, JeevesWatcher, VectorStoreClient, apiConfigSchema, applyRules, buildAttributes, compileRules, configWatchConfigSchema, contentHash, createApiServer, createEmbeddingProvider, createLogger, deleteMetadata, embeddingConfigSchema, extractText, inferenceRuleSchema, jeevesWatcherConfigSchema, loadConfig, loggingConfigSchema, metadataPath, pointId, readMetadata, startFromConfig, vectorStoreConfigSchema, watchConfigSchema, writeMetadata };
|
|
720
|
-
export type { ApiConfig, ApiServerOptions, CompiledRule, ConfigWatchConfig, EmbeddingConfig, EmbeddingProvider, EventQueueOptions, ExtractedText, FileAttributes, InferenceRule, JeevesWatcherConfig, JeevesWatcherFactories, LoggingConfig, ProcessFn, ProcessorConfig, RuleLogger, ScrolledPoint, SearchResult, VectorPoint, VectorStoreConfig, WatchConfig, WatchEvent };
|
|
864
|
+
export { DocumentProcessor, EventQueue, FileSystemWatcher, GitignoreFilter, JeevesWatcher, SystemHealth, VectorStoreClient, apiConfigSchema, applyRules, buildAttributes, compileRules, configWatchConfigSchema, contentHash, createApiServer, createEmbeddingProvider, createLogger, deleteMetadata, embeddingConfigSchema, extractText, inferenceRuleSchema, jeevesWatcherConfigSchema, loadConfig, loggingConfigSchema, metadataPath, pointId, readMetadata, startFromConfig, vectorStoreConfigSchema, watchConfigSchema, writeMetadata };
|
|
865
|
+
export type { ApiConfig, ApiServerOptions, CompiledRule, ConfigWatchConfig, EmbeddingConfig, EmbeddingProvider, EventQueueOptions, ExtractedText, FileAttributes, FileSystemWatcherOptions, InferenceRule, JeevesWatcherConfig, JeevesWatcherFactories, JeevesWatcherRuntimeOptions, LoggingConfig, ProcessFn, ProcessorConfig, RuleLogger, ScrolledPoint, SearchResult, SystemHealthOptions, VectorPoint, VectorStoreConfig, WatchConfig, WatchEvent };
|