rag-lite-ts 1.0.1 → 2.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 (204) hide show
  1. package/README.md +651 -109
  2. package/dist/cli/indexer.js +262 -46
  3. package/dist/cli/search.js +54 -32
  4. package/dist/cli.js +185 -28
  5. package/dist/config.d.ts +34 -73
  6. package/dist/config.js +50 -255
  7. package/dist/core/abstract-embedder.d.ts +125 -0
  8. package/dist/core/abstract-embedder.js +264 -0
  9. package/dist/core/actionable-error-messages.d.ts +60 -0
  10. package/dist/core/actionable-error-messages.js +397 -0
  11. package/dist/core/adapters.d.ts +93 -0
  12. package/dist/core/adapters.js +139 -0
  13. package/dist/core/batch-processing-optimizer.d.ts +155 -0
  14. package/dist/core/batch-processing-optimizer.js +541 -0
  15. package/dist/core/chunker.d.ts +119 -0
  16. package/dist/core/chunker.js +73 -0
  17. package/dist/core/cli-database-utils.d.ts +53 -0
  18. package/dist/core/cli-database-utils.js +239 -0
  19. package/dist/core/config.d.ts +102 -0
  20. package/dist/core/config.js +247 -0
  21. package/dist/core/content-errors.d.ts +111 -0
  22. package/dist/core/content-errors.js +362 -0
  23. package/dist/core/content-manager.d.ts +343 -0
  24. package/dist/core/content-manager.js +1504 -0
  25. package/dist/core/content-performance-optimizer.d.ts +150 -0
  26. package/dist/core/content-performance-optimizer.js +516 -0
  27. package/dist/core/content-resolver.d.ts +104 -0
  28. package/dist/core/content-resolver.js +285 -0
  29. package/dist/core/cross-modal-search.d.ts +164 -0
  30. package/dist/core/cross-modal-search.js +342 -0
  31. package/dist/core/database-connection-manager.d.ts +109 -0
  32. package/dist/core/database-connection-manager.js +304 -0
  33. package/dist/core/db.d.ts +245 -0
  34. package/dist/core/db.js +952 -0
  35. package/dist/core/embedder-factory.d.ts +176 -0
  36. package/dist/core/embedder-factory.js +338 -0
  37. package/dist/{error-handler.d.ts → core/error-handler.d.ts} +23 -2
  38. package/dist/{error-handler.js → core/error-handler.js} +51 -8
  39. package/dist/core/index.d.ts +59 -0
  40. package/dist/core/index.js +69 -0
  41. package/dist/core/ingestion.d.ts +213 -0
  42. package/dist/core/ingestion.js +812 -0
  43. package/dist/core/interfaces.d.ts +408 -0
  44. package/dist/core/interfaces.js +106 -0
  45. package/dist/core/lazy-dependency-loader.d.ts +152 -0
  46. package/dist/core/lazy-dependency-loader.js +453 -0
  47. package/dist/core/mode-detection-service.d.ts +150 -0
  48. package/dist/core/mode-detection-service.js +565 -0
  49. package/dist/core/mode-model-validator.d.ts +92 -0
  50. package/dist/core/mode-model-validator.js +203 -0
  51. package/dist/core/model-registry.d.ts +120 -0
  52. package/dist/core/model-registry.js +415 -0
  53. package/dist/core/model-validator.d.ts +217 -0
  54. package/dist/core/model-validator.js +782 -0
  55. package/dist/{path-manager.d.ts → core/path-manager.d.ts} +5 -0
  56. package/dist/{path-manager.js → core/path-manager.js} +5 -0
  57. package/dist/core/polymorphic-search-factory.d.ts +154 -0
  58. package/dist/core/polymorphic-search-factory.js +344 -0
  59. package/dist/core/raglite-paths.d.ts +121 -0
  60. package/dist/core/raglite-paths.js +145 -0
  61. package/dist/core/reranking-config.d.ts +42 -0
  62. package/dist/core/reranking-config.js +156 -0
  63. package/dist/core/reranking-factory.d.ts +92 -0
  64. package/dist/core/reranking-factory.js +591 -0
  65. package/dist/core/reranking-strategies.d.ts +325 -0
  66. package/dist/core/reranking-strategies.js +720 -0
  67. package/dist/core/resource-cleanup.d.ts +163 -0
  68. package/dist/core/resource-cleanup.js +371 -0
  69. package/dist/core/resource-manager.d.ts +212 -0
  70. package/dist/core/resource-manager.js +564 -0
  71. package/dist/core/search-pipeline.d.ts +111 -0
  72. package/dist/core/search-pipeline.js +287 -0
  73. package/dist/core/search.d.ts +131 -0
  74. package/dist/core/search.js +296 -0
  75. package/dist/core/streaming-operations.d.ts +145 -0
  76. package/dist/core/streaming-operations.js +409 -0
  77. package/dist/core/types.d.ts +66 -0
  78. package/dist/core/types.js +6 -0
  79. package/dist/core/universal-embedder.d.ts +177 -0
  80. package/dist/core/universal-embedder.js +139 -0
  81. package/dist/core/validation-messages.d.ts +99 -0
  82. package/dist/core/validation-messages.js +334 -0
  83. package/dist/{vector-index.d.ts → core/vector-index.d.ts} +4 -0
  84. package/dist/{vector-index.js → core/vector-index.js} +21 -3
  85. package/dist/dom-polyfills.d.ts +6 -0
  86. package/dist/dom-polyfills.js +40 -0
  87. package/dist/factories/index.d.ts +43 -0
  88. package/dist/factories/index.js +44 -0
  89. package/dist/factories/text-factory.d.ts +560 -0
  90. package/dist/factories/text-factory.js +968 -0
  91. package/dist/file-processor.d.ts +90 -4
  92. package/dist/file-processor.js +723 -20
  93. package/dist/index-manager.d.ts +3 -2
  94. package/dist/index-manager.js +13 -11
  95. package/dist/index.d.ts +72 -8
  96. package/dist/index.js +102 -16
  97. package/dist/indexer.js +1 -1
  98. package/dist/ingestion.d.ts +44 -154
  99. package/dist/ingestion.js +75 -671
  100. package/dist/mcp-server.d.ts +35 -3
  101. package/dist/mcp-server.js +1186 -79
  102. package/dist/multimodal/clip-embedder.d.ts +314 -0
  103. package/dist/multimodal/clip-embedder.js +945 -0
  104. package/dist/multimodal/index.d.ts +6 -0
  105. package/dist/multimodal/index.js +6 -0
  106. package/dist/preprocess.js +1 -1
  107. package/dist/run-error-recovery-tests.d.ts +7 -0
  108. package/dist/run-error-recovery-tests.js +101 -0
  109. package/dist/search-standalone.js +1 -1
  110. package/dist/search.d.ts +51 -69
  111. package/dist/search.js +117 -412
  112. package/dist/test-utils.d.ts +8 -26
  113. package/dist/text/chunker.d.ts +33 -0
  114. package/dist/{chunker.js → text/chunker.js} +98 -75
  115. package/dist/{embedder.d.ts → text/embedder.d.ts} +22 -1
  116. package/dist/{embedder.js → text/embedder.js} +84 -10
  117. package/dist/text/index.d.ts +8 -0
  118. package/dist/text/index.js +9 -0
  119. package/dist/text/preprocessors/index.d.ts +17 -0
  120. package/dist/text/preprocessors/index.js +38 -0
  121. package/dist/text/preprocessors/mdx.d.ts +25 -0
  122. package/dist/text/preprocessors/mdx.js +101 -0
  123. package/dist/text/preprocessors/mermaid.d.ts +68 -0
  124. package/dist/text/preprocessors/mermaid.js +330 -0
  125. package/dist/text/preprocessors/registry.d.ts +56 -0
  126. package/dist/text/preprocessors/registry.js +180 -0
  127. package/dist/text/reranker.d.ts +59 -0
  128. package/dist/{reranker.js → text/reranker.js} +138 -53
  129. package/dist/text/sentence-transformer-embedder.d.ts +96 -0
  130. package/dist/text/sentence-transformer-embedder.js +340 -0
  131. package/dist/{tokenizer.d.ts → text/tokenizer.d.ts} +1 -0
  132. package/dist/{tokenizer.js → text/tokenizer.js} +7 -2
  133. package/dist/types.d.ts +40 -1
  134. package/dist/utils/vector-math.d.ts +31 -0
  135. package/dist/utils/vector-math.js +70 -0
  136. package/package.json +16 -4
  137. package/dist/api-errors.d.ts.map +0 -1
  138. package/dist/api-errors.js.map +0 -1
  139. package/dist/chunker.d.ts +0 -47
  140. package/dist/chunker.d.ts.map +0 -1
  141. package/dist/chunker.js.map +0 -1
  142. package/dist/cli/indexer.d.ts.map +0 -1
  143. package/dist/cli/indexer.js.map +0 -1
  144. package/dist/cli/search.d.ts.map +0 -1
  145. package/dist/cli/search.js.map +0 -1
  146. package/dist/cli.d.ts.map +0 -1
  147. package/dist/cli.js.map +0 -1
  148. package/dist/config.d.ts.map +0 -1
  149. package/dist/config.js.map +0 -1
  150. package/dist/db.d.ts +0 -90
  151. package/dist/db.d.ts.map +0 -1
  152. package/dist/db.js +0 -340
  153. package/dist/db.js.map +0 -1
  154. package/dist/embedder.d.ts.map +0 -1
  155. package/dist/embedder.js.map +0 -1
  156. package/dist/error-handler.d.ts.map +0 -1
  157. package/dist/error-handler.js.map +0 -1
  158. package/dist/file-processor.d.ts.map +0 -1
  159. package/dist/file-processor.js.map +0 -1
  160. package/dist/index-manager.d.ts.map +0 -1
  161. package/dist/index-manager.js.map +0 -1
  162. package/dist/index.d.ts.map +0 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist/indexer.d.ts.map +0 -1
  165. package/dist/indexer.js.map +0 -1
  166. package/dist/ingestion.d.ts.map +0 -1
  167. package/dist/ingestion.js.map +0 -1
  168. package/dist/mcp-server.d.ts.map +0 -1
  169. package/dist/mcp-server.js.map +0 -1
  170. package/dist/path-manager.d.ts.map +0 -1
  171. package/dist/path-manager.js.map +0 -1
  172. package/dist/preprocess.d.ts.map +0 -1
  173. package/dist/preprocess.js.map +0 -1
  174. package/dist/preprocessors/index.d.ts.map +0 -1
  175. package/dist/preprocessors/index.js.map +0 -1
  176. package/dist/preprocessors/mdx.d.ts.map +0 -1
  177. package/dist/preprocessors/mdx.js.map +0 -1
  178. package/dist/preprocessors/mermaid.d.ts.map +0 -1
  179. package/dist/preprocessors/mermaid.js.map +0 -1
  180. package/dist/preprocessors/registry.d.ts.map +0 -1
  181. package/dist/preprocessors/registry.js.map +0 -1
  182. package/dist/reranker.d.ts +0 -40
  183. package/dist/reranker.d.ts.map +0 -1
  184. package/dist/reranker.js.map +0 -1
  185. package/dist/resource-manager-demo.d.ts +0 -7
  186. package/dist/resource-manager-demo.d.ts.map +0 -1
  187. package/dist/resource-manager-demo.js +0 -52
  188. package/dist/resource-manager-demo.js.map +0 -1
  189. package/dist/resource-manager.d.ts +0 -129
  190. package/dist/resource-manager.d.ts.map +0 -1
  191. package/dist/resource-manager.js +0 -389
  192. package/dist/resource-manager.js.map +0 -1
  193. package/dist/search-standalone.d.ts.map +0 -1
  194. package/dist/search-standalone.js.map +0 -1
  195. package/dist/search.d.ts.map +0 -1
  196. package/dist/search.js.map +0 -1
  197. package/dist/test-utils.d.ts.map +0 -1
  198. package/dist/test-utils.js.map +0 -1
  199. package/dist/tokenizer.d.ts.map +0 -1
  200. package/dist/tokenizer.js.map +0 -1
  201. package/dist/types.d.ts.map +0 -1
  202. package/dist/types.js.map +0 -1
  203. package/dist/vector-index.d.ts.map +0 -1
  204. package/dist/vector-index.js.map +0 -1
