searchfetch 4.0.0 → 4.1.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.
- package/README.md +22 -0
- package/package.json +8 -8
- package/src/templates.js +51 -0
package/README.md
CHANGED
|
@@ -137,11 +137,33 @@ The runtimes mirror each other module for module (`templates`, `extract`, `markd
|
|
|
137
137
|
`browser`, `server`). Any change to one should be made to the other, with a shared fixture if
|
|
138
138
|
the behavior is observable.
|
|
139
139
|
|
|
140
|
+
### Releasing
|
|
141
|
+
|
|
142
|
+
Bump `version` in both `package.json` and `pyproject.toml` (then `npm install` and `uv lock`),
|
|
143
|
+
commit, and push a matching tag:
|
|
144
|
+
|
|
145
|
+
```sh
|
|
146
|
+
git tag -a v4.1.1 -m "v4.1.1" && git push origin main v4.1.1
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
The Publish workflow checks that the tag matches both versions, runs lint and unit tests, stages
|
|
150
|
+
the npm release, publishes to PyPI, and then creates the GitHub Release with generated notes. To
|
|
151
|
+
retry a tag, run the workflow manually from the Actions tab with that tag.
|
|
152
|
+
|
|
153
|
+
Both registries use trusted publishing (OIDC), so no tokens are stored in the repository. The npm
|
|
154
|
+
trusted publisher (`maxylev/searchfetch`, workflow `publish.yml`) allows staged publishing only:
|
|
155
|
+
CI runs `npm stage publish` with automatic provenance, and the version goes live after a
|
|
156
|
+
maintainer approves it with 2FA on npmjs.com or with `npm stage list searchfetch` and
|
|
157
|
+
`npm stage approve <stage-id>`. PyPI publishes from the `pypi` environment.
|
|
158
|
+
|
|
140
159
|
### Limits
|
|
141
160
|
|
|
142
161
|
- HTML-to-Markdown conversion uses turndown (Node) and markdownify (Python). They agree on
|
|
143
162
|
common content, but edge cases such as tables differ.
|
|
144
163
|
- After the DOM is ready, each fetch waits up to five seconds for network activity to settle.
|
|
145
164
|
Pages that keep rendering after that may return partial content.
|
|
165
|
+
- CloakBrowser is held at 0.6.x in both runtimes: 0.7 requires a license key (free with email,
|
|
166
|
+
one concurrent session) on every launch and fails without a terminal unless
|
|
167
|
+
`CLOAKBROWSER_LICENSE_KEY` is set, which would break zero-config `uvx`/`npx` use.
|
|
146
168
|
- E2E tests use local fixtures. Live search-engine availability and third-party page layouts
|
|
147
169
|
change over time and need separate live checks.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "searchfetch",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Fault-tolerant MCP server for stealth web search and page fetching",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Max",
|
|
@@ -37,18 +37,18 @@
|
|
|
37
37
|
"check": "scripts/ci-check.sh"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@modelcontextprotocol/sdk": "^1.32.
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.32.2",
|
|
41
41
|
"cheerio": "^1.2.0",
|
|
42
|
-
"cloakbrowser": "^0.6.
|
|
43
|
-
"playwright-core": "^1.
|
|
44
|
-
"turndown": "^7.2.
|
|
42
|
+
"cloakbrowser": "^0.6.5",
|
|
43
|
+
"playwright-core": "^1.65.1",
|
|
44
|
+
"turndown": "^7.2.5",
|
|
45
45
|
"zod": "^4.6.7"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@eslint/js": "^10.0.1",
|
|
49
|
-
"eslint": "^10.
|
|
50
|
-
"globals": "^17.
|
|
51
|
-
"prettier": "^3.
|
|
49
|
+
"eslint": "^10.16.0",
|
|
50
|
+
"globals": "^17.14.0",
|
|
51
|
+
"prettier": "^3.10.1"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
54
|
"node": ">=24.0.0"
|
package/src/templates.js
CHANGED
|
@@ -23,6 +23,41 @@ export const TRANSFORMS = new Set([
|
|
|
23
23
|
export const ENGINE_ALIASES = { duckduckgo: "duckduckgo-search", google: "google-search" };
|
|
24
24
|
|
|
25
25
|
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
26
|
+
const isStringList = (value) =>
|
|
27
|
+
Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
28
|
+
|
|
29
|
+
/** Search engines whose `region`/`safe_search` mapping is built in. */
|
|
30
|
+
export const ENGINES = new Set(["duckduckgo", "google"]);
|
|
31
|
+
|
|
32
|
+
/** Check the optional template-level fields documented in the README. */
|
|
33
|
+
function validateTemplateFields(template, where) {
|
|
34
|
+
if (template.order != null && !Number.isFinite(template.order)) {
|
|
35
|
+
throw new Error(`${where}: "order" must be a number.`);
|
|
36
|
+
}
|
|
37
|
+
for (const key of ["remove", "block_resources"]) {
|
|
38
|
+
if (template[key] != null && !isStringList(template[key])) {
|
|
39
|
+
throw new Error(`${where}: "${key}" must be a list of strings.`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const key of ["source_url", "url_template", "fallback"]) {
|
|
43
|
+
if (template[key] != null && (typeof template[key] !== "string" || !template[key])) {
|
|
44
|
+
throw new Error(`${where}: "${key}" must be a non-empty string.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (template.cookies != null) {
|
|
48
|
+
if (!Array.isArray(template.cookies) || !template.cookies.every(isObject)) {
|
|
49
|
+
throw new Error(`${where}: "cookies" must be a list of objects.`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (template.url_params != null) {
|
|
53
|
+
if (!isObject(template.url_params) || !Object.values(template.url_params).every(isObject)) {
|
|
54
|
+
throw new Error(`${where}: "url_params" must map placeholder names to objects.`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (template.engine != null && !ENGINES.has(template.engine)) {
|
|
58
|
+
throw new Error(`${where}: "engine" must be one of ${[...ENGINES].join(", ")}.`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
26
61
|
|
|
27
62
|
function validateSection(section, where) {
|
|
28
63
|
if (!isObject(section) || typeof section.name !== "string" || !section.name) {
|
|
@@ -45,7 +80,15 @@ function validateSection(section, where) {
|
|
|
45
80
|
) {
|
|
46
81
|
throw new Error(`${label}: "max_items" must be a positive integer.`);
|
|
47
82
|
}
|
|
83
|
+
for (const key of ["required", "multiple"]) {
|
|
84
|
+
if (section[key] != null && typeof section[key] !== "boolean") {
|
|
85
|
+
throw new Error(`${label}: "${key}" must be a boolean.`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
48
88
|
const transforms = section.transform == null ? [] : [section.transform].flat();
|
|
89
|
+
if (!isStringList(transforms)) {
|
|
90
|
+
throw new Error(`${label}: "transform" must be a string or a list of strings.`);
|
|
91
|
+
}
|
|
49
92
|
for (const transform of transforms) {
|
|
50
93
|
if (!TRANSFORMS.has(transform)) throw new Error(`${label}: unknown transform '${transform}'.`);
|
|
51
94
|
}
|
|
@@ -68,6 +111,7 @@ export function validateTemplate(template, where = "template") {
|
|
|
68
111
|
throw new Error(`${where}: template needs a "sections" list.`);
|
|
69
112
|
}
|
|
70
113
|
for (const section of template.sections) validateSection(section, where);
|
|
114
|
+
validateTemplateFields(template, where);
|
|
71
115
|
const patterns = template.url_patterns ?? [];
|
|
72
116
|
if (!Array.isArray(patterns) || patterns.some((pattern) => typeof pattern !== "string")) {
|
|
73
117
|
throw new Error(`${where}: "url_patterns" must be a list of strings.`);
|
|
@@ -119,6 +163,13 @@ export function loadTemplates(directory = TEMPLATES_DIR) {
|
|
|
119
163
|
if (templates.has(template.name)) throw new Error(`Duplicate template '${template.name}'.`);
|
|
120
164
|
templates.set(template.name, template);
|
|
121
165
|
}
|
|
166
|
+
for (const template of templates.values()) {
|
|
167
|
+
if (template.fallback && !templates.has(template.fallback)) {
|
|
168
|
+
throw new Error(
|
|
169
|
+
`Template '${template.name}' falls back to unknown template '${template.fallback}'.`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
122
173
|
return templates;
|
|
123
174
|
}
|
|
124
175
|
|