@cosmocoder/mcp-web-docs 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 (240) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +368 -0
  3. package/build/__mocks__/embeddings.d.ts +17 -0
  4. package/build/__mocks__/embeddings.js +66 -0
  5. package/build/__mocks__/embeddings.js.map +1 -0
  6. package/build/config.d.ts +44 -0
  7. package/build/config.js +158 -0
  8. package/build/config.js.map +1 -0
  9. package/build/config.test.d.ts +1 -0
  10. package/build/config.test.js +165 -0
  11. package/build/config.test.js.map +1 -0
  12. package/build/crawler/auth.d.ts +128 -0
  13. package/build/crawler/auth.js +546 -0
  14. package/build/crawler/auth.js.map +1 -0
  15. package/build/crawler/auth.test.d.ts +1 -0
  16. package/build/crawler/auth.test.js +174 -0
  17. package/build/crawler/auth.test.js.map +1 -0
  18. package/build/crawler/base.d.ts +24 -0
  19. package/build/crawler/base.js +149 -0
  20. package/build/crawler/base.js.map +1 -0
  21. package/build/crawler/base.test.d.ts +1 -0
  22. package/build/crawler/base.test.js +234 -0
  23. package/build/crawler/base.test.js.map +1 -0
  24. package/build/crawler/browser-config.d.ts +2 -0
  25. package/build/crawler/browser-config.js +29 -0
  26. package/build/crawler/browser-config.js.map +1 -0
  27. package/build/crawler/browser-config.test.d.ts +1 -0
  28. package/build/crawler/browser-config.test.js +56 -0
  29. package/build/crawler/browser-config.test.js.map +1 -0
  30. package/build/crawler/cheerio.d.ts +11 -0
  31. package/build/crawler/cheerio.js +134 -0
  32. package/build/crawler/cheerio.js.map +1 -0
  33. package/build/crawler/chromium.d.ts +21 -0
  34. package/build/crawler/chromium.js +596 -0
  35. package/build/crawler/chromium.js.map +1 -0
  36. package/build/crawler/content-extractor-types.d.ts +25 -0
  37. package/build/crawler/content-extractor-types.js +2 -0
  38. package/build/crawler/content-extractor-types.js.map +1 -0
  39. package/build/crawler/content-extractors.d.ts +9 -0
  40. package/build/crawler/content-extractors.js +9 -0
  41. package/build/crawler/content-extractors.js.map +1 -0
  42. package/build/crawler/content-utils.d.ts +2 -0
  43. package/build/crawler/content-utils.js +22 -0
  44. package/build/crawler/content-utils.js.map +1 -0
  45. package/build/crawler/content-utils.test.d.ts +1 -0
  46. package/build/crawler/content-utils.test.js +99 -0
  47. package/build/crawler/content-utils.test.js.map +1 -0
  48. package/build/crawler/crawlee-crawler.d.ts +63 -0
  49. package/build/crawler/crawlee-crawler.js +342 -0
  50. package/build/crawler/crawlee-crawler.js.map +1 -0
  51. package/build/crawler/crawlee-crawler.test.d.ts +1 -0
  52. package/build/crawler/crawlee-crawler.test.js +280 -0
  53. package/build/crawler/crawlee-crawler.test.js.map +1 -0
  54. package/build/crawler/default-extractor.d.ts +4 -0
  55. package/build/crawler/default-extractor.js +26 -0
  56. package/build/crawler/default-extractor.js.map +1 -0
  57. package/build/crawler/default-extractor.test.d.ts +1 -0
  58. package/build/crawler/default-extractor.test.js +200 -0
  59. package/build/crawler/default-extractor.test.js.map +1 -0
  60. package/build/crawler/default.d.ts +11 -0
  61. package/build/crawler/default.js +138 -0
  62. package/build/crawler/default.js.map +1 -0
  63. package/build/crawler/docs-crawler.d.ts +26 -0
  64. package/build/crawler/docs-crawler.js +97 -0
  65. package/build/crawler/docs-crawler.js.map +1 -0
  66. package/build/crawler/docs-crawler.test.d.ts +1 -0
  67. package/build/crawler/docs-crawler.test.js +185 -0
  68. package/build/crawler/docs-crawler.test.js.map +1 -0
  69. package/build/crawler/factory.d.ts +6 -0
  70. package/build/crawler/factory.js +83 -0
  71. package/build/crawler/factory.js.map +1 -0
  72. package/build/crawler/github-pages-extractor.d.ts +4 -0
  73. package/build/crawler/github-pages-extractor.js +33 -0
  74. package/build/crawler/github-pages-extractor.js.map +1 -0
  75. package/build/crawler/github-pages-extractor.test.d.ts +1 -0
  76. package/build/crawler/github-pages-extractor.test.js +184 -0
  77. package/build/crawler/github-pages-extractor.test.js.map +1 -0
  78. package/build/crawler/github.d.ts +20 -0
  79. package/build/crawler/github.js +181 -0
  80. package/build/crawler/github.js.map +1 -0
  81. package/build/crawler/github.test.d.ts +1 -0
  82. package/build/crawler/github.test.js +326 -0
  83. package/build/crawler/github.test.js.map +1 -0
  84. package/build/crawler/puppeteer.d.ts +16 -0
  85. package/build/crawler/puppeteer.js +191 -0
  86. package/build/crawler/puppeteer.js.map +1 -0
  87. package/build/crawler/queue-manager.d.ts +43 -0
  88. package/build/crawler/queue-manager.js +169 -0
  89. package/build/crawler/queue-manager.js.map +1 -0
  90. package/build/crawler/queue-manager.test.d.ts +1 -0
  91. package/build/crawler/queue-manager.test.js +509 -0
  92. package/build/crawler/queue-manager.test.js.map +1 -0
  93. package/build/crawler/site-rules.d.ts +11 -0
  94. package/build/crawler/site-rules.js +104 -0
  95. package/build/crawler/site-rules.js.map +1 -0
  96. package/build/crawler/site-rules.test.d.ts +1 -0
  97. package/build/crawler/site-rules.test.js +139 -0
  98. package/build/crawler/site-rules.test.js.map +1 -0
  99. package/build/crawler/storybook-extractor.d.ts +34 -0
  100. package/build/crawler/storybook-extractor.js +767 -0
  101. package/build/crawler/storybook-extractor.js.map +1 -0
  102. package/build/crawler/storybook-extractor.test.d.ts +1 -0
  103. package/build/crawler/storybook-extractor.test.js +491 -0
  104. package/build/crawler/storybook-extractor.test.js.map +1 -0
  105. package/build/embeddings/fastembed.d.ts +25 -0
  106. package/build/embeddings/fastembed.js +188 -0
  107. package/build/embeddings/fastembed.js.map +1 -0
  108. package/build/embeddings/fastembed.test.d.ts +1 -0
  109. package/build/embeddings/fastembed.test.js +307 -0
  110. package/build/embeddings/fastembed.test.js.map +1 -0
  111. package/build/embeddings/openai.d.ts +8 -0
  112. package/build/embeddings/openai.js +56 -0
  113. package/build/embeddings/openai.js.map +1 -0
  114. package/build/embeddings/types.d.ts +4 -0
  115. package/build/embeddings/types.js +2 -0
  116. package/build/embeddings/types.js.map +1 -0
  117. package/build/index.d.ts +2 -0
  118. package/build/index.js +1007 -0
  119. package/build/index.js.map +1 -0
  120. package/build/index.test.d.ts +1 -0
  121. package/build/index.test.js +364 -0
  122. package/build/index.test.js.map +1 -0
  123. package/build/indexing/queue-manager.d.ts +36 -0
  124. package/build/indexing/queue-manager.js +86 -0
  125. package/build/indexing/queue-manager.js.map +1 -0
  126. package/build/indexing/queue-manager.test.d.ts +1 -0
  127. package/build/indexing/queue-manager.test.js +257 -0
  128. package/build/indexing/queue-manager.test.js.map +1 -0
  129. package/build/indexing/status.d.ts +39 -0
  130. package/build/indexing/status.js +207 -0
  131. package/build/indexing/status.js.map +1 -0
  132. package/build/indexing/status.test.d.ts +1 -0
  133. package/build/indexing/status.test.js +246 -0
  134. package/build/indexing/status.test.js.map +1 -0
  135. package/build/processor/content.d.ts +16 -0
  136. package/build/processor/content.js +286 -0
  137. package/build/processor/content.js.map +1 -0
  138. package/build/processor/content.test.d.ts +1 -0
  139. package/build/processor/content.test.js +369 -0
  140. package/build/processor/content.test.js.map +1 -0
  141. package/build/processor/markdown.d.ts +11 -0
  142. package/build/processor/markdown.js +256 -0
  143. package/build/processor/markdown.js.map +1 -0
  144. package/build/processor/markdown.test.d.ts +1 -0
  145. package/build/processor/markdown.test.js +312 -0
  146. package/build/processor/markdown.test.js.map +1 -0
  147. package/build/processor/metadata-parser.d.ts +37 -0
  148. package/build/processor/metadata-parser.js +245 -0
  149. package/build/processor/metadata-parser.js.map +1 -0
  150. package/build/processor/metadata-parser.test.d.ts +1 -0
  151. package/build/processor/metadata-parser.test.js +357 -0
  152. package/build/processor/metadata-parser.test.js.map +1 -0
  153. package/build/processor/processor.d.ts +8 -0
  154. package/build/processor/processor.js +190 -0
  155. package/build/processor/processor.js.map +1 -0
  156. package/build/processor/processor.test.d.ts +1 -0
  157. package/build/processor/processor.test.js +357 -0
  158. package/build/processor/processor.test.js.map +1 -0
  159. package/build/rag/cache.d.ts +10 -0
  160. package/build/rag/cache.js +10 -0
  161. package/build/rag/cache.js.map +1 -0
  162. package/build/rag/code-generator.d.ts +11 -0
  163. package/build/rag/code-generator.js +30 -0
  164. package/build/rag/code-generator.js.map +1 -0
  165. package/build/rag/context-assembler.d.ts +23 -0
  166. package/build/rag/context-assembler.js +113 -0
  167. package/build/rag/context-assembler.js.map +1 -0
  168. package/build/rag/docs-search.d.ts +55 -0
  169. package/build/rag/docs-search.js +380 -0
  170. package/build/rag/docs-search.js.map +1 -0
  171. package/build/rag/pipeline.d.ts +26 -0
  172. package/build/rag/pipeline.js +91 -0
  173. package/build/rag/pipeline.js.map +1 -0
  174. package/build/rag/query-processor.d.ts +14 -0
  175. package/build/rag/query-processor.js +57 -0
  176. package/build/rag/query-processor.js.map +1 -0
  177. package/build/rag/reranker.d.ts +55 -0
  178. package/build/rag/reranker.js +210 -0
  179. package/build/rag/reranker.js.map +1 -0
  180. package/build/rag/response-generator.d.ts +20 -0
  181. package/build/rag/response-generator.js +101 -0
  182. package/build/rag/response-generator.js.map +1 -0
  183. package/build/rag/retriever.d.ts +19 -0
  184. package/build/rag/retriever.js +111 -0
  185. package/build/rag/retriever.js.map +1 -0
  186. package/build/rag/validator.d.ts +22 -0
  187. package/build/rag/validator.js +128 -0
  188. package/build/rag/validator.js.map +1 -0
  189. package/build/rag/version-manager.d.ts +23 -0
  190. package/build/rag/version-manager.js +98 -0
  191. package/build/rag/version-manager.js.map +1 -0
  192. package/build/setupTests.d.ts +4 -0
  193. package/build/setupTests.js +50 -0
  194. package/build/setupTests.js.map +1 -0
  195. package/build/storage/storage.d.ts +38 -0
  196. package/build/storage/storage.js +700 -0
  197. package/build/storage/storage.js.map +1 -0
  198. package/build/storage/storage.test.d.ts +1 -0
  199. package/build/storage/storage.test.js +338 -0
  200. package/build/storage/storage.test.js.map +1 -0
  201. package/build/types/rag.d.ts +27 -0
  202. package/build/types/rag.js +2 -0
  203. package/build/types/rag.js.map +1 -0
  204. package/build/types.d.ts +120 -0
  205. package/build/types.js +2 -0
  206. package/build/types.js.map +1 -0
  207. package/build/util/content-utils.d.ts +31 -0
  208. package/build/util/content-utils.js +120 -0
  209. package/build/util/content-utils.js.map +1 -0
  210. package/build/util/content.d.ts +1 -0
  211. package/build/util/content.js +16 -0
  212. package/build/util/content.js.map +1 -0
  213. package/build/util/docs.d.ts +1 -0
  214. package/build/util/docs.js +26 -0
  215. package/build/util/docs.js.map +1 -0
  216. package/build/util/docs.test.d.ts +1 -0
  217. package/build/util/docs.test.js +49 -0
  218. package/build/util/docs.test.js.map +1 -0
  219. package/build/util/favicon.d.ts +6 -0
  220. package/build/util/favicon.js +88 -0
  221. package/build/util/favicon.js.map +1 -0
  222. package/build/util/favicon.test.d.ts +1 -0
  223. package/build/util/favicon.test.js +140 -0
  224. package/build/util/favicon.test.js.map +1 -0
  225. package/build/util/logger.d.ts +17 -0
  226. package/build/util/logger.js +72 -0
  227. package/build/util/logger.js.map +1 -0
  228. package/build/util/logger.test.d.ts +1 -0
  229. package/build/util/logger.test.js +46 -0
  230. package/build/util/logger.test.js.map +1 -0
  231. package/build/util/security.d.ts +312 -0
  232. package/build/util/security.js +719 -0
  233. package/build/util/security.js.map +1 -0
  234. package/build/util/security.test.d.ts +1 -0
  235. package/build/util/security.test.js +524 -0
  236. package/build/util/security.test.js.map +1 -0
  237. package/build/util/site-detector.d.ts +22 -0
  238. package/build/util/site-detector.js +42 -0
  239. package/build/util/site-detector.js.map +1 -0
  240. package/package.json +112 -0