@@ -0,0 +1,247 @@
1
+ /**
2
+ * CORE MODULE — Shared between text-only (rag-lite-ts) and future multimodal (rag-lite-mm)
3
+ * Model-agnostic. No transformer or modality-specific logic.
4
+ */
5
+ import { homedir } from 'os';
6
+ import { join } from 'path';
7
+ /**
8
+ * Standard exit codes for different error conditions
9
+ */
10
+ export const EXIT_CODES = {
11
+ SUCCESS: 0,
12
+ GENERAL_ERROR: 1,
13
+ INVALID_ARGUMENTS: 2,
14
+ CONFIGURATION_ERROR: 3,
15
+ FILE_NOT_FOUND: 4,
16
+ DATABASE_ERROR: 5,
17
+ MODEL_ERROR: 6,
18
+ INDEX_ERROR: 7,
19
+ PERMISSION_ERROR: 8
20
+ };
21
+ /**
22
+ * Configuration validation error with specific exit code
23
+ */
24
+ export class ConfigurationError extends Error {
25
+ exitCode;
26
+ constructor(message, exitCode = EXIT_CODES.CONFIGURATION_ERROR) {
27
+ super(message);
28
+ this.exitCode = exitCode;
29
+ this.name = 'ConfigurationError';
30
+ }
31
+ }
32
+ /**
33
+ * Get the default model cache path as specified in the requirements
34
+ * @returns Default cache path (~/.raglite/models/)
35
+ */
36
+ export function getDefaultModelCachePath() {
37
+ return join(homedir(), '.raglite', 'models');
38
+ }
39
+ /**
40
+ * Validates core configuration fields
41
+ * @param config - Configuration object to validate
42
+ * @throws {ConfigurationError} If configuration is invalid
43
+ */
44
+ export function validateCoreConfig(config) {
45
+ if (!config || typeof config !== 'object') {
46
+ throw new ConfigurationError('Configuration must be an object');
47
+ }
48
+ // Check required string fields
49
+ const requiredStrings = ['db_file', 'index_file'];
50
+ for (const field of requiredStrings) {
51
+ if (!config[field] || typeof config[field] !== 'string') {
52
+ throw new ConfigurationError(`Configuration error: '${field}' must be a non-empty string.\n` +
53
+ `Current value: ${JSON.stringify(config[field])}\n` +
54
+ `Please check your configuration file.`);
55
+ }
56
+ }
57
+ // Validate path_storage_strategy
58
+ if (!['absolute', 'relative'].includes(config.path_storage_strategy)) {
59
+ throw new ConfigurationError(`Configuration error: 'path_storage_strategy' must be either 'absolute' or 'relative'.\n` +
60
+ `Current value: ${JSON.stringify(config.path_storage_strategy)}\n` +
61
+ `Please set it to 'absolute' or 'relative'.`);
62
+ }
63
+ // Check required numeric fields are positive
64
+ const requiredNumbers = ['chunk_size', 'chunk_overlap', 'batch_size', 'top_k'];
65
+ for (const field of requiredNumbers) {
66
+ if (typeof config[field] !== 'number' || config[field] <= 0) {
67
+ throw new ConfigurationError(`Configuration error: '${field}' must be a positive number.\n` +
68
+ `Current value: ${JSON.stringify(config[field])}\n` +
69
+ `Please ensure all numeric values are greater than 0.`);
70
+ }
71
+ }
72
+ // Validate optional model_cache_path field
73
+ if (config.model_cache_path !== undefined && (typeof config.model_cache_path !== 'string' || config.model_cache_path.trim() === '')) {
74
+ throw new ConfigurationError(`Configuration error: 'model_cache_path' must be a non-empty string when provided.\n` +
75
+ `Current value: ${JSON.stringify(config.model_cache_path)}\n` +
76
+ `Please provide a valid directory path or remove the field to use default caching.`);
77
+ }
78
+ // Validate chunk_overlap is less than chunk_size
79
+ if (config.chunk_overlap >= config.chunk_size) {
80
+ throw new ConfigurationError(`Configuration error: chunk_overlap (${config.chunk_overlap}) must be less than chunk_size (${config.chunk_size}).\n` +
81
+ `Recommended: Set chunk_overlap to about 20% of chunk_size (e.g., chunk_size: 250, chunk_overlap: 50).`);
82
+ }
83
+ // Validate reasonable ranges for performance
84
+ if (config.chunk_size > 1000) {
85
+ console.warn(`Warning: Large chunk_size (${config.chunk_size}) may impact performance. Recommended range: 200-400 tokens.`);
86
+ }
87
+ if (config.batch_size > 64) {
88
+ console.warn(`Warning: Large batch_size (${config.batch_size}) may cause memory issues. Recommended range: 8-32.`);
89
+ }
90
+ }
91
+ /**
92
+ * Get default configuration for different embedding models
93
+ * @param modelName - Name of the embedding model
94
+ * @returns Model-specific defaults
95
+ */
96
+ export function getModelDefaults(modelName) {
97
+ // Default configuration for most models
98
+ const defaults = {
99
+ dimensions: 384, // Most common dimension for sentence transformers
100
+ chunk_size: 250,
101
+ chunk_overlap: 50,
102
+ batch_size: 16
103
+ };
104
+ // Model-specific overrides based on model name heuristics
105
+ if (modelName) {
106
+ const normalizedName = modelName.toLowerCase();
107
+ // CLIP models - 512 dimensions
108
+ if (normalizedName.includes('clip')) {
109
+ defaults.dimensions = 512;
110
+ defaults.batch_size = 8;
111
+ }
112
+ // MPNet models - 768 dimensions
113
+ else if (normalizedName.includes('all-mpnet-base-v2')) {
114
+ defaults.dimensions = 768;
115
+ defaults.chunk_size = 400;
116
+ defaults.chunk_overlap = 80;
117
+ defaults.batch_size = 8;
118
+ }
119
+ else if (normalizedName.includes('mpnet') || normalizedName.includes('768')) {
120
+ defaults.dimensions = 768;
121
+ }
122
+ // Models with 512 in the name
123
+ else if (normalizedName.includes('512')) {
124
+ defaults.dimensions = 512;
125
+ }
126
+ // MiniLM and other 384-dimensional models (default)
127
+ else if (normalizedName.includes('384') || normalizedName.includes('minilm')) {
128
+ defaults.dimensions = 384;
129
+ }
130
+ }
131
+ return defaults;
132
+ }
133
+ /**
134
+ * Default core configuration object
135
+ * Model-agnostic settings that can be used by core modules
136
+ */
137
+ export const config = {
138
+ chunk_size: parseInt(process.env.RAG_CHUNK_SIZE || '250', 10),
139
+ chunk_overlap: parseInt(process.env.RAG_CHUNK_OVERLAP || '50', 10),
140
+ batch_size: parseInt(process.env.RAG_BATCH_SIZE || '16', 10),
141
+ top_k: parseInt(process.env.RAG_TOP_K || '10', 10),
142
+ db_file: process.env.RAG_DB_FILE || 'db.sqlite',
143
+ index_file: process.env.RAG_INDEX_FILE || 'vector-index.bin',
144
+ model_cache_path: process.env.RAG_MODEL_CACHE_PATH || getDefaultModelCachePath(),
145
+ path_storage_strategy: process.env.RAG_PATH_STORAGE_STRATEGY || 'relative',
146
+ embedding_model: process.env.RAG_EMBEDDING_MODEL || 'sentence-transformers/all-MiniLM-L6-v2',
147
+ rerank_enabled: process.env.RAG_RERANK_ENABLED === 'true',
148
+ preprocessing: { mode: 'balanced' }
149
+ };
150
+ /**
151
+ * Validate preprocessing configuration
152
+ */
153
+ export function validatePreprocessingConfig(config) {
154
+ if (!config || typeof config !== 'object') {
155
+ throw new ConfigurationError('Preprocessing configuration must be an object');
156
+ }
157
+ if (!config.mode || !['strict', 'balanced', 'rich'].includes(config.mode)) {
158
+ throw new ConfigurationError('preprocessing.mode must be one of: strict, balanced, rich');
159
+ }
160
+ // Validate overrides if present
161
+ if (config.overrides !== undefined) {
162
+ if (!config.overrides || typeof config.overrides !== 'object') {
163
+ throw new ConfigurationError('preprocessing.overrides must be an object when provided');
164
+ }
165
+ const validValues = ['strip', 'keep', 'placeholder', 'extract'];
166
+ // Validate MDX override
167
+ if (config.overrides.mdx !== undefined && !validValues.includes(config.overrides.mdx)) {
168
+ throw new ConfigurationError('preprocessing.overrides.mdx must be one of: strip, keep, placeholder');
169
+ }
170
+ // Validate Mermaid override
171
+ if (config.overrides.mermaid !== undefined && !validValues.includes(config.overrides.mermaid)) {
172
+ throw new ConfigurationError('preprocessing.overrides.mermaid must be one of: strip, keep, placeholder, extract');
173
+ }
174
+ // Validate code override
175
+ if (config.overrides.code !== undefined && !validValues.includes(config.overrides.code)) {
176
+ throw new ConfigurationError('preprocessing.overrides.code must be one of: strip, keep, placeholder');
177
+ }
178
+ }
179
+ }
180
+ /**
181
+ * Merge preprocessing configurations with mode defaults
182
+ */
183
+ export function mergePreprocessingConfig(config) {
184
+ const modeDefaults = {
185
+ strict: { mdx: 'strip', mermaid: 'strip', code: 'strip' },
186
+ balanced: { mdx: 'placeholder', mermaid: 'placeholder', code: 'keep' },
187
+ rich: { mdx: 'keep', mermaid: 'extract', code: 'keep' }
188
+ };
189
+ const defaults = modeDefaults[config.mode] || modeDefaults.balanced;
190
+ return {
191
+ ...defaults,
192
+ ...config.overrides
193
+ };
194
+ }
195
+ /**
196
+ * Utility function to handle unrecoverable errors with descriptive messages
197
+ * Logs error and exits immediately with appropriate exit code
198
+ * @param error - Error object or message
199
+ * @param context - Context where the error occurred
200
+ * @param exitCode - Exit code to use (defaults to GENERAL_ERROR)
201
+ */
202
+ export function handleUnrecoverableError(error, context, exitCode = EXIT_CODES.GENERAL_ERROR) {
203
+ const errorMessage = error instanceof Error ? error.message : String(error);
204
+ console.error(`\nFatal Error in ${context}:`);
205
+ console.error(errorMessage);
206
+ console.error('\nThe system cannot continue and will exit immediately.');
207
+ // Provide context-specific guidance
208
+ switch (exitCode) {
209
+ case EXIT_CODES.CONFIGURATION_ERROR:
210
+ console.error('\nPlease check your configuration and try again.');
211
+ break;
212
+ case EXIT_CODES.DATABASE_ERROR:
213
+ console.error('\nTry running "raglite rebuild" to fix database issues.');
214
+ break;
215
+ case EXIT_CODES.MODEL_ERROR:
216
+ console.error('\nEnsure you have internet connection for model download and sufficient disk space.');
217
+ break;
218
+ case EXIT_CODES.INDEX_ERROR:
219
+ console.error('\nTry running "raglite rebuild" to recreate the vector index.');
220
+ break;
221
+ case EXIT_CODES.FILE_NOT_FOUND:
222
+ console.error('\nPlease check that the specified files or directories exist and are accessible.');
223
+ break;
224
+ case EXIT_CODES.PERMISSION_ERROR:
225
+ console.error('\nPlease check file and directory permissions.');
226
+ break;
227
+ default:
228
+ console.error('\nIf this problem persists, please report it as a bug.');
229
+ }
230
+ process.exit(exitCode);
231
+ }
232
+ /**
233
+ * Utility function for safe error logging with context
234
+ * @param error - Error to log
235
+ * @param context - Context where error occurred
236
+ * @param skipError - Whether to skip this error and continue (default: false)
237
+ */
238
+ export function logError(error, context, skipError = false) {
239
+ const errorMessage = error instanceof Error ? error.message : String(error);
240
+ if (skipError) {
241
+ console.error(`Warning in ${context}: ${errorMessage} (skipping and continuing)`);
242
+ }
243
+ else {
244
+ console.error(`Error in ${context}: ${errorMessage}`);
245
+ }
246
+ }
247
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Content System Error Handling - Comprehensive error handling for unified content system
3
+ * Implements task 8.1: Add specific error types for content operations with clear guidance
4
+ * Requirements: 8.1, 8.2, 8.3, 8.6
5
+ */
6
+ import { APIError, ErrorFactory } from '../api-errors.js';
7
+ import { ErrorSeverity } from './error-handler.js';
8
+ /**
9
+ * Content-specific error types for unified content system operations
10
+ */
11
+ export declare class ContentNotFoundError extends APIError {
12
+ constructor(contentId: string, displayName?: string, context?: string);
13
+ }
14
+ /**
15
+ * Error when storage limits are exceeded
16
+ */
17
+ export declare class StorageLimitExceededError extends APIError {
18
+ constructor(currentUsageMB: number, limitMB: number, contentSizeMB: number, context?: string);
19
+ }
20
+ /**
21
+ * Error when content format is invalid or unsupported
22
+ */
23
+ export declare class InvalidContentFormatError extends APIError {
24
+ constructor(contentType: string, reason: string, context?: string);
25
+ private static getSuggestionsForContentType;
26
+ }
27
+ /**
28
+ * Error when content ingestion fails
29
+ */
30
+ export declare class ContentIngestionError extends APIError {
31
+ constructor(operation: string, reason: string, context?: string);
32
+ }
33
+ /**
34
+ * Error when content retrieval fails
35
+ */
36
+ export declare class ContentRetrievalError extends APIError {
37
+ constructor(contentId: string, format: string, reason: string, context?: string);
38
+ }
39
+ /**
40
+ * Error when content directory operations fail
41
+ */
42
+ export declare class ContentDirectoryError extends APIError {
43
+ constructor(operation: string, reason: string, context?: string);
44
+ }
45
+ /**
46
+ * Error when content deduplication fails
47
+ */
48
+ export declare class ContentDeduplicationError extends APIError {
49
+ constructor(reason: string, context?: string);
50
+ }
51
+ /**
52
+ * Enhanced error factory for content system operations
53
+ * Extends the base ErrorFactory with content-specific error handling
54
+ */
55
+ export declare class ContentErrorFactory extends ErrorFactory {
56
+ /**
57
+ * Create content-specific error from generic error
58
+ */
59
+ static createContentError(error: unknown, operation: string, context: string): APIError;
60
+ /**
61
+ * Create storage-related error with enhanced guidance
62
+ */
63
+ static createStorageError(error: unknown, context: string): APIError;
64
+ /**
65
+ * Create format validation error with specific guidance
66
+ */
67
+ static createFormatError(contentType: string, reason: string, context: string): InvalidContentFormatError;
68
+ }
69
+ /**
70
+ * Content system error handler with categorized error management
71
+ */
72
+ export declare class ContentErrorHandler {
73
+ /**
74
+ * Handle content operation errors with appropriate categorization
75
+ */
76
+ static handleContentError(error: unknown, operation: string, context: string, options?: {
77
+ severity?: ErrorSeverity;
78
+ skipError?: boolean;
79
+ showStack?: boolean;
80
+ }): never;
81
+ /**
82
+ * Get appropriate error category for content errors
83
+ */
84
+ private static getCategoryForError;
85
+ /**
86
+ * Validate content operation parameters and throw appropriate errors
87
+ */
88
+ static validateContentOperation(contentId?: string, format?: string, contentType?: string): void;
89
+ /**
90
+ * Create user-friendly error message for common content scenarios
91
+ */
92
+ static createUserFriendlyMessage(error: APIError): string;
93
+ }
94
+ /**
95
+ * Utility functions for content error handling
96
+ */
97
+ export declare const ContentErrorUtils: {
98
+ /**
99
+ * Check if an error is content-related
100
+ */
101
+ isContentError(error: unknown): error is APIError;
102
+ /**
103
+ * Extract content ID from error message
104
+ */
105
+ extractContentId(error: APIError): string | null;
106
+ /**
107
+ * Get recovery action for content error
108
+ */
109
+ getRecoveryAction(error: APIError): string;
110
+ };
111
+ //# sourceMappingURL=content-errors.d.ts.map