smart-web-mcp 0.43.1 → 0.43.3
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/CHANGELOG.md +16 -0
- package/README.md +2 -2
- package/dist/korea/smartvertical.js +36 -10
- package/dist/korea/smartvertical.js.map +1 -1
- package/dist/smartfetch/generic-fallbacks.d.ts +17 -0
- package/dist/smartfetch/generic-fallbacks.js +15 -3
- package/dist/smartfetch/generic-fallbacks.js.map +1 -1
- package/dist/smartfetch/providers/reddit.js +192 -93
- package/dist/smartfetch/providers/reddit.js.map +1 -1
- package/dist/smartfetch.d.ts +1 -1
- package/dist/smartfetch.js +4 -2
- package/dist/smartfetch.js.map +1 -1
- package/dist/smartsearch.js +128 -23
- package/dist/smartsearch.js.map +1 -1
- package/package.json +2 -2
- package/python/requirements-undetected-chromedriver.txt +2 -2
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { asNumber, asString, configEnabled, dedupeUrls, extractAnchorHrefs, extractUrls } from "../../shared.js";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { parseFeed } from "../generic-fallbacks.js";
|
|
3
|
+
import { fetchProviderJson, fetchProviderText } from "../provider-policy.js";
|
|
4
|
+
function allowRedditRetrieval() {
|
|
4
5
|
return configEnabled("fetch.enableRedditJson", true);
|
|
5
6
|
}
|
|
7
|
+
function asRecord(value) {
|
|
8
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
9
|
+
}
|
|
10
|
+
function asRecordArray(value) {
|
|
11
|
+
return Array.isArray(value) ? value.map(asRecord).filter((item) => Object.keys(item).length > 0) : [];
|
|
12
|
+
}
|
|
6
13
|
function postUrl(context) {
|
|
7
14
|
const values = [
|
|
8
15
|
context.resolvedUrl,
|
|
@@ -36,112 +43,204 @@ function usefulLinks(values) {
|
|
|
36
43
|
}
|
|
37
44
|
});
|
|
38
45
|
}
|
|
46
|
+
function redditPostIdentity(url) {
|
|
47
|
+
try {
|
|
48
|
+
const parsed = new URL(url);
|
|
49
|
+
const match = parsed.pathname.match(/^\/r\/([^/]+)\/comments\/([^/]+)(?:\/([^/]+))?/i);
|
|
50
|
+
if (!match)
|
|
51
|
+
return null;
|
|
52
|
+
const subreddit = match[1] || "";
|
|
53
|
+
const id = match[2] || "";
|
|
54
|
+
const path = parsed.pathname.replace(/\/+$/, "");
|
|
55
|
+
return { id, subreddit, path, canonicalUrl: `https://www.reddit.com${path}/` };
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function mapComment(node) {
|
|
62
|
+
const record = asRecord(node);
|
|
63
|
+
if (asString(record.kind) !== "t1")
|
|
64
|
+
return null;
|
|
65
|
+
const data = asRecord(record.data);
|
|
66
|
+
const replies = asRecord(data.replies);
|
|
67
|
+
const listing = asRecord(replies.data);
|
|
68
|
+
const children = asRecordArray(listing.children).map(mapComment).filter((item) => Boolean(item));
|
|
69
|
+
return {
|
|
70
|
+
id: asString(data.id),
|
|
71
|
+
author: asString(data.author),
|
|
72
|
+
body: asString(data.body),
|
|
73
|
+
score: asNumber(data.score),
|
|
74
|
+
created_utc: asNumber(data.created_utc),
|
|
75
|
+
children,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function normalizePost(postData, identity, comments, method, partial, errors, activeLinks) {
|
|
79
|
+
const permalink = asString(postData.permalink) || identity.path;
|
|
80
|
+
const postTarget = asString(postData.url) || identity.canonicalUrl;
|
|
81
|
+
const outbound = dedupeUrls([
|
|
82
|
+
...usefulLinks(activeLinks),
|
|
83
|
+
...extractUrls(asString(postData.selftext)),
|
|
84
|
+
...extractAnchorHrefs(asString(postData.selftext_html)),
|
|
85
|
+
postTarget,
|
|
86
|
+
]);
|
|
87
|
+
return {
|
|
88
|
+
post: {
|
|
89
|
+
id: asString(postData.id) || identity.id,
|
|
90
|
+
title: asString(postData.title),
|
|
91
|
+
author: asString(postData.author),
|
|
92
|
+
subreddit: asString(postData.subreddit) || identity.subreddit,
|
|
93
|
+
permalink,
|
|
94
|
+
url: postTarget,
|
|
95
|
+
selftext: asString(postData.selftext),
|
|
96
|
+
score: asNumber(postData.score),
|
|
97
|
+
num_comments: asNumber(postData.num_comments),
|
|
98
|
+
created_utc: asNumber(postData.created_utc),
|
|
99
|
+
},
|
|
100
|
+
thread: [],
|
|
101
|
+
comments,
|
|
102
|
+
outbound_links: usefulLinks(outbound),
|
|
103
|
+
partial,
|
|
104
|
+
errors,
|
|
105
|
+
method,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function failedNormalization(context, method, error) {
|
|
109
|
+
return {
|
|
110
|
+
post: null,
|
|
111
|
+
thread: [],
|
|
112
|
+
comments: [],
|
|
113
|
+
outbound_links: [],
|
|
114
|
+
partial: true,
|
|
115
|
+
errors: [...context.errors, error],
|
|
116
|
+
method,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
39
119
|
export const redditProvider = {
|
|
40
120
|
id: "reddit",
|
|
41
121
|
matches: (_url, target) => target === "reddit_post",
|
|
42
122
|
async normalize(context) {
|
|
43
|
-
if (!
|
|
44
|
-
return {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
partial: true,
|
|
50
|
-
errors: [
|
|
51
|
-
...context.errors,
|
|
52
|
-
{ category: "unavailable", code: "reddit_json_disabled", message: "Reddit JSON enrichment disabled by configuration" },
|
|
53
|
-
],
|
|
54
|
-
method: "reddit_json_public",
|
|
55
|
-
};
|
|
123
|
+
if (!allowRedditRetrieval()) {
|
|
124
|
+
return failedNormalization(context, "reddit_personal_fallbacks", {
|
|
125
|
+
category: "unavailable",
|
|
126
|
+
code: "reddit_retrieval_disabled",
|
|
127
|
+
message: "Reddit retrieval disabled by configuration",
|
|
128
|
+
});
|
|
56
129
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
130
|
+
const sourceUrl = postUrl(context);
|
|
131
|
+
const identity = redditPostIdentity(sourceUrl);
|
|
132
|
+
if (!identity) {
|
|
133
|
+
return failedNormalization(context, "reddit_personal_fallbacks", {
|
|
134
|
+
category: "parse_error",
|
|
135
|
+
code: "invalid_reddit_url",
|
|
136
|
+
message: "URL is not a Reddit post URL",
|
|
137
|
+
});
|
|
61
138
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
139
|
+
const rssUrl = `https://www.reddit.com${identity.path}.rss`;
|
|
140
|
+
const rssResult = await fetchProviderText(rssUrl, context.timeoutMs, {
|
|
141
|
+
headers: {
|
|
142
|
+
accept: "application/atom+xml,application/rss+xml,application/xml,text/xml,text/plain,*/*",
|
|
143
|
+
"user-agent": "smart-web-personal/0.1",
|
|
144
|
+
},
|
|
145
|
+
}, {
|
|
146
|
+
mode: "same-origin",
|
|
147
|
+
sourceUrl,
|
|
148
|
+
});
|
|
149
|
+
if (rssResult.ok) {
|
|
150
|
+
const feed = parseFeed(rssResult.text, rssUrl);
|
|
151
|
+
const postEntry = feed?.entries.find((entry) => entry.id === `t3_${identity.id}`);
|
|
152
|
+
if (feed && postEntry) {
|
|
153
|
+
const comments = feed.entries.filter((entry) => entry.id.startsWith("t1_")).map((entry) => ({
|
|
154
|
+
id: entry.id.replace(/^t1_/, ""),
|
|
155
|
+
author: entry.author,
|
|
156
|
+
body: entry.content,
|
|
157
|
+
...(entry.published ? { published: entry.published } : {}),
|
|
158
|
+
children: [],
|
|
159
|
+
}));
|
|
160
|
+
return {
|
|
161
|
+
post: {
|
|
162
|
+
id: identity.id,
|
|
163
|
+
title: postEntry.title,
|
|
164
|
+
author: postEntry.author,
|
|
165
|
+
subreddit: identity.subreddit,
|
|
166
|
+
permalink: identity.path,
|
|
167
|
+
url: postEntry.url || identity.canonicalUrl,
|
|
168
|
+
selftext: postEntry.content,
|
|
169
|
+
},
|
|
170
|
+
thread: [],
|
|
171
|
+
comments,
|
|
172
|
+
outbound_links: dedupeUrls([
|
|
173
|
+
...usefulLinks(context.active.links),
|
|
174
|
+
postEntry.url || identity.canonicalUrl,
|
|
175
|
+
...extractUrls(postEntry.content),
|
|
176
|
+
]),
|
|
177
|
+
partial: true,
|
|
178
|
+
errors: context.errors,
|
|
179
|
+
method: "reddit_rss_public",
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
let arcticFallback = null;
|
|
184
|
+
const arcticPostUrl = `https://arctic-shift.photon-reddit.com/api/posts/ids?ids=${encodeURIComponent(identity.id)}`;
|
|
185
|
+
const arcticPost = await fetchProviderJson(arcticPostUrl, context.timeoutMs, {
|
|
186
|
+
headers: { accept: "application/json,text/plain,*/*" },
|
|
187
|
+
}, {
|
|
188
|
+
mode: "relay",
|
|
189
|
+
sourceUrl,
|
|
190
|
+
});
|
|
191
|
+
if (arcticPost.ok) {
|
|
192
|
+
const posts = asRecordArray(asRecord(arcticPost.data).data);
|
|
193
|
+
const postData = posts.find((item) => asString(item.id) === identity.id);
|
|
194
|
+
if (postData) {
|
|
195
|
+
const treeUrl = `https://arctic-shift.photon-reddit.com/api/comments/tree?link_id=t3_${encodeURIComponent(identity.id)}&limit=200`;
|
|
196
|
+
const tree = await fetchProviderJson(treeUrl, context.timeoutMs, {
|
|
197
|
+
headers: { accept: "application/json,text/plain,*/*" },
|
|
198
|
+
}, {
|
|
199
|
+
mode: "relay",
|
|
200
|
+
sourceUrl,
|
|
201
|
+
});
|
|
202
|
+
if (tree.ok) {
|
|
203
|
+
const comments = asRecordArray(asRecord(tree.data).data)
|
|
204
|
+
.map(mapComment)
|
|
205
|
+
.filter((item) => Boolean(item));
|
|
206
|
+
return normalizePost(postData, identity, comments, "reddit_arctic_shift", false, context.errors, context.active.links);
|
|
207
|
+
}
|
|
208
|
+
arcticFallback = normalizePost(postData, identity, [], "reddit_arctic_shift", true, [
|
|
70
209
|
...context.errors,
|
|
71
|
-
|
|
72
|
-
],
|
|
73
|
-
|
|
74
|
-
};
|
|
210
|
+
tree.error,
|
|
211
|
+
], context.active.links);
|
|
212
|
+
}
|
|
75
213
|
}
|
|
76
|
-
const
|
|
214
|
+
const jsonUrl = `https://www.reddit.com${identity.path}.json?raw_json=1&limit=200`;
|
|
215
|
+
const jsonResult = await fetchProviderJson(jsonUrl, context.timeoutMs, {
|
|
77
216
|
headers: {
|
|
78
217
|
accept: "application/json,text/plain,*/*",
|
|
79
|
-
"user-agent": "
|
|
218
|
+
"user-agent": "smart-web-personal/0.1",
|
|
80
219
|
},
|
|
81
220
|
}, {
|
|
82
221
|
mode: "same-origin",
|
|
83
|
-
sourceUrl
|
|
222
|
+
sourceUrl,
|
|
84
223
|
});
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
],
|
|
97
|
-
method: "reddit_json_public",
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
const postData = result.data?.[0]?.data?.children?.[0]?.data || {};
|
|
101
|
-
const commentListing = (result.data?.[1]?.data?.children || []);
|
|
102
|
-
function mapComment(node) {
|
|
103
|
-
if (!node || node.kind !== "t1")
|
|
104
|
-
return null;
|
|
105
|
-
const data = node.data || {};
|
|
106
|
-
const replies = Array.isArray(data?.replies?.data?.children)
|
|
107
|
-
? data.replies.data.children.map(mapComment).filter(Boolean)
|
|
108
|
-
: [];
|
|
109
|
-
return {
|
|
110
|
-
id: asString(data.id),
|
|
111
|
-
author: asString(data.author),
|
|
112
|
-
body: asString(data.body),
|
|
113
|
-
score: asNumber(data.score),
|
|
114
|
-
created_utc: asNumber(data.created_utc),
|
|
115
|
-
children: replies,
|
|
116
|
-
};
|
|
224
|
+
if (jsonResult.ok && Array.isArray(jsonResult.data)) {
|
|
225
|
+
const postListing = asRecord(jsonResult.data[0]);
|
|
226
|
+
const postChildren = asRecordArray(asRecord(postListing.data).children);
|
|
227
|
+
const postData = asRecord(postChildren[0]?.data);
|
|
228
|
+
const commentListing = asRecord(jsonResult.data[1]);
|
|
229
|
+
const comments = asRecordArray(asRecord(commentListing.data).children)
|
|
230
|
+
.map(mapComment)
|
|
231
|
+
.filter((item) => Boolean(item));
|
|
232
|
+
if (Object.keys(postData).length > 0) {
|
|
233
|
+
return normalizePost(postData, identity, comments, "reddit_json_public", false, context.errors, context.active.links);
|
|
234
|
+
}
|
|
117
235
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
post: {
|
|
128
|
-
id: asString(postData.id),
|
|
129
|
-
title: asString(postData.title),
|
|
130
|
-
author: asString(postData.author),
|
|
131
|
-
subreddit: asString(postData.subreddit),
|
|
132
|
-
permalink: asString(postData.permalink),
|
|
133
|
-
url: asString(postData.url),
|
|
134
|
-
selftext: asString(postData.selftext),
|
|
135
|
-
score: asNumber(postData.score),
|
|
136
|
-
num_comments: asNumber(postData.num_comments),
|
|
137
|
-
},
|
|
138
|
-
thread: [],
|
|
139
|
-
comments,
|
|
140
|
-
outbound_links: dedupeUrls([...usefulLinks(context.active.links), ...Array.from(outbound)]),
|
|
141
|
-
partial: false,
|
|
142
|
-
errors: context.errors,
|
|
143
|
-
method: "reddit_json_public",
|
|
144
|
-
};
|
|
236
|
+
if (arcticFallback)
|
|
237
|
+
return arcticFallback;
|
|
238
|
+
const providerError = !jsonResult.ok ? jsonResult.error : (!rssResult.ok ? rssResult.error : null);
|
|
239
|
+
return failedNormalization(context, "reddit_personal_fallbacks", {
|
|
240
|
+
category: providerError?.category || "unavailable",
|
|
241
|
+
code: providerError?.code || "reddit_retrieval_failed",
|
|
242
|
+
message: providerError?.message || "Reddit retrieval returned no usable post",
|
|
243
|
+
});
|
|
145
244
|
},
|
|
146
245
|
};
|
|
147
246
|
//# sourceMappingURL=reddit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reddit.js","sourceRoot":"","sources":["../../../src/smartfetch/providers/reddit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChH,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;
|
|
1
|
+
{"version":3,"file":"reddit.js","sourceRoot":"","sources":["../../../src/smartfetch/providers/reddit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAChH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAK5E,SAAS,oBAAoB;IAC3B,OAAO,aAAa,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAA;AACtD,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAmB,CAAC,CAAC,CAAC,EAAE,CAAA;AAC/F,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AACvG,CAAC;AAED,SAAS,OAAO,CAAC,OAA0B;IACzC,MAAM,MAAM,G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a,EAAE,IAAI,IAAI,yBAAyB;YACtD,OAAO,EAAE,aAAa,EAAE,OAAO,IAAI,0CAA0C;SAC9E,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
|
package/dist/smartfetch.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export declare function choosePlaywrightContent(page: {
|
|
|
14
14
|
text?: string;
|
|
15
15
|
};
|
|
16
16
|
}): string;
|
|
17
|
-
export declare function shouldUseProviderSeed(target: Target, forceDynamic?: boolean): boolean;
|
|
17
|
+
export declare function shouldUseProviderSeed(target: Target, forceDynamic?: boolean, url?: string): boolean;
|
|
18
18
|
export { planSmartfetchAcquire } from "./smartfetch/acquisition-plan.js";
|
|
19
19
|
export type SmartfetchBudgetResolverInput = {
|
|
20
20
|
outputBudget?: SmartfetchBudgetPreset | undefined;
|
package/dist/smartfetch.js
CHANGED
|
@@ -305,7 +305,9 @@ export function choosePlaywrightWaitUntil(target, url = "") {
|
|
|
305
305
|
export function choosePlaywrightContent(page) {
|
|
306
306
|
return String(page.primary_content?.html || page.content_html || page.html || page.primary_content?.text || page.content_text || page.text || "");
|
|
307
307
|
}
|
|
308
|
-
export function shouldUseProviderSeed(target, forceDynamic) {
|
|
308
|
+
export function shouldUseProviderSeed(target, forceDynamic, url = "") {
|
|
309
|
+
if (target === "reddit_post")
|
|
310
|
+
return !url || /\/comments\/[^/]+(?:\/|$)/i.test(url);
|
|
309
311
|
return !forceDynamic && (target === "youtube_video" || target === "x_post" || target === "solvedac_problem");
|
|
310
312
|
}
|
|
311
313
|
export { planSmartfetchAcquire } from "./smartfetch/acquisition-plan.js";
|
|
@@ -653,7 +655,7 @@ async function runSmartfetchInner(options, runtime = {}) {
|
|
|
653
655
|
...(forceDynamicForProfile !== undefined ? { forceDynamic: forceDynamicForProfile } : {}),
|
|
654
656
|
...(options.download !== undefined ? { download: options.download } : {}),
|
|
655
657
|
...(options.wait_for ? { waitForSelector: options.wait_for } : {}),
|
|
656
|
-
seedAllowed: shouldUseProviderSeed(target, forceDynamicForProfile),
|
|
658
|
+
seedAllowed: shouldUseProviderSeed(target, forceDynamicForProfile, options.url),
|
|
657
659
|
});
|
|
658
660
|
let effectiveLane = acquirePlan.lane;
|
|
659
661
|
let effectiveReason = acquirePlan.reason;
|