foxfetch 0.1.1__tar.gz → 0.1.3__tar.gz

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 (30) hide show
  1. {foxfetch-0.1.1 → foxfetch-0.1.3}/INSTALL.md +4 -0
  2. foxfetch-0.1.3/PKG-INFO +393 -0
  3. foxfetch-0.1.3/README.md +344 -0
  4. foxfetch-0.1.3/README.zh.md +339 -0
  5. {foxfetch-0.1.1 → foxfetch-0.1.3}/pyproject.toml +9 -1
  6. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/__init__.py +1 -1
  7. foxfetch-0.1.1/PKG-INFO +0 -241
  8. foxfetch-0.1.1/README.md +0 -192
  9. foxfetch-0.1.1/SETUP.md +0 -204
  10. foxfetch-0.1.1/dsh/cordis.patch.yml +0 -5
  11. foxfetch-0.1.1/dsh/index.js +0 -352
  12. foxfetch-0.1.1/dsh/package.json +0 -48
  13. foxfetch-0.1.1/tests/conftest.py +0 -6
  14. foxfetch-0.1.1/tests/test_contexts.py +0 -118
  15. foxfetch-0.1.1/tests/test_engine.py +0 -78
  16. foxfetch-0.1.1/tests/test_probe.py +0 -99
  17. foxfetch-0.1.1/tests/test_shapes.py +0 -78
  18. foxfetch-0.1.1/tools/push_via_api.py +0 -223
  19. {foxfetch-0.1.1 → foxfetch-0.1.3}/.gitignore +0 -0
  20. {foxfetch-0.1.1 → foxfetch-0.1.3}/LICENSE +0 -0
  21. {foxfetch-0.1.1 → foxfetch-0.1.3}/dsh/README.md +0 -0
  22. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/__main__.py +0 -0
  23. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/cli.py +0 -0
  24. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/config.py +0 -0
  25. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/contexts.py +0 -0
  26. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/doctor.py +0 -0
  27. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/engine.py +0 -0
  28. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/probe.py +0 -0
  29. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/server.py +0 -0
  30. {foxfetch-0.1.1 → foxfetch-0.1.3}/src/foxfetch/shapes.py +0 -0
@@ -1,5 +1,9 @@
1
1
  # Install
2
2
 
3
+ > The same content lives in [README.md](README.md) (English) and [README.zh.md](README.zh.md)
4
+ > (简体中文), which is what most people want. This file is the longer reference: it keeps the
5
+ > doctor output, the interpreter-path note and the troubleshooting table in one place.
6
+
3
7
  Two pieces, always two:
4
8
 
5
9
  | Piece | What it is | Where it comes from |
