@robthepcguy/rag-vault 1.0.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.
Files changed (131) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +421 -0
  3. package/dist/bin/install-skills.d.ts +20 -0
  4. package/dist/bin/install-skills.d.ts.map +1 -0
  5. package/dist/bin/install-skills.js +196 -0
  6. package/dist/bin/install-skills.js.map +1 -0
  7. package/dist/chunker/index.d.ts +11 -0
  8. package/dist/chunker/index.d.ts.map +1 -0
  9. package/dist/chunker/index.js +6 -0
  10. package/dist/chunker/index.js.map +1 -0
  11. package/dist/chunker/semantic-chunker.d.ts +96 -0
  12. package/dist/chunker/semantic-chunker.d.ts.map +1 -0
  13. package/dist/chunker/semantic-chunker.js +267 -0
  14. package/dist/chunker/semantic-chunker.js.map +1 -0
  15. package/dist/chunker/sentence-splitter.d.ts +16 -0
  16. package/dist/chunker/sentence-splitter.d.ts.map +1 -0
  17. package/dist/chunker/sentence-splitter.js +114 -0
  18. package/dist/chunker/sentence-splitter.js.map +1 -0
  19. package/dist/embedder/index.d.ts +55 -0
  20. package/dist/embedder/index.d.ts.map +1 -0
  21. package/dist/embedder/index.js +146 -0
  22. package/dist/embedder/index.js.map +1 -0
  23. package/dist/errors/index.d.ts +73 -0
  24. package/dist/errors/index.d.ts.map +1 -0
  25. package/dist/errors/index.js +170 -0
  26. package/dist/errors/index.js.map +1 -0
  27. package/dist/index.d.ts +3 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +91 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/parser/html-parser.d.ts +14 -0
  32. package/dist/parser/html-parser.d.ts.map +1 -0
  33. package/dist/parser/html-parser.js +99 -0
  34. package/dist/parser/html-parser.js.map +1 -0
  35. package/dist/parser/index.d.ts +144 -0
  36. package/dist/parser/index.d.ts.map +1 -0
  37. package/dist/parser/index.js +446 -0
  38. package/dist/parser/index.js.map +1 -0
  39. package/dist/parser/pdf-filter.d.ts +89 -0
  40. package/dist/parser/pdf-filter.d.ts.map +1 -0
  41. package/dist/parser/pdf-filter.js +304 -0
  42. package/dist/parser/pdf-filter.js.map +1 -0
  43. package/dist/server/index.d.ts +144 -0
  44. package/dist/server/index.d.ts.map +1 -0
  45. package/dist/server/index.js +518 -0
  46. package/dist/server/index.js.map +1 -0
  47. package/dist/server/raw-data-utils.d.ts +81 -0
  48. package/dist/server/raw-data-utils.d.ts.map +1 -0
  49. package/dist/server/raw-data-utils.js +196 -0
  50. package/dist/server/raw-data-utils.js.map +1 -0
  51. package/dist/server/schemas.d.ts +186 -0
  52. package/dist/server/schemas.d.ts.map +1 -0
  53. package/dist/server/schemas.js +99 -0
  54. package/dist/server/schemas.js.map +1 -0
  55. package/dist/utils/config-parsers.d.ts +14 -0
  56. package/dist/utils/config-parsers.d.ts.map +1 -0
  57. package/dist/utils/config-parsers.js +47 -0
  58. package/dist/utils/config-parsers.js.map +1 -0
  59. package/dist/utils/config.d.ts +37 -0
  60. package/dist/utils/config.d.ts.map +1 -0
  61. package/dist/utils/config.js +52 -0
  62. package/dist/utils/config.js.map +1 -0
  63. package/dist/utils/logger.d.ts +36 -0
  64. package/dist/utils/logger.d.ts.map +1 -0
  65. package/dist/utils/logger.js +64 -0
  66. package/dist/utils/logger.js.map +1 -0
  67. package/dist/utils/math.d.ts +34 -0
  68. package/dist/utils/math.d.ts.map +1 -0
  69. package/dist/utils/math.js +73 -0
  70. package/dist/utils/math.js.map +1 -0
  71. package/dist/utils/process-handlers.d.ts +26 -0
  72. package/dist/utils/process-handlers.d.ts.map +1 -0
  73. package/dist/utils/process-handlers.js +69 -0
  74. package/dist/utils/process-handlers.js.map +1 -0
  75. package/dist/vectordb/index.d.ts +210 -0
  76. package/dist/vectordb/index.d.ts.map +1 -0
  77. package/dist/vectordb/index.js +613 -0
  78. package/dist/vectordb/index.js.map +1 -0
  79. package/dist/web/api-routes.d.ts +9 -0
  80. package/dist/web/api-routes.d.ts.map +1 -0
  81. package/dist/web/api-routes.js +127 -0
  82. package/dist/web/api-routes.js.map +1 -0
  83. package/dist/web/config-routes.d.ts +7 -0
  84. package/dist/web/config-routes.d.ts.map +1 -0
  85. package/dist/web/config-routes.js +54 -0
  86. package/dist/web/config-routes.js.map +1 -0
  87. package/dist/web/database-manager.d.ts +130 -0
  88. package/dist/web/database-manager.d.ts.map +1 -0
  89. package/dist/web/database-manager.js +382 -0
  90. package/dist/web/database-manager.js.map +1 -0
  91. package/dist/web/http-server.d.ts +28 -0
  92. package/dist/web/http-server.d.ts.map +1 -0
  93. package/dist/web/http-server.js +311 -0
  94. package/dist/web/http-server.js.map +1 -0
  95. package/dist/web/index.d.ts +3 -0
  96. package/dist/web/index.d.ts.map +1 -0
  97. package/dist/web/index.js +114 -0
  98. package/dist/web/index.js.map +1 -0
  99. package/dist/web/middleware/async-handler.d.ts +17 -0
  100. package/dist/web/middleware/async-handler.d.ts.map +1 -0
  101. package/dist/web/middleware/async-handler.js +26 -0
  102. package/dist/web/middleware/async-handler.js.map +1 -0
  103. package/dist/web/middleware/auth.d.ts +22 -0
  104. package/dist/web/middleware/auth.d.ts.map +1 -0
  105. package/dist/web/middleware/auth.js +81 -0
  106. package/dist/web/middleware/auth.js.map +1 -0
  107. package/dist/web/middleware/error-handler.d.ts +36 -0
  108. package/dist/web/middleware/error-handler.d.ts.map +1 -0
  109. package/dist/web/middleware/error-handler.js +68 -0
  110. package/dist/web/middleware/error-handler.js.map +1 -0
  111. package/dist/web/middleware/index.d.ts +6 -0
  112. package/dist/web/middleware/index.d.ts.map +1 -0
  113. package/dist/web/middleware/index.js +19 -0
  114. package/dist/web/middleware/index.js.map +1 -0
  115. package/dist/web/middleware/rate-limit.d.ts +38 -0
  116. package/dist/web/middleware/rate-limit.d.ts.map +1 -0
  117. package/dist/web/middleware/rate-limit.js +116 -0
  118. package/dist/web/middleware/rate-limit.js.map +1 -0
  119. package/dist/web/middleware/request-logger.d.ts +52 -0
  120. package/dist/web/middleware/request-logger.d.ts.map +1 -0
  121. package/dist/web/middleware/request-logger.js +74 -0
  122. package/dist/web/middleware/request-logger.js.map +1 -0
  123. package/dist/web/types.d.ts +6 -0
  124. package/dist/web/types.d.ts.map +1 -0
  125. package/dist/web/types.js +4 -0
  126. package/dist/web/types.js.map +1 -0
  127. package/package.json +135 -0
  128. package/skills/rag-vault/SKILL.md +111 -0
  129. package/skills/rag-vault/references/html-ingestion.md +73 -0
  130. package/skills/rag-vault/references/query-optimization.md +57 -0
  131. package/skills/rag-vault/references/result-refinement.md +54 -0
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ // Raw Data Utilities for ingest_data tool
3
+ // Handles: base64url encoding, source normalization, file saving, source extraction
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.encodeBase64Url = encodeBase64Url;
6
+ exports.decodeBase64Url = decodeBase64Url;
7
+ exports.validateSourceProtocol = validateSourceProtocol;
8
+ exports.normalizeSource = normalizeSource;
9
+ exports.getRawDataDir = getRawDataDir;
10
+ exports.generateRawDataPath = generateRawDataPath;
11
+ exports.saveRawData = saveRawData;
12
+ exports.isRawDataPath = isRawDataPath;
13
+ exports.extractSourceFromPath = extractSourceFromPath;
14
+ const promises_1 = require("node:fs/promises");
15
+ const node_path_1 = require("node:path");
16
+ // ============================================
17
+ // Base64URL Encoding/Decoding
18
+ // ============================================
19
+ /**
20
+ * Encode string to URL-safe base64 (base64url)
21
+ * - Replaces + with -
22
+ * - Replaces / with _
23
+ * - Removes padding (=)
24
+ *
25
+ * @param str - String to encode
26
+ * @returns URL-safe base64 encoded string
27
+ */
28
+ function encodeBase64Url(str) {
29
+ return Buffer.from(str, 'utf-8')
30
+ .toString('base64')
31
+ .replace(/\+/g, '-')
32
+ .replace(/\//g, '_')
33
+ .replace(/=+$/, '');
34
+ }
35
+ /**
36
+ * Decode URL-safe base64 (base64url) to string
37
+ *
38
+ * @param base64url - URL-safe base64 encoded string
39
+ * @returns Decoded string
40
+ */
41
+ function decodeBase64Url(base64url) {
42
+ // Convert base64url to standard base64
43
+ let base64 = base64url.replace(/-/g, '+').replace(/_/g, '/');
44
+ // Add padding if needed
45
+ while (base64.length % 4 !== 0) {
46
+ base64 += '=';
47
+ }
48
+ return Buffer.from(base64, 'base64').toString('utf-8');
49
+ }
50
+ // ============================================
51
+ // Source Normalization
52
+ // ============================================
53
+ /**
54
+ * Blocked protocols that could be dangerous or lead to security issues.
55
+ * - javascript: XSS attacks
56
+ * - vbscript: VBScript execution
57
+ * - data: Can embed malicious content
58
+ */
59
+ const BLOCKED_PROTOCOLS = ['javascript:', 'vbscript:', 'data:'];
60
+ /**
61
+ * Validate that a source doesn't use a dangerous protocol
62
+ *
63
+ * @param source - Source identifier to validate
64
+ * @throws Error if the protocol is blocked
65
+ */
66
+ function validateSourceProtocol(source) {
67
+ try {
68
+ const parsed = new URL(source);
69
+ if (BLOCKED_PROTOCOLS.includes(parsed.protocol)) {
70
+ throw new Error(`Blocked protocol: ${parsed.protocol}. These protocols are not allowed for security reasons.`);
71
+ }
72
+ }
73
+ catch (error) {
74
+ // If it's our validation error, rethrow it
75
+ if (error instanceof Error && error.message.startsWith('Blocked protocol')) {
76
+ throw error;
77
+ }
78
+ // Not a valid URL format - this is OK, could be a simple identifier
79
+ }
80
+ }
81
+ /**
82
+ * Normalize source URL by removing query string and fragment
83
+ * Only normalizes HTTP(S) URLs. Other sources (e.g., "clipboard://...") are returned as-is
84
+ *
85
+ * @param source - Source identifier (URL or custom ID)
86
+ * @returns Normalized source
87
+ * @throws Error if the source uses a disallowed protocol
88
+ */
89
+ function normalizeSource(source) {
90
+ // Validate protocol before processing
91
+ validateSourceProtocol(source);
92
+ try {
93
+ const parsed = new URL(source);
94
+ // Only normalize HTTP(S) URLs
95
+ if (parsed.protocol === 'http:' || parsed.protocol === 'https:') {
96
+ return `${parsed.origin}${parsed.pathname}`;
97
+ }
98
+ // Non-HTTP URLs (clipboard://, etc.) are returned as-is
99
+ return source;
100
+ }
101
+ catch {
102
+ // Not a valid URL, return as-is
103
+ return source;
104
+ }
105
+ }
106
+ // ============================================
107
+ // Path Generation
108
+ // ============================================
109
+ /**
110
+ * Get raw-data directory path
111
+ *
112
+ * @param dbPath - LanceDB database path
113
+ * @returns Raw-data directory path
114
+ */
115
+ function getRawDataDir(dbPath) {
116
+ return (0, node_path_1.join)(dbPath, 'raw-data');
117
+ }
118
+ /**
119
+ * Generate raw-data file path from source and format
120
+ * Path format: {dbPath}/raw-data/{base64url(normalizedSource)}.{ext}
121
+ *
122
+ * @param dbPath - LanceDB database path
123
+ * @param source - Source identifier (URL or custom ID)
124
+ * @param format - Content format
125
+ * @returns Generated file path
126
+ */
127
+ function generateRawDataPath(dbPath, source, _format) {
128
+ const normalizedSource = normalizeSource(source);
129
+ const encoded = encodeBase64Url(normalizedSource);
130
+ // All formats use .md extension for consistency
131
+ // This allows generating unique path from source without knowing original format
132
+ return (0, node_path_1.resolve)(getRawDataDir(dbPath), `${encoded}.md`);
133
+ }
134
+ // ============================================
135
+ // File Operations
136
+ // ============================================
137
+ /**
138
+ * Save content to raw-data directory
139
+ * Creates directory if it doesn't exist
140
+ *
141
+ * @param dbPath - LanceDB database path
142
+ * @param source - Source identifier (URL or custom ID)
143
+ * @param content - Content to save
144
+ * @param format - Content format
145
+ * @returns Saved file path
146
+ */
147
+ async function saveRawData(dbPath, source, content, format) {
148
+ const filePath = generateRawDataPath(dbPath, source, format);
149
+ // Ensure directory exists
150
+ await (0, promises_1.mkdir)((0, node_path_1.dirname)(filePath), { recursive: true });
151
+ // Write content to file
152
+ await (0, promises_1.writeFile)(filePath, content, 'utf-8');
153
+ return filePath;
154
+ }
155
+ // ============================================
156
+ // Path Detection and Source Extraction
157
+ // ============================================
158
+ // Path patterns for raw-data directory detection (cross-platform)
159
+ const RAW_DATA_POSIX = '/raw-data/';
160
+ const RAW_DATA_NATIVE = `${node_path_1.sep}raw-data${node_path_1.sep}`;
161
+ /**
162
+ * Check if file path is in raw-data directory
163
+ *
164
+ * @param filePath - File path to check
165
+ * @returns True if path is in raw-data directory
166
+ */
167
+ function isRawDataPath(filePath) {
168
+ return filePath.includes(RAW_DATA_NATIVE) || filePath.includes(RAW_DATA_POSIX);
169
+ }
170
+ /**
171
+ * Extract original source from raw-data file path
172
+ * Returns null if not a raw-data path
173
+ *
174
+ * @param filePath - Raw-data file path
175
+ * @returns Original source or null
176
+ */
177
+ function extractSourceFromPath(filePath) {
178
+ // Try native path separator first, then POSIX
179
+ let rawDataIndex = filePath.indexOf(RAW_DATA_NATIVE);
180
+ let markerLength = RAW_DATA_NATIVE.length;
181
+ if (rawDataIndex === -1) {
182
+ rawDataIndex = filePath.indexOf(RAW_DATA_POSIX);
183
+ markerLength = RAW_DATA_POSIX.length;
184
+ }
185
+ if (rawDataIndex === -1) {
186
+ return null;
187
+ }
188
+ const fileName = filePath.slice(rawDataIndex + markerLength);
189
+ const dotIndex = fileName.lastIndexOf('.');
190
+ if (dotIndex === -1) {
191
+ return null;
192
+ }
193
+ const encoded = fileName.slice(0, dotIndex);
194
+ return decodeBase64Url(encoded);
195
+ }
196
+ //# sourceMappingURL=raw-data-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw-data-utils.js","sourceRoot":"","sources":["../../src/server/raw-data-utils.ts"],"names":[],"mappings":";AAAA,0CAA0C;AAC1C,oFAAoF;;AAkBpF,0CAMC;AAQD,0CAUC;AAoBD,wDAaC;AAUD,0CAgBC;AAqBD,sCAEC;AAWD,kDAUC;AAgBD,kCAeC;AAgBD,sCAEC;AASD,sDAuBC;AAhOD,+CAAmD;AACnD,yCAAuD;AAEvD,+CAA+C;AAC/C,8BAA8B;AAC9B,+CAA+C;AAE/C;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC;SAC7B,QAAQ,CAAC,QAAQ,CAAC;SAClB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;SACnB,OAAO,CAAC,KAA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Ae,CAAC,OAAO,CAAC,CAAA;AACjC,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { z } from 'zod';
2
+ /**
3
+ * Content format enum for ingest_data
4
+ */
5
+ export declare const ContentFormatSchema: z.ZodEnum<["text", "html", "markdown"]>;
6
+ /**
7
+ * query_documents tool input schema
8
+ */
9
+ export declare const QueryDocumentsSchema: z.ZodObject<{
10
+ query: z.ZodString;
11
+ limit: z.ZodOptional<z.ZodNumber>;
12
+ }, "strip", z.ZodTypeAny, {
13
+ query: string;
14
+ limit?: number | undefined;
15
+ }, {
16
+ query: string;
17
+ limit?: number | undefined;
18
+ }>;
19
+ /**
20
+ * ingest_file tool input schema
21
+ */
22
+ export declare const IngestFileSchema: z.ZodObject<{
23
+ filePath: z.ZodString;
24
+ }, "strip", z.ZodTypeAny, {
25
+ filePath: string;
26
+ }, {
27
+ filePath: string;
28
+ }>;
29
+ /**
30
+ * ingest_data metadata schema
31
+ */
32
+ export declare const IngestDataMetadataSchema: z.ZodObject<{
33
+ source: z.ZodString;
34
+ format: z.ZodEnum<["text", "html", "markdown"]>;
35
+ }, "strip", z.ZodTypeAny, {
36
+ source: string;
37
+ format: "text" | "html" | "markdown";
38
+ }, {
39
+ source: string;
40
+ format: "text" | "html" | "markdown";
41
+ }>;
42
+ /**
43
+ * ingest_data tool input schema
44
+ */
45
+ export declare const IngestDataSchema: z.ZodObject<{
46
+ content: z.ZodString;
47
+ metadata: z.ZodObject<{
48
+ source: z.ZodString;
49
+ format: z.ZodEnum<["text", "html", "markdown"]>;
50
+ }, "strip", z.ZodTypeAny, {
51
+ source: string;
52
+ format: "text" | "html" | "markdown";
53
+ }, {
54
+ source: string;
55
+ format: "text" | "html" | "markdown";
56
+ }>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ content: string;
59
+ metadata: {
60
+ source: string;
61
+ format: "text" | "html" | "markdown";
62
+ };
63
+ }, {
64
+ content: string;
65
+ metadata: {
66
+ source: string;
67
+ format: "text" | "html" | "markdown";
68
+ };
69
+ }>;
70
+ /**
71
+ * delete_file tool input schema
72
+ */
73
+ export declare const DeleteFileSchema: z.ZodEffects<z.ZodObject<{
74
+ filePath: z.ZodOptional<z.ZodString>;
75
+ source: z.ZodOptional<z.ZodString>;
76
+ }, "strip", z.ZodTypeAny, {
77
+ source?: string | undefined;
78
+ filePath?: string | undefined;
79
+ }, {
80
+ source?: string | undefined;
81
+ filePath?: string | undefined;
82
+ }>, {
83
+ source?: string | undefined;
84
+ filePath?: string | undefined;
85
+ }, {
86
+ source?: string | undefined;
87
+ filePath?: string | undefined;
88
+ }>;
89
+ export type QueryDocumentsInput = z.infer<typeof QueryDocumentsSchema>;
90
+ export type IngestFileInput = z.infer<typeof IngestFileSchema>;
91
+ export type IngestDataInput = z.infer<typeof IngestDataSchema>;
92
+ export type DeleteFileInput = z.infer<typeof DeleteFileSchema>;
93
+ export interface QueryResult {
94
+ filePath: string;
95
+ chunkIndex: number;
96
+ text: string;
97
+ score: number;
98
+ source?: string;
99
+ }
100
+ export interface IngestResult {
101
+ filePath: string;
102
+ chunkCount: number;
103
+ timestamp: string;
104
+ }
105
+ export interface DeleteResult {
106
+ filePath: string;
107
+ deleted: boolean;
108
+ timestamp: string;
109
+ }
110
+ export interface FileInfo {
111
+ filePath: string;
112
+ chunkCount: number;
113
+ source?: string;
114
+ }
115
+ export interface StatusOutput {
116
+ documentCount: number;
117
+ chunkCount: number;
118
+ memoryUsage: number;
119
+ uptime: number;
120
+ ftsIndexEnabled: boolean;
121
+ searchMode: 'hybrid' | 'vector-only';
122
+ }
123
+ /**
124
+ * Schema for validating status response from RAG server
125
+ */
126
+ export declare const StatusResponseSchema: z.ZodObject<{
127
+ documentCount: z.ZodNumber;
128
+ chunkCount: z.ZodNumber;
129
+ memoryUsage: z.ZodNumber;
130
+ uptime: z.ZodNumber;
131
+ ftsIndexEnabled: z.ZodBoolean;
132
+ searchMode: z.ZodEnum<["hybrid", "vector-only"]>;
133
+ }, "strip", z.ZodTypeAny, {
134
+ documentCount: number;
135
+ chunkCount: number;
136
+ memoryUsage: number;
137
+ ftsIndexEnabled: boolean;
138
+ searchMode: "hybrid" | "vector-only";
139
+ uptime: number;
140
+ }, {
141
+ documentCount: number;
142
+ chunkCount: number;
143
+ memoryUsage: number;
144
+ ftsIndexEnabled: boolean;
145
+ searchMode: "hybrid" | "vector-only";
146
+ uptime: number;
147
+ }>;
148
+ /**
149
+ * Schema for validating recent databases file structure
150
+ */
151
+ export declare const RecentDatabasesFileSchema: z.ZodObject<{
152
+ version: z.ZodNumber;
153
+ databases: z.ZodArray<z.ZodObject<{
154
+ path: z.ZodString;
155
+ name: z.ZodString;
156
+ lastAccessed: z.ZodString;
157
+ modelName: z.ZodOptional<z.ZodString>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ name: string;
160
+ path: string;
161
+ lastAccessed: string;
162
+ modelName?: string | undefined;
163
+ }, {
164
+ name: string;
165
+ path: string;
166
+ lastAccessed: string;
167
+ modelName?: string | undefined;
168
+ }>, "many">;
169
+ }, "strip", z.ZodTypeAny, {
170
+ version: number;
171
+ databases: {
172
+ name: string;
173
+ path: string;
174
+ lastAccessed: string;
175
+ modelName?: string | undefined;
176
+ }[];
177
+ }, {
178
+ version: number;
179
+ databases: {
180
+ name: string;
181
+ path: string;
182
+ lastAccessed: string;
183
+ modelName?: string | undefined;
184
+ }[];
185
+ }>;
186
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../src/server/schemas.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,mBAAmB,yCAAuC,CAAA;AAEvE;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;EAc/B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;EAK3B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;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UAAU,EAAE,QAAQ,GAAG,aAAa,CAAA;CACrC;AAMD;;GAEG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;EAO/B,CAAA;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUpC,CAAA"}
@@ -0,0 +1,99 @@
1
+ "use strict";
2
+ // Zod schemas for MCP tool validation
3
+ // Used by RAGServer with McpServer high-level API
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.RecentDatabasesFileSchema = exports.StatusResponseSchema = exports.DeleteFileSchema = exports.IngestDataSchema = exports.IngestDataMetadataSchema = exports.IngestFileSchema = exports.QueryDocumentsSchema = exports.ContentFormatSchema = void 0;
6
+ const zod_1 = require("zod");
7
+ /**
8
+ * Content format enum for ingest_data
9
+ */
10
+ exports.ContentFormatSchema = zod_1.z.enum(['text', 'html', 'markdown']);
11
+ /**
12
+ * query_documents tool input schema
13
+ */
14
+ exports.QueryDocumentsSchema = zod_1.z.object({
15
+ query: zod_1.z
16
+ .string()
17
+ .min(1, 'Query cannot be empty')
18
+ .describe('Search query. Include specific terms and add context if needed.'),
19
+ limit: zod_1.z
20
+ .number()
21
+ .int()
22
+ .positive()
23
+ .max(20, 'Limit cannot exceed 20')
24
+ .optional()
25
+ .describe('Maximum number of results to return (default: 10, max: 20). Recommended: 5 for precision, 10 for balance, 20 for broad exploration.'),
26
+ });
27
+ /**
28
+ * ingest_file tool input schema
29
+ */
30
+ exports.IngestFileSchema = zod_1.z.object({
31
+ filePath: zod_1.z
32
+ .string()
33
+ .min(1, 'File path cannot be empty')
34
+ .describe('Absolute path to the file to ingest. Example: "/Users/user/documents/manual.pdf"'),
35
+ });
36
+ /**
37
+ * ingest_data metadata schema
38
+ */
39
+ exports.IngestDataMetadataSchema = zod_1.z.object({
40
+ source: zod_1.z
41
+ .string()
42
+ .min(1, 'Source cannot be empty')
43
+ .describe('Source identifier. For web pages, use the URL (e.g., "https://example.com/page"). For other content, use URL-scheme format: "{type}://{date}" or "{type}://{date}/{detail}". Examples: "clipboard://2024-12-30", "chat://2024-12-30/project-discussion".'),
44
+ format: exports.ContentFormatSchema.describe('Content format: "text", "html", or "markdown"'),
45
+ });
46
+ /**
47
+ * ingest_data tool input schema
48
+ */
49
+ exports.IngestDataSchema = zod_1.z.object({
50
+ content: zod_1.z
51
+ .string()
52
+ .min(1, 'Content cannot be empty')
53
+ .describe('The content to ingest (text, HTML, or Markdown)'),
54
+ metadata: exports.IngestDataMetadataSchema.describe('Content metadata'),
55
+ });
56
+ /**
57
+ * delete_file tool input schema
58
+ */
59
+ exports.DeleteFileSchema = zod_1.z
60
+ .object({
61
+ filePath: zod_1.z
62
+ .string()
63
+ .optional()
64
+ .describe('Absolute path to the file (for ingest_file). Example: "/Users/user/documents/manual.pdf"'),
65
+ source: zod_1.z
66
+ .string()
67
+ .optional()
68
+ .describe('Source identifier used in ingest_data. Examples: "https://example.com/page", "clipboard://2024-12-30"'),
69
+ })
70
+ .refine((data) => data.filePath !== undefined || data.source !== undefined, {
71
+ message: 'Either filePath or source must be provided',
72
+ });
73
+ // ============================================
74
+ // Internal Response Validation Schemas
75
+ // ============================================
76
+ /**
77
+ * Schema for validating status response from RAG server
78
+ */
79
+ exports.StatusResponseSchema = zod_1.z.object({
80
+ documentCount: zod_1.z.number(),
81
+ chunkCount: zod_1.z.number(),
82
+ memoryUsage: zod_1.z.number(),
83
+ uptime: zod_1.z.number(),
84
+ ftsIndexEnabled: zod_1.z.boolean(),
85
+ searchMode: zod_1.z.enum(['hybrid', 'vector-only']),
86
+ });
87
+ /**
88
+ * Schema for validating recent databases file structure
89
+ */
90
+ exports.RecentDatabasesFileSchema = zod_1.z.object({
91
+ version: zod_1.z.number(),
92
+ databases: zod_1.z.array(zod_1.z.object({
93
+ path: zod_1.z.string(),
94
+ name: zod_1.z.string(),
95
+ lastAccessed: zod_1.z.string(),
96
+ modelName: zod_1.z.string().optional(),
97
+ })),
98
+ });
99
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../src/server/schemas.ts"],"names":[],"mappings":";AAAA,sCAAsC;AACtC,kDAAkD;;;AAElD,6BAAuB;AAEvB;;GAEG;AACU,QAAA,mBAAmB,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAA;AAEvE;;GAEG;AACU,QAAA,oBAAoB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;SAC/B,QAAQ,CAAC,iEAAiE,CAAC;IAC9E,KAAK,EAAE,OAAC;SACL,MAAM,EAAE;SACR,GAAG,EAAE;SACL,QAAQ,EAAE;SACV,GAAG,CAAC,EAAE,EAAE,wBAAwB,CAAC;SACjC,QAAQ,EAAE;SACV,QAAQ,CACP,qIAAqI,CACtI;CACJ,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,QAAQ,EAAE,OAAC;SACR,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,2BAA2B,CAAC;SACnC,QAAQ,CAAC,kFAAkF,CAAC;CAChG,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IAC/C,MAAM,EAAE,OAAC;SACN,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,EAAE,wBAAwB,CAAC;SAChC,QAAQ,CACP,0PAA0P,CAC3P;IACH,MAAM,EAAE,2BAAmB,CAAC,QAAQ,CAAC,+CAA+C,CAAC;CACtF,CAAC,CAAA;AAEF;;GAEG;AACU,QAAA,gBAAgB,GAAG,OAAC,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,OAAC;SACP,MAAM,EAAE;SACR,GAAG,C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MAAM,EAAE;QAChB,YAAY,EAAE,OAAC,CAAC,MAAM,EAAE;QACxB,SAAS,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KACjC,CAAC,CACH;CACF,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { GroupingMode } from '../vectordb/index.js';
2
+ /**
3
+ * Parse grouping mode from environment variable
4
+ */
5
+ export declare function parseGroupingMode(value: string | undefined): GroupingMode | undefined;
6
+ /**
7
+ * Parse max distance from environment variable
8
+ */
9
+ export declare function parseMaxDistance(value: string | undefined): number | undefined;
10
+ /**
11
+ * Parse hybrid weight from environment variable
12
+ */
13
+ export declare function parseHybridWeight(value: string | undefined): number | undefined;
14
+ //# sourceMappingURL=config-parsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-parsers.d.ts","sourceRoot":"","sources":["../../src/utils/config-parsers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAExD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAUrF;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAQ9E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAU/E"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ // Shared configuration parsing utilities
3
+ // Used by both MCP server (src/index.ts) and Web server (src/web/index.ts)
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.parseGroupingMode = parseGroupingMode;
6
+ exports.parseMaxDistance = parseMaxDistance;
7
+ exports.parseHybridWeight = parseHybridWeight;
8
+ /**
9
+ * Parse grouping mode from environment variable
10
+ */
11
+ function parseGroupingMode(value) {
12
+ if (!value)
13
+ return undefined;
14
+ const normalized = value.toLowerCase().trim();
15
+ if (normalized === 'similar' || normalized === 'related') {
16
+ return normalized;
17
+ }
18
+ console.error(`Invalid RAG_GROUPING value: "${value}". Expected "similar" or "related". Ignoring.`);
19
+ return undefined;
20
+ }
21
+ /**
22
+ * Parse max distance from environment variable
23
+ */
24
+ function parseMaxDistance(value) {
25
+ if (!value)
26
+ return undefined;
27
+ const parsed = Number.parseFloat(value);
28
+ if (Number.isNaN(parsed) || parsed <= 0) {
29
+ console.error(`Invalid RAG_MAX_DISTANCE value: "${value}". Expected positive number. Ignoring.`);
30
+ return undefined;
31
+ }
32
+ return parsed;
33
+ }
34
+ /**
35
+ * Parse hybrid weight from environment variable
36
+ */
37
+ function parseHybridWeight(value) {
38
+ if (!value)
39
+ return undefined;
40
+ const parsed = Number.parseFloat(value);
41
+ if (Number.isNaN(parsed) || parsed < 0 || parsed > 1) {
42
+ console.error(`Invalid RAG_HYBRID_WEIGHT value: "${value}". Expected 0.0-1.0. Using default (0.6).`);
43
+ return undefined;
44
+ }
45
+ return parsed;
46
+ }
47
+ //# sourceMappingURL=config-parsers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-parsers.js","sourceRoot":"","sources":["../../src/utils/config-parsers.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,2EAA2E;;AAO3E,8CAUC;AAKD,4CAQC;AAKD,8CAUC;AAzCD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAAyB;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC5B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,CAAA;IAC7C,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QACzD,OAAO,UAAU,CAAA;IACnB,CAAC;IACD,OAAO,CAAC,KAAK,CACX,gCAAgC,KAAK,+CAA+C,CACrF,CAAA;IACD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED;;GAEG;AACH,SAAgB,gBAAgB,CAAC,KAAyB;IACxD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,CAAC,KAAK,CAAC,oCAAoC,KAAK,wCAAwC,CAAC,CAAA;QAChG,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAAyB;IACzD,IAAI,CAAC,KAAK;QAAE,OAAO,SAAS,CAAA;IAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACvC,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;QACrD,OAAO,CAAC,KAAK,CACX,qCAAqC,KAAK,2CAA2C,CACtF,CAAA;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,37 @@
1
+ import type { GroupingMode } from '../vectordb/index.js';
2
+ /**
3
+ * RAG server configuration (matches RAGServerConfig in server/index.ts)
4
+ */
5
+ export interface RAGConfig {
6
+ /** LanceDB database path */
7
+ dbPath: string;
8
+ /** Transformers.js model path */
9
+ modelName: string;
10
+ /** Model cache directory */
11
+ cacheDir: string;
12
+ /** Document base directory */
13
+ baseDir: string;
14
+ /** Maximum file size in bytes */
15
+ maxFileSize: number;
16
+ /** Maximum distance threshold for quality filtering (optional) */
17
+ maxDistance?: number;
18
+ /** Grouping mode for quality filtering (optional) */
19
+ grouping?: GroupingMode;
20
+ /** Hybrid search weight for BM25 (0.0 = vector only, 1.0 = BM25 only) */
21
+ hybridWeight?: number;
22
+ }
23
+ /**
24
+ * Build RAG server configuration from environment variables
25
+ *
26
+ * Environment variables:
27
+ * - DB_PATH: LanceDB database path (default: ./lancedb/)
28
+ * - MODEL_NAME: Transformers.js model name (default: Xenova/all-MiniLM-L6-v2)
29
+ * - CACHE_DIR: Model cache directory (default: ./models/)
30
+ * - BASE_DIR: Document base directory (default: process.cwd())
31
+ * - MAX_FILE_SIZE: Maximum file size in bytes (default: 104857600)
32
+ * - RAG_MAX_DISTANCE: Quality filter max distance threshold
33
+ * - RAG_GROUPING: Quality filter grouping mode ('similar' | 'related')
34
+ * - RAG_HYBRID_WEIGHT: Hybrid search weight (0.0-1.0)
35
+ */
36
+ export declare function buildRAGConfig(overrides?: Partial<RAGConfig>): RAGConfig;
37
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AAGxD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4BAA4B;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,4BAA4B;IAC5B,QAAQ,EAAE,MAAM,CAAA;IAChB,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,iCAAiC;IACjC,WAAW,EAAE,MAAM,CAAA;IACnB,kEAAkE;IAClE,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,YAAY,CAAA;IACvB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAYD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CA6BxE"}
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ // Shared configuration builder for RAG servers
3
+ // Used by both MCP server (src/index.ts) and Web server (src/web/index.ts)
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.buildRAGConfig = buildRAGConfig;
6
+ const config_parsers_js_1 = require("./config-parsers.js");
7
+ /**
8
+ * Default configuration values
9
+ */
10
+ const DEFAULTS = {
11
+ dbPath: './lancedb/',
12
+ modelName: 'Xenova/all-MiniLM-L6-v2',
13
+ cacheDir: './models/',
14
+ maxFileSize: 104857600, // 100MB
15
+ };
16
+ /**
17
+ * Build RAG server configuration from environment variables
18
+ *
19
+ * Environment variables:
20
+ * - DB_PATH: LanceDB database path (default: ./lancedb/)
21
+ * - MODEL_NAME: Transformers.js model name (default: Xenova/all-MiniLM-L6-v2)
22
+ * - CACHE_DIR: Model cache directory (default: ./models/)
23
+ * - BASE_DIR: Document base directory (default: process.cwd())
24
+ * - MAX_FILE_SIZE: Maximum file size in bytes (default: 104857600)
25
+ * - RAG_MAX_DISTANCE: Quality filter max distance threshold
26
+ * - RAG_GROUPING: Quality filter grouping mode ('similar' | 'related')
27
+ * - RAG_HYBRID_WEIGHT: Hybrid search weight (0.0-1.0)
28
+ */
29
+ function buildRAGConfig(overrides) {
30
+ const config = {
31
+ dbPath: process.env['DB_PATH'] || overrides?.dbPath || DEFAULTS.dbPath,
32
+ modelName: process.env['MODEL_NAME'] || overrides?.modelName || DEFAULTS.modelName,
33
+ cacheDir: process.env['CACHE_DIR'] || overrides?.cacheDir || DEFAULTS.cacheDir,
34
+ baseDir: process.env['BASE_DIR'] || overrides?.baseDir || process.cwd(),
35
+ maxFileSize: Number.parseInt(process.env['MAX_FILE_SIZE'] || String(overrides?.maxFileSize || DEFAULTS.maxFileSize), 10),
36
+ };
37
+ // Add quality filter settings only if defined
38
+ const maxDistance = (0, config_parsers_js_1.parseMaxDistance)(process.env['RAG_MAX_DISTANCE']) ?? overrides?.maxDistance;
39
+ const grouping = (0, config_parsers_js_1.parseGroupingMode)(process.env['RAG_GROUPING']) ?? overrides?.grouping;
40
+ const hybridWeight = (0, config_parsers_js_1.parseHybridWeight)(process.env['RAG_HYBRID_WEIGHT']) ?? overrides?.hybridWeight;
41
+ if (maxDistance !== undefined) {
42
+ config.maxDistance = maxDistance;
43
+ }
44
+ if (grouping !== undefined) {
45
+ config.grouping = grouping;
46
+ }
47
+ if (hybridWeight !== undefined) {
48
+ config.hybridWeight = hybridWeight;
49
+ }
50
+ return config;
51
+ }
52
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/utils/config.ts"],"names":[],"mappings":";AAAA,+CAA+C;AAC/C,2EAA2E;;AAkD3E,wCA6BC;AA5ED,2DAA4F;AAwB5F;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,MAAM,EAAE,YAAY;IACpB,SAAS,EAAE,yBAAyB;IACpC,QAAQ,EAAE,WAAW;IACrB,WAAW,EAAE,SAAS,EAAE,QAAQ;CACxB,CAAA;AAEV;;;;;;;;;;;;GAYG;AACH,SAAgB,cAAc,CAAC,SAA8B;IAC3D,MAAM,MAAM,GAAc;QACxB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,SAAS,EAAE,MAAM,IAAI,QAAQ,CAAC,MAAM;QACtE,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,SAAS,EAAE,SAAS,IAAI,QAAQ,CAAC,SAAS;QAClF,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,SAAS,EAAE,QAAQ,IAAI,QAAQ,CAAC,QAAQ;QAC9E,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,GAAG,EAAE;QACvE,WAAW,EAAE,MAAM,CAAC,QAAQ,CAC1B,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,WAAW,IAAI,QAAQ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