@j0hanz/superfetch 1.0.6 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +228 -36
- package/dist/config/index.d.ts +10 -5
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +73 -19
- package/dist/config/index.js.map +1 -1
- package/dist/config/types.d.ts +98 -57
- package/dist/config/types.d.ts.map +1 -1
- package/dist/errors/app-error.d.ts +4 -28
- package/dist/errors/app-error.d.ts.map +1 -1
- package/dist/errors/app-error.js +10 -51
- package/dist/errors/app-error.js.map +1 -1
- package/dist/index.js +10 -55
- package/dist/index.js.map +1 -1
- package/dist/middleware/error-handler.d.ts +2 -2
- package/dist/middleware/error-handler.d.ts.map +1 -1
- package/dist/middleware/error-handler.js +12 -14
- package/dist/middleware/error-handler.js.map +1 -1
- package/dist/middleware/rate-limiter.d.ts.map +1 -1
- package/dist/middleware/rate-limiter.js +0 -8
- package/dist/middleware/rate-limiter.js.map +1 -1
- package/dist/parsers/base-html-element-parser.d.ts +43 -0
- package/dist/parsers/base-html-element-parser.d.ts.map +1 -0
- package/dist/parsers/base-html-element-parser.js +59 -0
- package/dist/parsers/base-html-element-parser.js.map +1 -0
- package/dist/parsers/heading-element-parser.d.ts +14 -0
- package/dist/parsers/heading-element-parser.d.ts.map +1 -0
- package/dist/parsers/heading-element-parser.js +26 -0
- package/dist/parsers/heading-element-parser.js.map +1 -0
- package/dist/parsers/image-element-parser.d.ts +16 -0
- package/dist/parsers/image-element-parser.d.ts.map +1 -0
- package/dist/parsers/image-element-parser.js +33 -0
- package/dist/parsers/image-element-parser.js.map +1 -0
- package/dist/parsers/link-element-parser.d.ts +15 -0
- package/dist/parsers/link-element-parser.d.ts.map +1 -0
- package/dist/parsers/link-element-parser.js +28 -0
- package/dist/parsers/link-element-parser.js.map +1 -0
- package/dist/parsers/open-graph-parser.d.ts +17 -0
- package/dist/parsers/open-graph-parser.d.ts.map +1 -0
- package/dist/parsers/open-graph-parser.js +41 -0
- package/dist/parsers/open-graph-parser.js.map +1 -0
- package/dist/parsers/schema-org-parser.d.ts +17 -0
- package/dist/parsers/schema-org-parser.d.ts.map +1 -0
- package/dist/parsers/schema-org-parser.js +32 -0
- package/dist/parsers/schema-org-parser.js.map +1 -0
- package/dist/parsers/standard-meta-parser.d.ts +18 -0
- package/dist/parsers/standard-meta-parser.d.ts.map +1 -0
- package/dist/parsers/standard-meta-parser.js +32 -0
- package/dist/parsers/standard-meta-parser.js.map +1 -0
- package/dist/parsers/twitter-card-parser.d.ts +17 -0
- package/dist/parsers/twitter-card-parser.d.ts.map +1 -0
- package/dist/parsers/twitter-card-parser.js +41 -0
- package/dist/parsers/twitter-card-parser.js.map +1 -0
- package/dist/resources/cached-content.d.ts +0 -1
- package/dist/resources/cached-content.d.ts.map +1 -1
- package/dist/resources/cached-content.js +3 -9
- package/dist/resources/cached-content.js.map +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +8 -8
- package/dist/resources/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +10 -10
- package/dist/server.js.map +1 -1
- package/dist/services/cache.d.ts +0 -28
- package/dist/services/cache.d.ts.map +1 -1
- package/dist/services/cache.js +10 -173
- package/dist/services/cache.js.map +1 -1
- package/dist/services/extractor.d.ts +1 -11
- package/dist/services/extractor.d.ts.map +1 -1
- package/dist/services/extractor.js +86 -84
- package/dist/services/extractor.js.map +1 -1
- package/dist/services/fetcher.d.ts +2 -13
- package/dist/services/fetcher.d.ts.map +1 -1
- package/dist/services/fetcher.js +195 -211
- package/dist/services/fetcher.js.map +1 -1
- package/dist/services/logger.d.ts +5 -4
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +27 -42
- package/dist/services/logger.js.map +1 -1
- package/dist/services/parser.d.ts.map +1 -1
- package/dist/services/parser.js +35 -26
- package/dist/services/parser.js.map +1 -1
- package/dist/services/session-manager.d.ts +18 -0
- package/dist/services/session-manager.d.ts.map +1 -0
- package/dist/services/session-manager.js +73 -0
- package/dist/services/session-manager.js.map +1 -0
- package/dist/strategies/exponential-backoff-strategy.d.ts +13 -0
- package/dist/strategies/exponential-backoff-strategy.d.ts.map +1 -0
- package/dist/strategies/exponential-backoff-strategy.js +32 -0
- package/dist/strategies/exponential-backoff-strategy.js.map +1 -0
- package/dist/tools/handlers/fetch-links.tool.d.ts +2 -9
- package/dist/tools/handlers/fetch-links.tool.d.ts.map +1 -1
- package/dist/tools/handlers/fetch-links.tool.js +0 -1
- package/dist/tools/handlers/fetch-links.tool.js.map +1 -1
- package/dist/tools/handlers/fetch-markdown.tool.d.ts +5 -2
- package/dist/tools/handlers/fetch-markdown.tool.d.ts.map +1 -1
- package/dist/tools/handlers/fetch-markdown.tool.js +23 -33
- package/dist/tools/handlers/fetch-markdown.tool.js.map +1 -1
- package/dist/tools/handlers/fetch-url.tool.d.ts +2 -9
- package/dist/tools/handlers/fetch-url.tool.d.ts.map +1 -1
- package/dist/tools/handlers/fetch-url.tool.js +15 -20
- package/dist/tools/handlers/fetch-url.tool.js.map +1 -1
- package/dist/tools/handlers/fetch-urls.tool.d.ts +2 -9
- package/dist/tools/handlers/fetch-urls.tool.d.ts.map +1 -1
- package/dist/tools/handlers/fetch-urls.tool.js +124 -105
- package/dist/tools/handlers/fetch-urls.tool.js.map +1 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +0 -4
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/utils/common.d.ts +6 -7
- package/dist/tools/utils/common.d.ts.map +1 -1
- package/dist/tools/utils/common.js +8 -8
- package/dist/tools/utils/common.js.map +1 -1
- package/dist/tools/utils/fetch-pipeline.d.ts +8 -0
- package/dist/tools/utils/fetch-pipeline.d.ts.map +1 -1
- package/dist/tools/utils/fetch-pipeline.js +47 -79
- package/dist/tools/utils/fetch-pipeline.js.map +1 -1
- package/dist/transformers/jsonl.transformer.d.ts +1 -1
- package/dist/transformers/jsonl.transformer.d.ts.map +1 -1
- package/dist/transformers/jsonl.transformer.js +15 -10
- package/dist/transformers/jsonl.transformer.js.map +1 -1
- package/dist/transformers/markdown.transformer.d.ts.map +1 -1
- package/dist/transformers/markdown.transformer.js +58 -62
- package/dist/transformers/markdown.transformer.js.map +1 -1
- package/dist/utils/concurrency.d.ts +2 -5
- package/dist/utils/concurrency.d.ts.map +1 -1
- package/dist/utils/concurrency.js +19 -19
- package/dist/utils/concurrency.js.map +1 -1
- package/dist/utils/content-cleaner.d.ts +0 -25
- package/dist/utils/content-cleaner.d.ts.map +1 -1
- package/dist/utils/content-cleaner.js +12 -187
- package/dist/utils/content-cleaner.js.map +1 -1
- package/dist/utils/html-truncator.d.ts +2 -0
- package/dist/utils/html-truncator.d.ts.map +1 -0
- package/dist/utils/html-truncator.js +14 -0
- package/dist/utils/html-truncator.js.map +1 -0
- package/dist/utils/language-detector.d.ts +0 -3
- package/dist/utils/language-detector.d.ts.map +1 -1
- package/dist/utils/language-detector.js +0 -11
- package/dist/utils/language-detector.js.map +1 -1
- package/dist/utils/sanitizer.d.ts.map +1 -1
- package/dist/utils/sanitizer.js +7 -5
- package/dist/utils/sanitizer.js.map +1 -1
- package/dist/utils/tool-error-handler.d.ts.map +1 -1
- package/dist/utils/tool-error-handler.js +15 -42
- package/dist/utils/tool-error-handler.js.map +1 -1
- package/dist/utils/url-validator.d.ts +0 -6
- package/dist/utils/url-validator.d.ts.map +1 -1
- package/dist/utils/url-validator.js +12 -81
- package/dist/utils/url-validator.js.map +1 -1
- package/package.json +5 -6
|
@@ -1,208 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* that slip through Readability extraction.
|
|
4
|
-
*/
|
|
5
|
-
// Pre-compiled combined pattern for optimal performance
|
|
6
|
-
const NOISE_PATTERN_COMBINED = new RegExp([
|
|
7
|
-
// Relative timestamps
|
|
8
|
-
'^\\d+\\s*(seconds?|minutes?|hours?|days?|weeks?|months?|years?)\\s*ago$',
|
|
9
|
-
'^(just now|recently|today|yesterday|last week|last month)$',
|
|
10
|
-
'^(updated|modified|edited|created|published)\\s*:?\\s*\\d+\\s*(seconds?|minutes?|hours?|days?|weeks?|months?|years?)\\s*ago$',
|
|
11
|
-
'^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+\\d{1,2},?\\s+\\d{4}$',
|
|
12
|
-
'^\\d{1,2}\\s+(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\\s+\\d{4}$',
|
|
13
|
-
'^\\d{4}-\\d{2}-\\d{2}$',
|
|
14
|
-
'^last\\s+updated\\s*:?',
|
|
15
|
-
// Share/action buttons
|
|
16
|
-
'^(share|copy|like|follow|subscribe|download|print|save|bookmark|tweet|pin it|email|export)$',
|
|
1
|
+
const NOISE_PATTERN = new RegExp([
|
|
2
|
+
'^(share|copy|like|follow|subscribe|download|print|save)$',
|
|
17
3
|
'^(copy to clipboard|copied!?|copy code|copy link)$',
|
|
18
|
-
'^(
|
|
19
|
-
|
|
20
|
-
'^(
|
|
21
|
-
'^(toggle|switch|enable|disable|on|off)$',
|
|
22
|
-
'^(edit|delete|remove|add|new|create|update|cancel|confirm|submit|reset|clear)$',
|
|
23
|
-
'^(open in|view in|edit in)\\s+\\w+$',
|
|
24
|
-
'^(try it|run|execute|play|preview|demo|live demo|playground)$',
|
|
25
|
-
'^(source|view source|edit this page|edit on github|improve this doc)$',
|
|
26
|
-
// Empty/placeholder
|
|
4
|
+
'^(show more|show less|load more|view more|read more|see all|view all)$',
|
|
5
|
+
'^(next|previous|prev|back|forward|home|menu|close|skip to)$',
|
|
6
|
+
'^(table of contents|toc|on this page)$',
|
|
27
7
|
'^(loading\\.{0,3}|please wait\\.{0,3}|\\.{2,})$',
|
|
28
|
-
'^(n\\/a|tbd|todo|coming soon|placeholder
|
|
29
|
-
|
|
30
|
-
'^(next|previous|prev|back|forward|home|menu|close|open|skip to|jump to|go to)$',
|
|
31
|
-
'^(table of contents|toc|contents|on this page|in this article|in this section)$',
|
|
32
|
-
'^(scroll to top|back to top|top)$',
|
|
33
|
-
// Cookie/consent
|
|
34
|
-
'^(accept|reject|accept all|reject all|cookie settings|privacy settings|manage preferences)$',
|
|
35
|
-
'^(accept cookies|decline cookies|cookie policy|privacy policy|terms of service|terms & conditions)$',
|
|
36
|
-
// Counts
|
|
37
|
-
'^\\d+\\s*(comments?|replies?|reactions?|responses?)$',
|
|
38
|
-
'^\\d+\\s*(likes?|shares?|views?|followers?|retweets?|stars?|forks?|claps?|upvotes?|downvotes?)$',
|
|
39
|
-
'^(liked by|shared by|followed by)\\s+\\d+',
|
|
40
|
-
// Version badges
|
|
41
|
-
'^v?\\d+\\.\\d+(\\.\\d+)?(-\\w+)?$',
|
|
42
|
-
'^(stable|beta|alpha|rc|preview|experimental|deprecated|legacy|new|updated)$',
|
|
43
|
-
// Structural
|
|
44
|
-
'^(a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z)$',
|
|
45
|
-
'^panel\\s*[a-z]?$',
|
|
46
|
-
// API artifacts
|
|
47
|
-
'^(required|optional|default|type|example|description|parameters?|returns?|response|request)$',
|
|
48
|
-
'^(get|post|put|patch|delete|head|options)\\s*$',
|
|
49
|
-
// Interactive
|
|
50
|
-
'^(drag|drop|resize|zoom|scroll|swipe|tap|click|hover|focus)(\\s+to\\s+\\w+)?$',
|
|
51
|
-
'^(drag the|move the|resize the|drag to|click to)\\s+\\w+',
|
|
52
|
-
// Breadcrumbs
|
|
8
|
+
'^(n\\/a|tbd|todo|coming soon|placeholder)$',
|
|
9
|
+
'^\\d+\\s*(comments?|replies?|likes?|shares?|views?)$',
|
|
53
10
|
'^[/\\\\>→»›]+$',
|
|
54
|
-
// Ads
|
|
55
|
-
'^(ad|advertisement|sponsored|promoted|partner content)$',
|
|
56
11
|
].join('|'), 'i');
|
|
57
|
-
// Pre-compiled pattern for short text noise
|
|
58
|
-
const SHORT_TEXT_NOISE_PATTERN = new RegExp([
|
|
59
|
-
'^#\\w+$',
|
|
60
|
-
'^@\\w+$',
|
|
61
|
-
'^\\d+$',
|
|
62
|
-
'^[•·→←↑↓►▼▲◄▶◀■□●○★☆✓✗✔✘×]+$',
|
|
63
|
-
'^[,;:\\-–—]+$',
|
|
64
|
-
'^\\[\\d+\\]$',
|
|
65
|
-
'^\\(\\d+\\)$',
|
|
66
|
-
'^fig\\.?\\s*\\d+$',
|
|
67
|
-
'^table\\s*\\d+$',
|
|
68
|
-
'^step\\s*\\d+$',
|
|
69
|
-
'^note:?$',
|
|
70
|
-
'^tip:?$',
|
|
71
|
-
'^warning:?$',
|
|
72
|
-
'^info:?$',
|
|
73
|
-
'^caution:?$',
|
|
74
|
-
].join('|'), 'i');
|
|
75
|
-
// Pre-compiled pattern for UI chrome detection
|
|
76
|
-
const UI_CHROME_PATTERN = new RegExp([
|
|
77
|
-
'^(sign in|sign up|log in|log out|register|create account)$',
|
|
78
|
-
'^(search|search\\.\\.\\.|search docs|search documentation)$',
|
|
79
|
-
'^(dark mode|light mode|theme|language|locale)$',
|
|
80
|
-
'^(feedback|report issue|report a bug|file an issue|suggest edit)$',
|
|
81
|
-
'^(documentation|docs|api|reference|guide|tutorial|examples?)$',
|
|
82
|
-
"^(version|changelog|release notes|what's new)$",
|
|
83
|
-
].join('|'), 'i');
|
|
84
|
-
// Minimum lengths for different content types
|
|
85
12
|
const MIN_PARAGRAPH_LENGTH = 20;
|
|
86
13
|
const MIN_HEADING_LENGTH = 2;
|
|
87
14
|
const MIN_LIST_ITEM_LENGTH = 3;
|
|
88
|
-
const SHORT_TEXT_THRESHOLD = 25;
|
|
89
|
-
// Maximum text length to test against regex patterns (ReDoS protection)
|
|
90
15
|
const MAX_REGEX_INPUT_LENGTH = 500;
|
|
91
|
-
/**
|
|
92
|
-
* Check if text matches any noise pattern
|
|
93
|
-
* Protected against ReDoS by limiting input length
|
|
94
|
-
*/
|
|
95
16
|
function isNoiseText(text) {
|
|
96
17
|
const trimmed = text.trim();
|
|
97
|
-
|
|
98
|
-
if (!trimmed) {
|
|
18
|
+
if (!trimmed)
|
|
99
19
|
return true;
|
|
100
|
-
|
|
101
|
-
// ReDoS protection: skip regex for very long strings
|
|
102
|
-
if (trimmed.length > MAX_REGEX_INPUT_LENGTH) {
|
|
20
|
+
if (trimmed.length > MAX_REGEX_INPUT_LENGTH)
|
|
103
21
|
return false;
|
|
104
|
-
|
|
105
|
-
// Check combined noise pattern (single regex test)
|
|
106
|
-
if (NOISE_PATTERN_COMBINED.test(trimmed)) {
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
// Check short text patterns for brief content
|
|
110
|
-
if (trimmed.length < SHORT_TEXT_THRESHOLD) {
|
|
111
|
-
if (SHORT_TEXT_NOISE_PATTERN.test(trimmed)) {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
// Also check UI chrome patterns for short text
|
|
115
|
-
if (UI_CHROME_PATTERN.test(trimmed)) {
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
// Pre-compiled placeholder pattern (combined for performance)
|
|
122
|
-
const PLACEHOLDER_PATTERN = /^(lorem ipsum|sample text|placeholder|example (text|content|data)|test (text|content|data)|your (text|content|name|email) here|enter (your|a) |type (your|a|something) )/i;
|
|
123
|
-
const PLACEHOLDER_CACHE = new Map();
|
|
124
|
-
const PLACEHOLDER_CACHE_MAX_SIZE = 1000;
|
|
125
|
-
const PLACEHOLDER_CACHE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
126
|
-
/**
|
|
127
|
-
* Check if text looks like placeholder/demo content
|
|
128
|
-
* Uses caching with TTL for performance and memory safety
|
|
129
|
-
*/
|
|
130
|
-
function isPlaceholderContent(text) {
|
|
131
|
-
const trimmed = text.trim().toLowerCase();
|
|
132
|
-
const now = Date.now();
|
|
133
|
-
// Check cache first
|
|
134
|
-
const cached = PLACEHOLDER_CACHE.get(trimmed);
|
|
135
|
-
if (cached !== undefined) {
|
|
136
|
-
// Check if entry is still valid
|
|
137
|
-
if (now - cached.timestamp < PLACEHOLDER_CACHE_TTL_MS) {
|
|
138
|
-
return cached.value;
|
|
139
|
-
}
|
|
140
|
-
// Expired entry, remove it
|
|
141
|
-
PLACEHOLDER_CACHE.delete(trimmed);
|
|
142
|
-
}
|
|
143
|
-
// Single regex test (faster than array iteration)
|
|
144
|
-
const result = PLACEHOLDER_PATTERN.test(trimmed);
|
|
145
|
-
// Cache result with LRU eviction and timestamp
|
|
146
|
-
if (PLACEHOLDER_CACHE.size >= PLACEHOLDER_CACHE_MAX_SIZE) {
|
|
147
|
-
// Remove oldest entries (first 10% of cache)
|
|
148
|
-
const keysToDelete = Math.ceil(PLACEHOLDER_CACHE_MAX_SIZE * 0.1);
|
|
149
|
-
const iterator = PLACEHOLDER_CACHE.keys();
|
|
150
|
-
for (let i = 0; i < keysToDelete; i++) {
|
|
151
|
-
const key = iterator.next().value;
|
|
152
|
-
if (key !== undefined) {
|
|
153
|
-
PLACEHOLDER_CACHE.delete(key);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
PLACEHOLDER_CACHE.set(trimmed, { value: result, timestamp: now });
|
|
158
|
-
return result;
|
|
22
|
+
return NOISE_PATTERN.test(trimmed);
|
|
159
23
|
}
|
|
160
|
-
/**
|
|
161
|
-
* Clean paragraph text by removing noise
|
|
162
|
-
*/
|
|
163
24
|
export function cleanParagraph(text) {
|
|
164
25
|
const trimmed = text.trim();
|
|
165
|
-
// Too short to be meaningful
|
|
166
26
|
if (trimmed.length < MIN_PARAGRAPH_LENGTH) {
|
|
167
|
-
// Allow very short paragraphs if they end with punctuation (likely real content)
|
|
168
27
|
if (!/[.!?]$/.test(trimmed)) {
|
|
169
28
|
return null;
|
|
170
29
|
}
|
|
171
30
|
}
|
|
172
|
-
// Is noise content
|
|
173
31
|
if (isNoiseText(trimmed)) {
|
|
174
32
|
return null;
|
|
175
33
|
}
|
|
176
|
-
// Is placeholder content (in paragraphs, not in examples)
|
|
177
|
-
if (isPlaceholderContent(trimmed)) {
|
|
178
|
-
return null;
|
|
179
|
-
}
|
|
180
34
|
return trimmed;
|
|
181
35
|
}
|
|
182
|
-
/**
|
|
183
|
-
* Clean heading text by removing noise and markdown link syntax
|
|
184
|
-
*/
|
|
185
36
|
export function cleanHeading(text) {
|
|
186
37
|
let cleaned = text.trim();
|
|
187
|
-
// Too short
|
|
188
38
|
if (cleaned.length < MIN_HEADING_LENGTH) {
|
|
189
39
|
return null;
|
|
190
40
|
}
|
|
191
|
-
// Remove markdown link syntax: [Text](#anchor) -> Text
|
|
192
41
|
cleaned = cleaned.replace(/\[([^\]]+)\]\([^)]*\)/g, '$1');
|
|
193
|
-
// Remove trailing anchor links like "Link for this heading"
|
|
194
42
|
cleaned = cleaned.replace(/\s*Link for (this heading|[\w\s]+)\s*$/i, '');
|
|
195
|
-
// Remove trailing hash symbols often used for anchor links
|
|
196
43
|
cleaned = cleaned.replace(/\s*#+\s*$/, '');
|
|
197
|
-
// Is noise content
|
|
198
44
|
if (isNoiseText(cleaned)) {
|
|
199
45
|
return null;
|
|
200
46
|
}
|
|
201
47
|
return cleaned.trim();
|
|
202
48
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Clean list items by filtering out noise
|
|
205
|
-
*/
|
|
206
49
|
export function cleanListItems(items) {
|
|
207
50
|
return items
|
|
208
51
|
.map((item) => item.trim())
|
|
@@ -214,43 +57,25 @@ export function cleanListItems(items) {
|
|
|
214
57
|
return true;
|
|
215
58
|
});
|
|
216
59
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Clean code block text - minimal cleaning to preserve code integrity
|
|
219
|
-
*/
|
|
220
60
|
export function cleanCodeBlock(code) {
|
|
221
61
|
const trimmed = code.trim();
|
|
222
|
-
// Empty code block
|
|
223
62
|
if (trimmed.length === 0) {
|
|
224
63
|
return null;
|
|
225
64
|
}
|
|
226
|
-
// Very short code blocks that are likely just labels
|
|
227
65
|
if (trimmed.length < 3 && !/^[{}[\]();<>]$/.test(trimmed)) {
|
|
228
66
|
return null;
|
|
229
67
|
}
|
|
230
68
|
return trimmed;
|
|
231
69
|
}
|
|
232
|
-
/**
|
|
233
|
-
* Strip markdown link syntax from text for cleaner slugs/display
|
|
234
|
-
* [Text](#anchor) -> Text
|
|
235
|
-
* [Text](url) -> Text
|
|
236
|
-
*/
|
|
237
70
|
export function stripMarkdownLinks(text) {
|
|
238
71
|
return text.replace(/\[([^\]]+)\]\([^)]*\)/g, '$1');
|
|
239
72
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Remove common timestamp patterns from text (inline removal)
|
|
242
|
-
* Use when you want to strip timestamps from within longer content
|
|
243
|
-
*/
|
|
244
73
|
export function removeInlineTimestamps(text) {
|
|
245
|
-
return
|
|
246
|
-
// Remove "X days/hours/etc ago" patterns
|
|
74
|
+
return text
|
|
247
75
|
.replace(/\b\d+\s*(seconds?|minutes?|hours?|days?|weeks?|months?|years?)\s*ago\b/gi, '')
|
|
248
|
-
// Remove "Updated: date" patterns
|
|
249
76
|
.replace(/\b(updated|modified|edited|created|published)\s*:?\s*\d+\s*(seconds?|minutes?|hours?|days?|weeks?|months?|years?)\s*ago\b/gi, '')
|
|
250
|
-
// Remove standalone dates
|
|
251
77
|
.replace(/\b(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\s+\d{1,2},?\s+\d{4}\b/gi, '')
|
|
252
|
-
// Clean up extra whitespace
|
|
253
78
|
.replace(/\s{2,}/g, ' ')
|
|
254
|
-
.trim()
|
|
79
|
+
.trim();
|
|
255
80
|
}
|
|
256
81
|
//# sourceMappingURL=content-cleaner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-cleaner.js","sourceRoot":"","sources":["../../src/utils/content-cleaner.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"content-cleaner.js","sourceRoot":"","sources":["../../src/utils/content-cleaner.ts"],"names":[],"mappings":"AAAA,M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SACR,OAAO,CACN,0EAA0E,EAC1E,EAAE,CACH;SACA,OAAO,CACN,6HAA6H,EAC7H,EAAE,CACH;SACA,OAAO,CACN,6EAA6E,EAC7E,EAAE,CACH;SACA,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;SACvB,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-truncator.d.ts","sourceRoot":"","sources":["../../src/utils/html-truncator.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAajD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { config } from '../config/index.js';
|
|
2
|
+
import { logWarn } from '../services/logger.js';
|
|
3
|
+
export function truncateHtml(html) {
|
|
4
|
+
const maxSize = config.constants.maxHtmlSize;
|
|
5
|
+
if (html.length <= maxSize) {
|
|
6
|
+
return html;
|
|
7
|
+
}
|
|
8
|
+
logWarn('HTML content exceeds maximum size, truncating', {
|
|
9
|
+
size: html.length,
|
|
10
|
+
maxSize,
|
|
11
|
+
});
|
|
12
|
+
return html.substring(0, maxSize);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=html-truncator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-truncator.js","sourceRoot":"","sources":["../../src/utils/html-truncator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC;IAE7C,IAAI,IAAI,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,+CAA+C,EAAE;QACvD,IAAI,EAAE,IAAI,CAAC,MAAM;QACjB,OAAO;KACR,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-detector.d.ts","sourceRoot":"","sources":["../../src/utils/language-detector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"language-detector.d.ts","sourceRoot":"","sources":["../../src/utils/language-detector.ts"],"names":[],"mappings":"AAoCA,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE/D"}
|
|
@@ -1,21 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language detection patterns for code blocks
|
|
3
|
-
* Shared between parser and markdown transformer
|
|
4
|
-
*/
|
|
5
1
|
const LANGUAGE_PATTERNS = [
|
|
6
|
-
// JSX/TSX patterns
|
|
7
2
|
[
|
|
8
3
|
/^\s*import\s+.*\s+from\s+['"]react['"]|<[A-Z][a-zA-Z]*[\s/>]|jsx\s*:|className=/m,
|
|
9
4
|
'jsx',
|
|
10
5
|
],
|
|
11
|
-
// TypeScript patterns
|
|
12
6
|
[
|
|
13
7
|
/:\s*(string|number|boolean|void|any|unknown|never)\b|interface\s+\w+|type\s+\w+\s*=/m,
|
|
14
8
|
'typescript',
|
|
15
9
|
],
|
|
16
|
-
// Rust patterns
|
|
17
10
|
[/^\s*(fn|let\s+mut|impl|struct|enum|use\s+\w+::)/m, 'rust'],
|
|
18
|
-
// JavaScript patterns (generic)
|
|
19
11
|
[
|
|
20
12
|
/^\s*(export|const|let|var|function|class|async|await)\b|^\s*import\s+.*['"]/m,
|
|
21
13
|
'javascript',
|
|
@@ -41,9 +33,6 @@ const LANGUAGE_PATTERNS = [
|
|
|
41
33
|
// Go patterns
|
|
42
34
|
[/^\s*(func|package|import\s+")/m, 'go'],
|
|
43
35
|
];
|
|
44
|
-
/**
|
|
45
|
-
* Detect programming language from code content
|
|
46
|
-
*/
|
|
47
36
|
export function detectLanguage(code) {
|
|
48
37
|
return LANGUAGE_PATTERNS.find(([pattern]) => pattern.test(code))?.[1];
|
|
49
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"language-detector.js","sourceRoot":"","sources":["../../src/utils/language-detector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"language-detector.js","sourceRoot":"","sources":["../../src/utils/language-detector.ts"],"names":[],"mappings":"AAAA,MAAM,iBAAiB,GAAG;IACxB;QACE,kFAAkF;QAClF,KAAK;KACN;IACD;QACE,sFAAsF;QACtF,YAAY;KACb;IACD,CAAC,kDAAkD,EAAE,MAAM,CAAC;IAC5D;QACE,8EAA8E;QAC9E,YAAY;KACb;IACD,kBAAkB;IAClB,CAAC,kDAAkD,EAAE,QAAQ,CAAC;IAC9D,sBAAsB;IACtB;QACE,iFAAiF;QACjF,MAAM;KACP;IACD,CAAC,iEAAiE,EAAE,MAAM,CAAC;IAC3E,eAAe;IACf,CAAC,yDAAyD,EAAE,KAAK,CAAC;IAClE,gBAAgB;IAChB,CAAC,8DAA8D,EAAE,MAAM,CAAC;IACxE,gBAAgB;IAChB,CAAC,6CAA6C,EAAE,MAAM,CAAC;IACvD,gBAAgB;IAChB,CAAC,oBAAoB,EAAE,MAAM,CAAC;IAC9B,eAAe;IACf,CAAC,0DAA0D,EAAE,KAAK,CAAC;IACnE,cAAc;IACd,CAAC,gCAAgC,EAAE,IAAI,CAAC;CAChC,CAAC;AAEX,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,OAAO,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../../src/utils/sanitizer.ts"],"names":[],"mappings":"AAIA,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAKpE;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAWpE"}
|
package/dist/utils/sanitizer.js
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
1
|
+
const CONSECUTIVE_WHITESPACE = /\s+/g;
|
|
2
|
+
const MIN_TRUNCATION_LENGTH = 4;
|
|
3
|
+
const TRUNCATION_SUFFIX = '...';
|
|
3
4
|
export function sanitizeText(text) {
|
|
4
5
|
if (text == null)
|
|
5
6
|
return '';
|
|
6
7
|
if (typeof text !== 'string')
|
|
7
8
|
return String(text);
|
|
8
|
-
return text.replace(
|
|
9
|
+
return text.replace(CONSECUTIVE_WHITESPACE, ' ').trim();
|
|
9
10
|
}
|
|
10
11
|
export function truncateText(text, maxLength) {
|
|
11
|
-
if (maxLength <
|
|
12
|
+
if (maxLength < MIN_TRUNCATION_LENGTH) {
|
|
12
13
|
return text.length > 0 ? text.charAt(0) : '';
|
|
13
14
|
}
|
|
14
15
|
if (text.length <= maxLength) {
|
|
15
16
|
return text;
|
|
16
17
|
}
|
|
17
|
-
|
|
18
|
+
const truncationPoint = maxLength - TRUNCATION_SUFFIX.length;
|
|
19
|
+
return `${text.substring(0, truncationPoint)}${TRUNCATION_SUFFIX}`;
|
|
18
20
|
}
|
|
19
21
|
//# sourceMappingURL=sanitizer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../src/utils/sanitizer.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"sanitizer.js","sourceRoot":"","sources":["../../src/utils/sanitizer.ts"],"names":[],"mappings":"AAAA,MAAM,sBAAsB,GAAG,MAAM,CAAC;AACtC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AAEhC,MAAM,UAAU,YAAY,CAAC,IAA+B;IAC1D,IAAI,IAAI,IAAI,IAAI;QAAE,OAAO,EAAE,CAAC;IAC5B,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;IAElD,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC1D,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAY,EAAE,SAAiB;IAC1D,IAAI,SAAS,GAAG,qBAAqB,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/C,CAAC;IAED,IAAI,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,eAAe,GAAG,SAAS,GAAG,iBAAiB,CAAC,MAAM,CAAC;IAC7D,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,CAAC,GAAG,iBAAiB,EAAE,CAAC;AACrE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/tool-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"tool-error-handler.d.ts","sourceRoot":"","sources":["../../src/utils/tool-error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAQ5D,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GACX,iBAAiB,CAQnB;AAgBD,wBAAgB,eAAe,CAC7B,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,MAAM,EACX,eAAe,SAAqB,GACnC,iBAAiB,CAgBnB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const isDevelopment = process.env.NODE_ENV === 'development' &&
|
|
1
|
+
import { FetchError } from '../errors/app-error.js';
|
|
2
|
+
const IS_DEVELOPMENT_WITH_STACK_TRACES = process.env.NODE_ENV === 'development' &&
|
|
4
3
|
process.env.EXPOSE_STACK_TRACES === 'true';
|
|
5
4
|
export function createToolErrorResponse(message, url, code) {
|
|
6
5
|
const structuredContent = { error: message, url, errorCode: code };
|
|
@@ -10,48 +9,22 @@ export function createToolErrorResponse(message, url, code) {
|
|
|
10
9
|
isError: true,
|
|
11
10
|
};
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
: error.message;
|
|
18
|
-
return createToolErrorResponse(message, url, 'INVALID_URL');
|
|
19
|
-
}
|
|
20
|
-
if (error instanceof AbortError) {
|
|
21
|
-
const message = isDevelopment
|
|
22
|
-
? `Request aborted${error.reason ? `: ${error.reason}` : ''}\n${error.stack ?? ''}`
|
|
23
|
-
: `Request aborted${error.reason ? `: ${error.reason}` : ''}`;
|
|
24
|
-
return createToolErrorResponse(message, url, 'ABORTED');
|
|
25
|
-
}
|
|
26
|
-
if (error instanceof TimeoutError) {
|
|
27
|
-
const message = isDevelopment
|
|
28
|
-
? `Request timed out after ${error.timeoutMs}ms\n${error.stack ?? ''}`
|
|
29
|
-
: `Request timed out after ${error.timeoutMs}ms`;
|
|
30
|
-
return createToolErrorResponse(message, url, 'TIMEOUT');
|
|
31
|
-
}
|
|
32
|
-
if (error instanceof RateLimitError) {
|
|
33
|
-
const message = isDevelopment
|
|
34
|
-
? `Rate limited. Retry after ${error.retryAfter}s\n${error.stack ?? ''}`
|
|
35
|
-
: `Rate limited. Retry after ${error.retryAfter}s`;
|
|
36
|
-
return createToolErrorResponse(message, url, 'RATE_LIMITED');
|
|
12
|
+
function formatErrorMessage(baseMessage, error, fallback) {
|
|
13
|
+
const message = fallback ? `${fallback}: ${error.message}` : error.message;
|
|
14
|
+
if (IS_DEVELOPMENT_WITH_STACK_TRACES && error.stack) {
|
|
15
|
+
return `${message}\n${error.stack}`;
|
|
37
16
|
}
|
|
17
|
+
return message;
|
|
18
|
+
}
|
|
19
|
+
export function handleToolError(error, url, fallbackMessage = 'Operation failed') {
|
|
38
20
|
if (error instanceof FetchError) {
|
|
39
|
-
const
|
|
40
|
-
const message = isDevelopment
|
|
41
|
-
? `${error.message}\n${error.stack ?? ''}`
|
|
42
|
-
: error.message;
|
|
43
|
-
return createToolErrorResponse(message, url, code);
|
|
44
|
-
}
|
|
45
|
-
if (error instanceof AppError) {
|
|
46
|
-
const message = isDevelopment
|
|
47
|
-
? `${error.message}\n${error.stack ?? ''}`
|
|
48
|
-
: error.message;
|
|
21
|
+
const message = formatErrorMessage(error.message, error);
|
|
49
22
|
return createToolErrorResponse(message, url, error.code);
|
|
50
23
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return createToolErrorResponse(
|
|
24
|
+
if (error instanceof Error) {
|
|
25
|
+
const message = formatErrorMessage(error.message, error, fallbackMessage);
|
|
26
|
+
return createToolErrorResponse(message, url, 'UNKNOWN_ERROR');
|
|
27
|
+
}
|
|
28
|
+
return createToolErrorResponse(`${fallbackMessage}: Unknown error`, url, 'UNKNOWN_ERROR');
|
|
56
29
|
}
|
|
57
30
|
//# sourceMappingURL=tool-error-handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-error-handler.js","sourceRoot":"","sources":["../../src/utils/tool-error-handler.ts"],"names":[],"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AG,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAC1E,OAAO,uBAAuB,CAAC,OAAO,EAAE,GAAG,EAAE,eAAe,CAAC,CAAC;IAChE,CAAC;IAED,OAAO,uBAAuB,CAC5B,GAAG,eAAe,iBAAiB,EACnC,GAAG,EACH,eAAe,CAChB,CAAC;AACJ,CAAC"}
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
* Check if an IP address is in a blocked private range
|
|
3
3
|
*/
|
|
4
4
|
export declare function isBlockedIp(ip: string): boolean;
|
|
5
|
-
/**
|
|
6
|
-
* Validate resolved IP addresses to prevent DNS rebinding attacks.
|
|
7
|
-
* This should be called after DNS resolution to ensure the resolved
|
|
8
|
-
* IPs are not in blocked private ranges.
|
|
9
|
-
*/
|
|
10
|
-
export declare function validateResolvedIps(hostname: string): Promise<void>;
|
|
11
5
|
export declare function validateAndNormalizeUrl(urlString: string): string;
|
|
12
6
|
export declare function isInternalUrl(url: string, baseUrl: string): boolean;
|
|
13
7
|
//# sourceMappingURL=url-validator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-validator.d.ts","sourceRoot":"","sources":["../../src/utils/url-validator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url-validator.d.ts","sourceRoot":"","sources":["../../src/utils/url-validator.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE/C;AAED,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CA2DjE;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAQnE"}
|