@@ -0,0 +1,393 @@
1
+ Metadata-Version: 2.5
2
+ Name: foxfetch
3
+ Version: 0.1.3
4
+ Summary: Fetch pages through a real Firefox engine (ruyijs) for AI agents: pass bot checks, run the page's own JavaScript, then hand the identity to Chromium when a screenshot is needed.
5
+ Project-URL: Homepage, https://github.com/zhuchongba-01/foxfetch
6
+ Project-URL: Repository, https://github.com/zhuchongba-01/foxfetch
7
+ Project-URL: Issues, https://github.com/zhuchongba-01/foxfetch/issues
8
+ Project-URL: Changelog, https://github.com/zhuchongba-01/foxfetch/commits/master
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 foxfetch contributors
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+
31
+ Note: `ruyijs`, the Firefox engine this package drives, is a separate project
32
+ under AGPL-3.0. foxfetch only imports and calls it; no ruyijs code is bundled.
33
+ License-File: LICENSE
34
+ Keywords: agent,anti-bot,firefox,mcp,playwright,ruyijs,scraping
35
+ Classifier: Environment :: Console
36
+ Classifier: Intended Audience :: Developers
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Operating System :: Microsoft :: Windows
39
+ Classifier: Operating System :: POSIX :: Linux
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Topic :: Internet :: WWW/HTTP :: Browsers
42
+ Requires-Python: >=3.10
43
+ Requires-Dist: mcp<2,>=1.30
44
+ Requires-Dist: ruyijs>=0.4.5
45
+ Provides-Extra: dev
46
+ Requires-Dist: mypy>=1.10; extra == 'dev'
47
+ Requires-Dist: pytest>=8; extra == 'dev'
48
+ Description-Content-Type: text/markdown
49
+
50
+ # foxfetch
51
+
52
+ **Read pages that block plain HTTP — by running them in a real Firefox engine.**
53
+
54
+ [English](README.md) · [简体中文](README.zh.md)
55
+
56
+ [![PyPI](https://img.shields.io/pypi/v/foxfetch?logo=pypi&label=PyPI)](https://pypi.org/project/foxfetch/)
57
+ [![Python](https://img.shields.io/pypi/pyversions/foxfetch?logo=python&logoColor=white)](https://pypi.org/project/foxfetch/)
58
+ [![npm plugin](https://img.shields.io/npm/v/dsh-foxfetch?logo=npm&label=dsh-foxfetch)](https://www.npmjs.com/package/dsh-foxfetch)
59
+ [![License](https://img.shields.io/pypi/l/foxfetch)](LICENSE)
60
+
61
+ `curl` gets a 403. Headless Chrome gets fingerprinted. foxfetch uses a real Firefox engine
62
+ (SpiderMonkey + Necko, no window, no renderer) to run the site's own JavaScript, pass the bot
63
+ check, and read what only a browser can see. When a screenshot is needed, it hands the identity
64
+ it earned to Chromium.
65
+
66
+ ---
67
+
68
+ ## Install in 30 seconds
69
+
70
+ **1. Install the service** (once per machine):
71
+
72
+ ```bash
73
+ pip install foxfetch
74
+ ```
75
+
76
+ **2. Check it** — should print `"ok": true`:
77
+
78
+ ```bash
79
+ python -m foxfetch doctor
80
+ ```
81
+
82
+ **3. Connect your agent** — this step differs per host, because the hosts live on different
83
+ platforms:
84
+
85
+ ```
86
+ the service (one, shared)
87
+ python -m foxfetch serve ← pip install foxfetch
88
+ ▲
89
+ ┌───────────────┴────────────────┐
90
+ │ │
91
+ MCP clients (Pi, Claude Code, DeepSeek Harness
92
+ Codex, anything else) (native plugin API)
93
+ → a config entry pointing → an npm plugin that forwards
94
+ at the command above to the command above
95
+ │ │
96
+ Pi: pi mcp add foxfetch cd ~/.dsh/profiles/desktop
97
+ -- python -m foxfetch pnpm add dsh-foxfetch
98
+ serve (+ add to dsh.profile.bundles)
99
+ ```
100
+
101
+ | Your agent | Platform | What you install for it |
102
+ |---|---|---|
103
+ | **Pi** | MCP | `pi mcp add foxfetch -- python -m foxfetch serve` |
104
+ | **Claude Code** | MCP | `claude mcp add foxfetch -- python -m foxfetch serve` |
105
+ | **Codex** | MCP | a `[mcp_servers.foxfetch]` table in `~/.codex/config.toml` → [steps](#codex) |
106
+ | **DeepSeek Harness** | **npm plugin** | `pnpm add dsh-foxfetch` in the profile → [steps](#deepseek-harness) |
107
+ | **Other MCP client** | MCP | `command: python`, `args: ["-m", "foxfetch", "serve"]` |
108
+
109
+ Only DSH needs the npm package. Every MCP client talks to the Python service directly, so
110
+ `pip install foxfetch` is the **only** install they need.
111
+
112
+ **4. Prove it works** — ask your agent:
113
+
114
+ ```
115
+ foxfetch_run(js="navigator.userAgent", url="https://example.com")
116
+ ```
117
+
118
+ You must see `Firefox/160.0` in the answer. If you see `Python-urllib` or `HeadlessChrome`, the
119
+ agent is not talking to the engine — nothing else will work until you fix it.
120
+
121
+ > **One entry per host.** Never add both an MCP entry and the DSH plugin to the same agent:
122
+ > you would get the same seven tools twice (`foxfetch_run` and `mcp__foxfetch__run`).
123
+
124
+ ---
125
+
126
+ ## Detailed install
127
+
128
+ ### Requirements
129
+
130
+ There are two platforms involved, and it matters:
131
+
132
+ - **the service** — one Python package, `pip install foxfetch`, shared by every host.
133
+ - **the host entry** — a different mechanism per host: an MCP config entry for Pi / Claude
134
+ Code / Codex, an npm plugin for DSH.
135
+
136
+ - **Python 3.10+** — that is all. Chromium is optional (screenshots only).
137
+ - The `ruyijs` engine (44 MB wheel) comes in automatically as a dependency.
138
+
139
+ If `doctor` reports a problem, run the command it prints. The three that happen:
140
+
141
+ | `doctor` says | Fix |
142
+ |---|---|
143
+ | `ruyijs` missing or `< 0.4.5` | `pip install -U "ruyijs>=0.4.5"` |
144
+ | `mcp` is 2.x | `pip install "mcp>=1.30,<2"` — 2.x renamed `FastMCP`; this server cannot import it |
145
+ | `chromium: found: false` | optional: `npx playwright install chromium` |
146
+
147
+ **Which Python?** The agent must start the same interpreter that `pip install` used:
148
+
149
+ ```powershell
150
+ (Get-Command python).Source # Windows
151
+ which python3 # macOS / Linux
152
+ ```
153
+
154
+ ```bash
155
+ # If it is not plain `python`, put the absolute path in the config:
156
+ # "command": "C:/Users/you/AppData/Local/Programs/Python/Python314/python.exe"
157
+ ```
158
+
159
+ ### Pi
160
+
161
+ `pi mcp add foxfetch -- python -m foxfetch serve`
162
+
163
+ Or write `~/.pi/agent/mcp.json` yourself:
164
+
165
+ ```json
166
+ {
167
+ "mcpServers": {
168
+ "foxfetch": {
169
+ "command": "python",
170
+ "args": ["-m", "foxfetch", "serve"],
171
+ "timeout": 180
172
+ }
173
+ }
174
+ }
175
+ ```
176
+
177
+ Verify: `pi mcp list` → `foxfetch: connected, 7 tools`.
178
+ Inside a running Pi session, `/reload` picks it up.
179
+
180
+ ### Claude Code
181
+
182
+ `claude mcp add foxfetch -- python -m foxfetch serve`
183
+
184
+ Verify: `claude mcp list`.
185
+
186
+ ### Codex
187
+
188
+ Append to `~/.codex/config.toml`, then restart Codex:
189
+
190
+ ```toml
191
+ [mcp_servers.foxfetch]
192
+ command = "python"
193
+ args = ["-m", "foxfetch", "serve"]
194
+ ```
195
+
196
+ ### DeepSeek Harness
197
+
198
+ DSH has a native plugin API, so it gets a real plugin instead of an MCP entry. The plugin holds
199
+ no logic — it starts the same Python service and reshapes results for the DSH UI.
200
+
201
+ ```powershell
202
+ # 1. service (same as everyone else)
203
+ pip install foxfetch
204
+
205
+ # 2. plugin, into the DSH profile
206
+ cd "$env:USERPROFILE\.dsh\profiles\desktop"
207
+ pnpm add dsh-foxfetch
208
+
209
+ # 3. register it (keep the entries already in the file)
210
+ $pkg = Get-Content package.json -Raw | ConvertFrom-Json
211
+ if ($pkg.dsh.profile.bundles -notcontains "dsh-foxfetch") {
212
+ $pkg.dsh.profile.bundles += "dsh-foxfetch"
213
+ }
214
+ $pkg | ConvertTo-Json -Depth 20 | Set-Content package.json
215
+
216
+ # 4. restart DSH
217
+ ```
218
+
219
+ The result should look like this:
220
+
221
+ ```json
222
+ {
223
+ "name": "dsh-profile-desktop",
224
+ "private": true,
225
+ "dependencies": {
226
+ "dsh-foxfetch": "^0.1.1"
227
+ },
228
+ "dsh": {
229
+ "profile": {
230
+ "bundles": [
231
+ "@deepseek-ai/dsh-base",
232
+ "@deepseek-ai/dsh-web-app",
233
+ "dsh-foxfetch"
234
+ ]
235
+ }
236
+ }
237
+ }
238
+ ```
239
+
240
+ `pnpm` not on PATH? DSH ships its own:
241
+
242
+ ```powershell
243
+ $dsh = "$env:USERPROFILE\.dsh\dsh-runtimes\dsh-primary-runtime\dependencies"
244
+ $node = Join-Path $dsh "node\bin\node.exe"
245
+ $pnpm = Join-Path $dsh "pnpm\bin\pnpm.cjs"
246
+ & $node $pnpm add dsh-foxfetch
247
+ ```
248
+
249
+ After restarting DSH the tool list shows `foxfetch_probe`, `foxfetch_run`, `foxfetch_net`,
250
+ `foxfetch_handoff`, `foxfetch_close`, `foxfetch_cleanup`, `foxfetch_status` — and no
251
+ `mcp__foxfetch__*` entries.
252
+
253
+ ### Any other MCP client
254
+
255
+ Most clients take the same stdio block:
256
+
257
+ ```json
258
+ {
259
+ "mcpServers": {
260
+ "foxfetch": {
261
+ "command": "python",
262
+ "args": ["-m", "foxfetch", "serve"]
263
+ }
264
+ }
265
+ }
266
+ ```
267
+
268
+ ---
269
+
270
+ ## What you get
271
+
272
+ Seven tools:
273
+
274
+ | Tool | What it does |
275
+ |---|---|
276
+ | `probe` | Classify a URL — `plain_http` / `needs_engine` / `blocked` — with the evidence |
277
+ | `run` | Evaluate JavaScript in the engine; returns the value, console and request log |
278
+ | `net` | Read the request log and console of a live context |
279
+ | `handoff` | Export cookies (incl. HttpOnly), localStorage, UA; write a Playwright script |
280
+ | `close` | Close one context (by id or origin) or all of them |
281
+ | `cleanup` | Delete artifacts, close contexts, sweep temp scratch dirs |
282
+ | `status` | Live contexts, artifact usage, environment check |
283
+
284
+ ### Use the cheapest layer
285
+
286
+ | Situation | Use |
287
+ |---|---|
288
+ | Static HTML, JSON endpoints, RSS | plain HTTP — **do not call foxfetch** |
289
+ | Content appears only after JS runs | `run` |
290
+ | 403 / Cloudflare / DataDome / Kasada | `probe`, then `run` |
291
+ | Someone needs to *see* the page | `handoff` → the generated Playwright script |
292
+
293
+ ```
294
+ probe("https://shop.example/item")
295
+ → verdict: blocked
296
+ evidence: HTTP 403, DataDome (matched 'datadome'), 512 bytes, 0 visible text
297
+ suggestion: use run — the engine's TLS and JS profile match a real Firefox
298
+ ```
299
+
300
+ The engine costs ~90 MB of RAM and ~3 s per open. On a page `curl` could have fetched, that buys
301
+ nothing — hence `probe`.
302
+
303
+ ### Contexts
304
+
305
+ One engine world per origin, kept alive between calls, so a multi-step flow is several small
306
+ calls instead of one giant script:
307
+
308
+ ```python
309
+ run("window.step = 1", url="https://x.test") # opens the page
310
+ run("window.step + 1") # → 2, same document
311
+ run("fetch('/api/me').then(r => r.text())",
312
+ advance_ms=800, read="window.__last") # carries the cookies earned above
313
+ ```
314
+
315
+ A context dies on `close`, after `FOXFETCH_IDLE_SECONDS` (default 60) of silence, or when the pool
316
+ exceeds `FOXFETCH_MAX_CONTEXTS` (default 2) — least recently used first.
317
+
318
+ ---
319
+
320
+ ## Configuration
321
+
322
+ | Variable | Default | Meaning |
323
+ |---|---|---|
324
+ | `FOXFETCH_HOME` | `%LOCALAPPDATA%\foxfetch` | Artifact root (credentials pass through it) |
325
+ | `FOXFETCH_MAX_CONTEXTS` | 2 | Live contexts before LRU eviction |
326
+ | `FOXFETCH_IDLE_SECONDS` | 60 | Silence before a context is killed |
327
+ | `FOXFETCH_TIMEOUT_MS` | 30000 | Default navigation budget |
328
+ | `FOXFETCH_MAX_BYTES` | 65536 | Output cap before spilling to a file |
329
+ | `FOXFETCH_ARTIFACT_TTL` | 86400 | Seconds before an artifact is deleted |
330
+ | `FOXFETCH_ARTIFACT_MAX` | 67108864 | Artifact directory byte budget |
331
+ | `FOXFETCH_REMIND_AFTER` | 600 | Seconds before responses start reminding about pending artifacts (0 disables) |
332
+ | `FOXFETCH_PY` | — | Interpreter the DSH plugin starts |
333
+
334
+ ## Safety
335
+
336
+ `handoff` writes **live credentials** — cookies including the HttpOnly ones page script cannot
337
+ read. They land under `FOXFETCH_HOME`, owner-only, and expire after `FOXFETCH_ARTIFACT_TTL`.
338
+
339
+ Every tool response reports what is still on disk, and once a file is older than
340
+ `FOXFETCH_REMIND_AFTER` the response grows a `reminder` telling the agent to call `cleanup` and to
341
+ pass `keep=[...]` for anything the user still needs to look at. The field disappears the moment
342
+ cleanup runs, so a stale reminder is a visible bug rather than a silent one.
343
+
344
+ ## What it is not
345
+
346
+ - Not a screenshot tool, not a clicker, not a layout engine — Chromium does that, once it has the
347
+ identity `handoff` exported.
348
+ - Not a session store: every context is fresh, nothing survives `close`.
349
+ - Not a fingerprint randomiser: guessing a profile that matches nobody is worse than sending a
350
+ real Firefox.
351
+
352
+ ## Development
353
+
354
+ ```bash
355
+ pip install -e '.[dev]'
356
+ pytest -q # 45 tests, no network
357
+ mypy src # strict
358
+ ```
359
+
360
+ ```bash
361
+ # when github.com:443 is reset but api.github.com answers, push through the API
362
+ python tools/push_via_api.py --repo <owner>/<name> --dry-run
363
+ ```
364
+
365
+ The tests encode the bugs this rewrite exists to prevent: a clip that split UTF-8 sequences, a URL
366
+ compare that ignored the trailing slash, `sameSite: "Default"` rejected by Playwright, a `cleanup`
367
+ that only deleted expired files, and a runaway browser left behind when the screenshot threw.
368
+
369
+ ## Troubleshooting
370
+
371
+ | Symptom | Cause | Fix |
372
+ |---|---|---|
373
+ | `cannot start the Python service` (DSH) | the plugin found a different interpreter | set `FOXFETCH_PY` to the absolute path |
374
+ | `ModuleNotFoundError: mcp.server.fastmcp` | `mcp` 2.x installed | `pip install "mcp>=1.30,<2"` |
375
+ | `no live context for that origin` | context idled out (60 s) or was evicted | pass `url` again, or keep `context_id` |
376
+ | `navigation produced an empty document` | slow page, or one that needs a real renderer | raise `timeout_ms`, or use `handoff` + Chromium |
377
+ | tools appear twice | two entries in one host | remove one |
378
+ | `pip install` stops mid-download | flaky network to `files.pythonhosted.org` | retry, or `pip install --proxy http://127.0.0.1:7897 foxfetch` |
379
+
380
+ ## Uninstall
381
+
382
+ ```bash
383
+ pip uninstall foxfetch
384
+ ```
385
+
386
+ Artifacts: `%LOCALAPPDATA%\foxfetch` (Windows) or `~/.local/share/foxfetch`. Then delete the host
387
+ entry — the `mcpServers` block, the `[mcp_servers.foxfetch]` table, or the `dsh-foxfetch`
388
+ dependency plus its bundle line.
389
+
390
+ ## Licence
391
+
392
+ MIT. The engine (`ruyijs`) is a separate project under AGPL-3.0; foxfetch only calls it — no
393
+ ruyijs code is bundled.