@@ -0,0 +1,46 @@
1
+ import { logger } from './logger.js';
2
+ describe('Logger', () => {
3
+ describe('API surface', () => {
4
+ it.each(['debug', 'info', 'warn', 'error'])('should have %s method', (method) => {
5
+ expect(typeof logger[method]).toBe('function');
6
+ });
7
+ });
8
+ describe('methods do not throw', () => {
9
+ it.each(['debug', 'info', 'warn', 'error'])('should not throw when calling %s with string', (method) => {
10
+ expect(() => logger[method]('Test message')).not.toThrow();
11
+ });
12
+ it('should not throw when calling with multiple arguments', () => {
13
+ expect(() => logger.error('Multiple', 'arguments', 123, true)).not.toThrow();
14
+ });
15
+ it('should not throw when calling with Error object', () => {
16
+ const error = new Error('Test error');
17
+ expect(() => logger.error('Got error:', error)).not.toThrow();
18
+ });
19
+ it('should not throw when calling with nested object', () => {
20
+ const obj = { nested: { deep: { value: true } } };
21
+ expect(() => logger.info('Object:', obj)).not.toThrow();
22
+ });
23
+ it('should not throw when calling with circular reference', () => {
24
+ const circular = {};
25
+ circular.self = circular;
26
+ expect(() => logger.error('Circular:', circular)).not.toThrow();
27
+ });
28
+ it('should not throw when calling with null/undefined', () => {
29
+ expect(() => logger.info('Values:', null, undefined)).not.toThrow();
30
+ });
31
+ it('should not throw when calling with empty string', () => {
32
+ expect(() => logger.info('')).not.toThrow();
33
+ });
34
+ it('should not throw when calling with unicode', () => {
35
+ expect(() => logger.info('Unicode: 你好世界 🌍')).not.toThrow();
36
+ });
37
+ it('should not throw when calling with special characters', () => {
38
+ expect(() => logger.info('Special: <>&"\' \n\t')).not.toThrow();
39
+ });
40
+ it('should not throw when calling with very long message', () => {
41
+ const longMessage = 'a'.repeat(10000);
42
+ expect(() => logger.info(longMessage)).not.toThrow();
43
+ });
44
+ });
45
+ });
46
+ //# sourceMappingURL=logger.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.test.js","sourceRoot":"","sources":["../../src/util/logger.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;QAC3B,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAU,CAAC,CAAC,uBAAuB,EAAE,CAAC,MAAM,EAAE,EAAE;YACvF,MAAM,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EA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3
+ * Handles encryption, input sanitization, and validation
4
+ */
5
+ import { z } from 'zod';
6
+ /**
7
+ * Encrypt sensitive data using AES-256-GCM
8
+ * @param plaintext - Data to encrypt
9
+ * @returns Encrypted data as base64 string with embedded IV, salt, and auth tag
10
+ */
11
+ export declare function encryptData(plaintext: string): string;
12
+ /**
13
+ * Decrypt data encrypted with encryptData
14
+ * @param encryptedData - Base64 encoded encrypted data
15
+ * @returns Decrypted plaintext
16
+ */
17
+ export declare function decryptData(encryptedData: string): string;
18
+ /**
19
+ * Escape special characters for LanceDB filter expressions
20
+ * Prevents SQL/filter injection attacks
21
+ * @param value - User-provided value to escape
22
+ * @returns Escaped value safe for use in filter expressions
23
+ */
24
+ export declare function escapeFilterValue(value: string): string;
25
+ /**
26
+ * Validate and sanitize a URL for safe usage
27
+ * Prevents SSRF attacks by blocking private/internal networks
28
+ * @param urlString - URL to validate
29
+ * @returns Validated URL object
30
+ * @throws Error if URL is invalid or points to private network
31
+ */
32
+ export declare function validatePublicUrl(urlString: string): URL;
33
+ /**
34
+ * Check if a regex pattern is safe (not vulnerable to ReDoS)
35
+ * Uses safe-regex2 from https://github.com/fastify/safe-regex2
36
+ * @param pattern - Regex pattern string to check
37
+ * @returns true if pattern is safe, false if potentially dangerous
38
+ */
39
+ export declare function isSafeRegex(pattern: string): boolean;
40
+ /**
41
+ * Create a safe RegExp from user input with ReDoS protection
42
+ * @param pattern - User-provided regex pattern
43
+ * @param flags - Optional regex flags
44
+ * @returns RegExp object
45
+ * @throws Error if pattern is unsafe or invalid
46
+ */
47
+ export declare function createSafeRegex(pattern: string, flags?: string): RegExp;
48
+ /**
49
+ * Schema for browser storage state (cookies and localStorage)
50
+ */
51
+ export declare const StorageStateSchema: z.ZodObject<{
52
+ cookies: z.ZodArray<z.ZodObject<{
53
+ name: z.ZodString;
54
+ value: z.ZodString;
55
+ domain: z.ZodString;
56
+ path: z.ZodString;
57
+ expires: z.ZodOptional<z.ZodNumber>;
58
+ httpOnly: z.ZodOptional<z.ZodBoolean>;
59
+ secure: z.ZodOptional<z.ZodBoolean>;
60
+ sameSite: z.ZodOptional<z.ZodEnum<{
61
+ Strict: "Strict";
62
+ Lax: "Lax";
63
+ None: "None";
64
+ }>>;
65
+ }, z.core.$strip>>;
66
+ origins: z.ZodOptional<z.ZodArray<z.ZodObject<{
67
+ origin: z.ZodString;
68
+ localStorage: z.ZodArray<z.ZodObject<{
69
+ name: z.ZodString;
70
+ value: z.ZodString;
71
+ }, z.core.$strip>>;
72
+ }, z.core.$strip>>>;
73
+ }, z.core.$strip>;
74
+ export type ValidatedStorageState = z.infer<typeof StorageStateSchema>;
75
+ /**
76
+ * Schema for stored session data
77
+ */
78
+ export declare const StoredSessionSchema: z.ZodObject<{
79
+ domain: z.ZodString;
80
+ storageState: z.ZodString;
81
+ createdAt: z.ZodString;
82
+ browser: z.ZodEnum<{
83
+ chromium: "chromium";
84
+ chrome: "chrome";
85
+ firefox: "firefox";
86
+ webkit: "webkit";
87
+ edge: "edge";
88
+ }>;
89
+ version: z.ZodLiteral<2>;
90
+ }, z.core.$strip>;
91
+ /** Validated stored session type */
92
+ export type ValidatedStoredSession = z.infer<typeof StoredSessionSchema>;
93
+ /**
94
+ * Schema for GitHub API file response
95
+ */
96
+ export declare const GitHubFileSchema: z.ZodObject<{
97
+ path: z.ZodString;
98
+ type: z.ZodEnum<{
99
+ file: "file";
100
+ dir: "dir";
101
+ }>;
102
+ url: z.ZodString;
103
+ content: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$strip>;
105
+ export declare const GitHubFilesArraySchema: z.ZodArray<z.ZodObject<{
106
+ path: z.ZodString;
107
+ type: z.ZodEnum<{
108
+ file: "file";
109
+ dir: "dir";
110
+ }>;
111
+ url: z.ZodString;
112
+ content: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$strip>>;
114
+ export type ValidatedGitHubFile = z.infer<typeof GitHubFileSchema>;
115
+ /**
116
+ * Safely parse JSON with schema validation
117
+ * @param jsonString - JSON string to parse
118
+ * @param schema - Zod schema to validate against
119
+ * @returns Validated and typed data
120
+ * @throws Error if JSON is invalid or doesn't match schema
121
+ */
122
+ export declare function safeJsonParse<T>(jsonString: string, schema: z.ZodSchema<T>): T;
123
+ /**
124
+ * Generate a secure hash for cache keys or identifiers
125
+ * @param input - String to hash
126
+ * @returns SHA-256 hash as hex string
127
+ */
128
+ export declare function secureHash(input: string): string;
129
+ /**
130
+ * Schema for add_documentation tool arguments
131
+ */
132
+ export declare const AddDocumentationArgsSchema: z.ZodObject<{
133
+ url: z.ZodString;
134
+ title: z.ZodOptional<z.ZodString>;
135
+ id: z.ZodOptional<z.ZodString>;
136
+ pathPrefix: z.ZodOptional<z.ZodString>;
137
+ auth: z.ZodOptional<z.ZodObject<{
138
+ requiresAuth: z.ZodOptional<z.ZodBoolean>;
139
+ browser: z.ZodOptional<z.ZodEnum<{
140
+ chromium: "chromium";
141
+ chrome: "chrome";
142
+ firefox: "firefox";
143
+ webkit: "webkit";
144
+ edge: "edge";
145
+ }>>;
146
+ loginUrl: z.ZodOptional<z.ZodString>;
147
+ loginSuccessPattern: z.ZodOptional<z.ZodString>;
148
+ loginSuccessSelector: z.ZodOptional<z.ZodString>;
149
+ loginTimeoutSecs: z.ZodOptional<z.ZodNumber>;
150
+ }, z.core.$strip>>;
151
+ }, z.core.$strip>;
152
+ export type AddDocumentationArgs = z.infer<typeof AddDocumentationArgsSchema>;
153
+ /**
154
+ * Schema for authenticate tool arguments
155
+ */
156
+ export declare const AuthenticateArgsSchema: z.ZodObject<{
157
+ url: z.ZodString;
158
+ browser: z.ZodOptional<z.ZodEnum<{
159
+ chromium: "chromium";
160
+ chrome: "chrome";
161
+ firefox: "firefox";
162
+ webkit: "webkit";
163
+ edge: "edge";
164
+ }>>;
165
+ loginUrl: z.ZodOptional<z.ZodString>;
166
+ loginTimeoutSecs: z.ZodOptional<z.ZodNumber>;
167
+ }, z.core.$strip>;
168
+ export type AuthenticateArgs = z.infer<typeof AuthenticateArgsSchema>;
169
+ /**
170
+ * Schema for clear_auth tool arguments
171
+ */
172
+ export declare const ClearAuthArgsSchema: z.ZodObject<{
173
+ url: z.ZodString;
174
+ }, z.core.$strip>;
175
+ export type ClearAuthArgs = z.infer<typeof ClearAuthArgsSchema>;
176
+ /**
177
+ * Schema for search_documentation tool arguments
178
+ */
179
+ export declare const SearchDocumentationArgsSchema: z.ZodObject<{
180
+ query: z.ZodString;
181
+ url: z.ZodOptional<z.ZodString>;
182
+ limit: z.ZodOptional<z.ZodNumber>;
183
+ }, z.core.$strip>;
184
+ export type SearchDocumentationArgs = z.infer<typeof SearchDocumentationArgsSchema>;
185
+ /**
186
+ * Schema for reindex_documentation tool arguments
187
+ */
188
+ export declare const ReindexDocumentationArgsSchema: z.ZodObject<{
189
+ url: z.ZodString;
190
+ }, z.core.$strip>;
191
+ export type ReindexDocumentationArgs = z.infer<typeof ReindexDocumentationArgsSchema>;
192
+ /**
193
+ * Schema for delete_documentation tool arguments
194
+ */
195
+ export declare const DeleteDocumentationArgsSchema: z.ZodObject<{
196
+ url: z.ZodString;
197
+ clearAuth: z.ZodOptional<z.ZodBoolean>;
198
+ }, z.core.$strip>;
199
+ export type DeleteDocumentationArgs = z.infer<typeof DeleteDocumentationArgsSchema>;
200
+ /**
201
+ * Validate MCP tool arguments against a schema
202
+ * @param args - Raw arguments from MCP request
203
+ * @param schema - Zod schema to validate against
204
+ * @returns Validated and typed arguments
205
+ * @throws Error with user-friendly message if validation fails
206
+ */
207
+ export declare function validateToolArgs<T>(args: Record<string, unknown> | undefined, schema: z.ZodSchema<T>): T;
208
+ /**
209
+ * Sanitize an error message for safe return to clients.
210
+ * Removes sensitive information like file paths, credentials, and system details.
211
+ * @param error - The error to sanitize
212
+ * @returns A safe error message
213
+ */
214
+ export declare function sanitizeErrorMessage(error: unknown): string;
215
+ /**
216
+ * Redact sensitive information from log messages.
217
+ * Use this before logging any data that might contain credentials.
218
+ * @param data - The data to sanitize for logging
219
+ * @returns Sanitized string safe for logging
220
+ */
221
+ export declare function redactForLogging(data: unknown): string;
222
+ /**
223
+ * Result of prompt injection detection
224
+ */
225
+ export interface PromptInjectionResult {
226
+ /** Whether any injection patterns were detected */
227
+ hasInjection: boolean;
228
+ /** Highest severity level found */
229
+ maxSeverity: 'high' | 'medium' | 'low' | 'none';
230
+ /** List of detected patterns */
231
+ detections: Array<{
232
+ severity: 'high' | 'medium' | 'low';
233
+ description: string;
234
+ match: string;
235
+ }>;
236
+ }
237
+ /**
238
+ * Detect potential prompt injection patterns in content using vard.
239
+ * Uses the vard package for robust, performant detection of:
240
+ * - Instruction overrides ("ignore all previous instructions")
241
+ * - Role manipulation ("you are now a...")
242
+ * - Delimiter injection ([SYSTEM], <|im_start|>)
243
+ * - System prompt leaks ("reveal your instructions")
244
+ * - Encoding attacks (base64, homoglyphs, unicode escapes)
245
+ *
246
+ * NOTE: Code blocks are stripped before detection to avoid false positives
247
+ * from code examples (especially common in AI/LLM documentation).
248
+ *
249
+ * @param content - The content to scan
250
+ * @returns Detection results with severity and matched patterns
251
+ * @see https://github.com/andersmyrmel/vard
252
+ */
253
+ export declare function detectPromptInjection(content: string): PromptInjectionResult;
254
+ /**
255
+ * Marker to wrap content indicating it's from an external untrusted source.
256
+ * This helps AI assistants understand the content should be treated with caution.
257
+ */
258
+ export declare const EXTERNAL_CONTENT_MARKER: {
259
+ prefix: string;
260
+ suffix: string;
261
+ };
262
+ /**
263
+ * Wrap content with external source markers to indicate it's from an untrusted source.
264
+ * @param content - The content to wrap
265
+ * @param source - Optional source URL for attribution
266
+ * @returns Content wrapped with safety markers
267
+ */
268
+ export declare function wrapExternalContent(content: string, source?: string): string;
269
+ /**
270
+ * Add injection warnings to content if prompt injection patterns are detected.
271
+ * @param content - The content to check
272
+ * @param detectionResult - Result from detectPromptInjection
273
+ * @returns Content with warnings prepended if injections detected
274
+ */
275
+ export declare function addInjectionWarnings(content: string, detectionResult: PromptInjectionResult): string;
276
+ /**
277
+ * Result of login page detection
278
+ */
279
+ export interface LoginPageDetectionResult {
280
+ /** Whether this appears to be a login page */
281
+ isLoginPage: boolean;
282
+ /** Confidence level (0-1) based on number of indicators matched */
283
+ confidence: number;
284
+ /** Detected reasons (for logging/debugging) */
285
+ reasons: string[];
286
+ }
287
+ /**
288
+ * Detect if a URL looks like a login/authentication page.
289
+ * @param url - The URL to check
290
+ * @returns Whether the URL pattern suggests a login page
291
+ */
292
+ export declare function isLoginPageUrl(url: string): boolean;
293
+ /**
294
+ * Detect if page content suggests a login page.
295
+ * This is a heuristic check - it counts how many login-related
296
+ * indicators are present in the content.
297
+ *
298
+ * @param content - The page's text content
299
+ * @param url - The page URL (for additional URL-based detection)
300
+ * @returns Detection result with confidence score
301
+ */
302
+ export declare function detectLoginPage(content: string, url: string): LoginPageDetectionResult;
303
+ /**
304
+ * Error thrown when authentication session has expired.
305
+ * This allows callers to handle session expiration gracefully.
306
+ */
307
+ export declare class SessionExpiredError extends Error {
308
+ readonly detectedUrl: string;
309
+ readonly expectedUrl: string;
310
+ readonly detectionResult: LoginPageDetectionResult;
311
+ constructor(message: string, expectedUrl: string, detectedUrl: string, detectionResult: LoginPageDetectionResult);
312
+ }