@karmaniverous/jeeves-watcher 0.15.1 → 0.16.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/dist/cli/jeeves-watcher/index.js +764 -8167
- package/dist/index.d.ts +101 -8
- package/dist/index.js +616 -76
- package/package.json +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import * as _karmaniverous_jsonmap from '@karmaniverous/jsonmap';
|
|
|
4
4
|
import { JsonMapMap } from '@karmaniverous/jsonmap';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import Handlebars from 'handlebars';
|
|
7
|
+
import { JeevesComponentDescriptor } from '@karmaniverous/jeeves';
|
|
7
8
|
import { Stats } from 'node:fs';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -300,6 +301,7 @@ declare function createEmbeddingProvider(config: EmbeddingConfig, logger?: pino.
|
|
|
300
301
|
* @module enrichment/EnrichmentStore
|
|
301
302
|
* SQLite-backed enrichment metadata store. Persists path-keyed metadata at stateDir/enrichments.sqlite. Atomic writes, supports move.
|
|
302
303
|
*/
|
|
304
|
+
|
|
303
305
|
/**
|
|
304
306
|
* Interface for enrichment metadata persistence.
|
|
305
307
|
*/
|
|
@@ -322,12 +324,13 @@ interface EnrichmentStoreInterface {
|
|
|
322
324
|
*/
|
|
323
325
|
declare class EnrichmentStore implements EnrichmentStoreInterface {
|
|
324
326
|
private readonly db;
|
|
327
|
+
private readonly logger?;
|
|
325
328
|
/**
|
|
326
329
|
* Create or open the enrichment store.
|
|
327
330
|
*
|
|
328
331
|
* @param stateDir - Directory for the SQLite database file.
|
|
329
332
|
*/
|
|
330
|
-
constructor(stateDir: string);
|
|
333
|
+
constructor(stateDir: string, logger?: pino.Logger);
|
|
331
334
|
get(path: string): Record<string, unknown> | null;
|
|
332
335
|
set(path: string, metadata: Record<string, unknown>): void;
|
|
333
336
|
delete(path: string): void;
|
|
@@ -806,6 +809,57 @@ declare class VirtualRuleStore {
|
|
|
806
809
|
get size(): number;
|
|
807
810
|
}
|
|
808
811
|
|
|
812
|
+
/**
|
|
813
|
+
* @module util/BinaryFileStore
|
|
814
|
+
* Binary-backed read/modify/write store with in-memory caching and debounced flush.
|
|
815
|
+
*
|
|
816
|
+
* Persists a single JS object to disk using V8 structured clone serialization.
|
|
817
|
+
* I/O: synchronous fs read/write.
|
|
818
|
+
*/
|
|
819
|
+
|
|
820
|
+
/** Options for {@link BinaryFileStore}. */
|
|
821
|
+
interface BinaryFileStoreOptions {
|
|
822
|
+
/** Path to the binary file on disk. */
|
|
823
|
+
filePath: string;
|
|
824
|
+
/** Logger for warnings. */
|
|
825
|
+
logger: pino.Logger;
|
|
826
|
+
/** Debounce interval in ms for flushing dirty state. Default: 5000. */
|
|
827
|
+
flushDebounceMs?: number;
|
|
828
|
+
}
|
|
829
|
+
/**
|
|
830
|
+
* Base class for binary file stores.
|
|
831
|
+
*
|
|
832
|
+
* @typeParam T - The stored data structure.
|
|
833
|
+
*/
|
|
834
|
+
declare abstract class BinaryFileStore<T> {
|
|
835
|
+
/** Path to the binary file on disk. */
|
|
836
|
+
protected readonly filePath: string;
|
|
837
|
+
/** In-memory cache of the file contents, or `null` if not yet loaded. */
|
|
838
|
+
protected cache: T | null;
|
|
839
|
+
/** Logger instance for warnings and diagnostics. */
|
|
840
|
+
protected readonly logger: pino.Logger;
|
|
841
|
+
private readonly flushDebounceMs;
|
|
842
|
+
private flushTimer;
|
|
843
|
+
private dirty;
|
|
844
|
+
protected constructor(options: BinaryFileStoreOptions);
|
|
845
|
+
/** Create an empty default value when file is missing or unreadable. */
|
|
846
|
+
protected abstract createEmpty(): T;
|
|
847
|
+
/** Load from disk into cache if not already loaded. */
|
|
848
|
+
protected load(): T;
|
|
849
|
+
/**
|
|
850
|
+
* Mark the store dirty and schedule a debounced flush.
|
|
851
|
+
*/
|
|
852
|
+
protected markDirty(): void;
|
|
853
|
+
/**
|
|
854
|
+
* Flush cache to disk if dirty.
|
|
855
|
+
*
|
|
856
|
+
* Uses an atomic write (tmp + rename) to avoid partial files.
|
|
857
|
+
*/
|
|
858
|
+
flush(): void;
|
|
859
|
+
/** Stop any pending scheduled flush. Does not flush automatically. */
|
|
860
|
+
stopAutoFlush(): void;
|
|
861
|
+
}
|
|
862
|
+
|
|
809
863
|
/**
|
|
810
864
|
* @module values/ValuesManager
|
|
811
865
|
* Manages per-rule distinct metadata value tracking. Persists to disk with in-memory caching and sorted deduplication.
|
|
@@ -816,7 +870,7 @@ type ValuesIndex = Record<string, Record<string, unknown[]>>;
|
|
|
816
870
|
/**
|
|
817
871
|
* Manages a persistent values.json file tracking distinct metadata values per rule.
|
|
818
872
|
*/
|
|
819
|
-
declare class ValuesManager extends
|
|
873
|
+
declare class ValuesManager extends BinaryFileStore<ValuesIndex> {
|
|
820
874
|
constructor(stateDir: string, logger: pino.Logger);
|
|
821
875
|
protected createEmpty(): ValuesIndex;
|
|
822
876
|
/** Check if a value is a trackable primitive (string, number, boolean). */
|
|
@@ -997,6 +1051,7 @@ interface VectorStore {
|
|
|
997
1051
|
*/
|
|
998
1052
|
declare class VectorStoreClient implements VectorStore {
|
|
999
1053
|
private readonly client;
|
|
1054
|
+
private writeClient;
|
|
1000
1055
|
private readonly clientConfig;
|
|
1001
1056
|
private readonly collectionName;
|
|
1002
1057
|
private readonly dims;
|
|
@@ -1037,12 +1092,12 @@ declare class VectorStoreClient implements VectorStore {
|
|
|
1037
1092
|
* @param fn - Async function to retry.
|
|
1038
1093
|
*/
|
|
1039
1094
|
private retryOperation;
|
|
1095
|
+
private getWriteClient;
|
|
1040
1096
|
/**
|
|
1041
1097
|
* Upsert points into the collection.
|
|
1042
1098
|
*
|
|
1043
|
-
* Uses
|
|
1044
|
-
*
|
|
1045
|
-
* server, causing ECONNRESET on reuse.
|
|
1099
|
+
* Uses the shared client. On retry (after ECONNRESET from stale connections),
|
|
1100
|
+
* creates a fresh client to recover.
|
|
1046
1101
|
*
|
|
1047
1102
|
* @param points - The points to upsert.
|
|
1048
1103
|
*/
|
|
@@ -1050,7 +1105,7 @@ declare class VectorStoreClient implements VectorStore {
|
|
|
1050
1105
|
/**
|
|
1051
1106
|
* Delete points by their IDs.
|
|
1052
1107
|
*
|
|
1053
|
-
* Uses
|
|
1108
|
+
* Uses the shared client. On retry, creates a fresh client to recover.
|
|
1054
1109
|
*
|
|
1055
1110
|
* @param ids - The point IDs to delete.
|
|
1056
1111
|
*/
|
|
@@ -1360,6 +1415,7 @@ declare class EventQueue {
|
|
|
1360
1415
|
private readonly concurrency;
|
|
1361
1416
|
private readonly rateLimitPerMinute?;
|
|
1362
1417
|
private started;
|
|
1418
|
+
private paused;
|
|
1363
1419
|
private active;
|
|
1364
1420
|
private readonly debounceTimers;
|
|
1365
1421
|
private readonly latestByKey;
|
|
@@ -1368,6 +1424,7 @@ declare class EventQueue {
|
|
|
1368
1424
|
private tokens;
|
|
1369
1425
|
private lastRefillMs;
|
|
1370
1426
|
private drainWaiters;
|
|
1427
|
+
private idleWorkerWaiters;
|
|
1371
1428
|
/**
|
|
1372
1429
|
* Create an event queue.
|
|
1373
1430
|
*
|
|
@@ -1385,12 +1442,28 @@ declare class EventQueue {
|
|
|
1385
1442
|
* Start processing events.
|
|
1386
1443
|
*/
|
|
1387
1444
|
process(): void;
|
|
1445
|
+
/**
|
|
1446
|
+
* Pause processing events. Events can still be enqueued but will not be processed.
|
|
1447
|
+
*/
|
|
1448
|
+
pause(): void;
|
|
1449
|
+
/**
|
|
1450
|
+
* Resume processing events.
|
|
1451
|
+
*/
|
|
1452
|
+
resume(): void;
|
|
1388
1453
|
/**
|
|
1389
1454
|
* Wait for the queue to become idle (no pending debounces, no queued items, no active work).
|
|
1390
1455
|
*
|
|
1391
1456
|
* @returns A promise that resolves when the queue is drained.
|
|
1392
1457
|
*/
|
|
1393
1458
|
drain(): Promise<void>;
|
|
1459
|
+
/**
|
|
1460
|
+
* Wait until there is no in-flight work.
|
|
1461
|
+
*
|
|
1462
|
+
* Unlike {@link drain}, this does NOT wait for debounced or queued items to be empty.
|
|
1463
|
+
* It's useful when you need to temporarily quiesce outgoing work without losing
|
|
1464
|
+
* or rejecting new enqueues.
|
|
1465
|
+
*/
|
|
1466
|
+
waitForIdleWorkers(): Promise<void>;
|
|
1394
1467
|
private push;
|
|
1395
1468
|
private refillTokens;
|
|
1396
1469
|
private takeToken;
|
|
@@ -1398,6 +1471,7 @@ declare class EventQueue {
|
|
|
1398
1471
|
private pump;
|
|
1399
1472
|
private isIdle;
|
|
1400
1473
|
private maybeResolveDrain;
|
|
1474
|
+
private maybeResolveIdleWorkers;
|
|
1401
1475
|
}
|
|
1402
1476
|
|
|
1403
1477
|
/**
|
|
@@ -1663,6 +1737,8 @@ interface ApiServerOptions {
|
|
|
1663
1737
|
initialScanTracker?: InitialScanTracker;
|
|
1664
1738
|
/** Filesystem watcher instance for /walk endpoint (in-memory file list). */
|
|
1665
1739
|
fileSystemWatcher?: FileSystemWatcher;
|
|
1740
|
+
/** Getter for live filesystem watcher access after hot-reload rebuilds. */
|
|
1741
|
+
getFileSystemWatcher?: () => FileSystemWatcher | undefined;
|
|
1666
1742
|
/** Optional enrichment store for persisted enrichment metadata. */
|
|
1667
1743
|
enrichmentStore?: EnrichmentStoreInterface;
|
|
1668
1744
|
}
|
|
@@ -1726,7 +1802,12 @@ interface JeevesWatcherFactories {
|
|
|
1726
1802
|
/**
|
|
1727
1803
|
* Create and start a JeevesWatcher from a config file path.
|
|
1728
1804
|
*
|
|
1729
|
-
*
|
|
1805
|
+
* When no explicit config path is given, auto-migrates the legacy flat
|
|
1806
|
+
* config (`jeeves-watcher.config.json`) to the namespaced convention
|
|
1807
|
+
* (`jeeves-watcher/config.json`) before loading.
|
|
1808
|
+
*
|
|
1809
|
+
* @param configPath - Optional explicit path to the configuration file.
|
|
1810
|
+
* When provided, the file is loaded as-is (no migration).
|
|
1730
1811
|
* @returns The running JeevesWatcher instance.
|
|
1731
1812
|
*/
|
|
1732
1813
|
declare function startFromConfig(configPath?: string): Promise<JeevesWatcher>;
|
|
@@ -1791,6 +1872,18 @@ declare class JeevesWatcher {
|
|
|
1791
1872
|
*/
|
|
1792
1873
|
declare function loadConfig(configPath?: string): Promise<JeevesWatcherConfig>;
|
|
1793
1874
|
|
|
1875
|
+
/**
|
|
1876
|
+
* @module descriptor
|
|
1877
|
+
* Jeeves Component Descriptor for the watcher service. Single source of truth
|
|
1878
|
+
* consumed by core factories (CLI, plugin tools, HTTP handlers, service manager).
|
|
1879
|
+
*/
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* Watcher component descriptor. Single source of truth for service identity,
|
|
1883
|
+
* config schema, and extension points consumed by core factories.
|
|
1884
|
+
*/
|
|
1885
|
+
declare const watcherDescriptor: JeevesComponentDescriptor;
|
|
1886
|
+
|
|
1794
1887
|
/**
|
|
1795
1888
|
* @module extractors
|
|
1796
1889
|
*
|
|
@@ -1836,5 +1929,5 @@ declare function contentHash(text: string): string;
|
|
|
1836
1929
|
*/
|
|
1837
1930
|
declare function pointId(filePath: string, chunkIndex?: number): string;
|
|
1838
1931
|
|
|
1839
|
-
export { DocumentProcessor, EnrichmentStore, EventQueue, FileSystemWatcher, GitignoreFilter, InitialScanTracker, IssuesManager, JeevesWatcher, ReindexTracker, SystemHealth, TemplateEngine, ValuesManager, VectorStoreClient, VirtualRuleStore, apiConfigSchema, applyRules, buildAttributes, buildTemplateEngine, compileRules, configWatchConfigSchema, contentHash, createApiServer, createEmbeddingProvider, createHandlebarsInstance, createLogger, embeddingConfigSchema, extractText, inferenceRuleSchema, issueRecordSchema, jeevesWatcherConfigSchema, loadConfig, loadCustomHelpers, loggingConfigSchema, mergeEnrichment, pointId, registerBuiltinHelpers, resolveTemplateSource, startFromConfig, vectorStoreConfigSchema, watchConfigSchema };
|
|
1932
|
+
export { ContentHashCache, DocumentProcessor, EnrichmentStore, EventQueue, FileSystemWatcher, GitignoreFilter, InitialScanTracker, IssuesManager, JeevesWatcher, ReindexTracker, SystemHealth, TemplateEngine, ValuesManager, VectorStoreClient, VirtualRuleStore, apiConfigSchema, applyRules, buildAttributes, buildTemplateEngine, compileRules, configWatchConfigSchema, contentHash, createApiServer, createEmbeddingProvider, createHandlebarsInstance, createLogger, embeddingConfigSchema, extractText, inferenceRuleSchema, issueRecordSchema, jeevesWatcherConfigSchema, loadConfig, loadCustomHelpers, loggingConfigSchema, mergeEnrichment, pointId, registerBuiltinHelpers, resolveTemplateSource, startFromConfig, vectorStoreConfigSchema, watchConfigSchema, watcherDescriptor };
|
|
1840
1933
|
export type { AllHelpersIntrospection, ApiConfig, ApiServerOptions, ApplyRulesOptions, ApplyRulesResult, CollectionInfo, CompiledRule, CompiledTemplate, ConfigWatchConfig, DocumentProcessorDeps, DocumentProcessorInterface, EmbeddingConfig, EmbeddingProvider, EnrichmentStoreInterface, EventQueueOptions, ExtractedText, Extractor, FileAttributes, FileSystemWatcherOptions, HelperModuleIntrospection, InferenceRule, InitialScanStatus, IssueRecord, IssuesFile, JeevesWatcherConfig, JeevesWatcherConfigInput, JeevesWatcherFactories, JeevesWatcherRuntimeOptions, LoggingConfig, PayloadFieldSchema, ProcessFn, ProcessorConfig, ProviderFactory, ReindexStatus, RenderResult, RuleLogger, ScrollPageResult, ScrolledPoint, SearchResult, SystemHealthOptions, ValuesIndex, VectorPoint, VectorStore, VectorStoreConfig, WatchConfig, WatchEvent };
|