aegis-stack-crawl4ai 0.1.0__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 (40) hide show
  1. aegis_stack_crawl4ai-0.1.0/.github/workflows/release.yml +102 -0
  2. aegis_stack_crawl4ai-0.1.0/.github/workflows/test.yml +16 -0
  3. aegis_stack_crawl4ai-0.1.0/.gitignore +10 -0
  4. aegis_stack_crawl4ai-0.1.0/.pre-commit-config.yaml +9 -0
  5. aegis_stack_crawl4ai-0.1.0/LICENSE +202 -0
  6. aegis_stack_crawl4ai-0.1.0/Makefile +16 -0
  7. aegis_stack_crawl4ai-0.1.0/PKG-INFO +317 -0
  8. aegis_stack_crawl4ai-0.1.0/README.md +298 -0
  9. aegis_stack_crawl4ai-0.1.0/pyproject.toml +42 -0
  10. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/__init__.py +1 -0
  11. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/plugin.py +144 -0
  12. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/cli/crawl.py.jinja +460 -0
  13. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/backend/api/crawler/__init__.py.jinja +8 -0
  14. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/backend/api/crawler/router.py.jinja +122 -0
  15. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/frontend/dashboard/cards/crawler_card.py.jinja +84 -0
  16. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/frontend/dashboard/crawler_ui.py.jinja +42 -0
  17. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/frontend/dashboard/modals/crawler_crawl_tab.py.jinja +337 -0
  18. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/frontend/dashboard/modals/crawler_modal.py.jinja +199 -0
  19. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/components/frontend/dashboard/modals/crawler_pages_tab.py.jinja +255 -0
  20. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/__init__.py.jinja +15 -0
  21. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/deps.py.jinja +34 -0
  22. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/dispatch.py.jinja +46 -0
  23. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/health.py.jinja +61 -0
  24. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/jobs.py.jinja +79 -0
  25. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/models.py.jinja +48 -0
  26. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/options.py.jinja +84 -0
  27. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/queries.py.jinja +112 -0
  28. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/schemas.py.jinja +137 -0
  29. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/service.py.jinja +440 -0
  30. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/settings.py.jinja +35 -0
  31. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/app/services/crawler/urls.py.jinja +27 -0
  32. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/components/frontend/test_crawler_tab.py.jinja +230 -0
  33. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/services/test_crawler_jobs.py.jinja +234 -0
  34. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/services/test_crawler_layout.py.jinja +49 -0
  35. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/services/test_crawler_options.py.jinja +197 -0
  36. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/services/test_crawler_sites.py.jinja +110 -0
  37. aegis_stack_crawl4ai-0.1.0/src/aegis_stack_crawl4ai/templates/{{ project_slug }}/tests/services/test_crawler_wiring.py.jinja +48 -0
  38. aegis_stack_crawl4ai-0.1.0/tests/__init__.py +0 -0
  39. aegis_stack_crawl4ai-0.1.0/tests/test_plugin.py +212 -0
  40. aegis_stack_crawl4ai-0.1.0/uv.lock +791 -0
@@ -0,0 +1,102 @@
1
+ name: Release to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*.*.*-rc*' # Pre-release tags (v0.1.0-rc1, etc.) → TestPyPI
7
+ - 'v*.*.*' # Production tags (v0.1.0, etc.) → PyPI
8
+
9
+ jobs:
10
+ build:
11
+ name: Build Package
12
+ runs-on: ubuntu-latest
13
+ env:
14
+ UV_PYTHON: "3.11" # The floor this plugin supports
15
+ UV_LINK_MODE: "copy"
16
+ steps:
17
+ - uses: actions/checkout@v6
18
+ - uses: astral-sh/setup-uv@v7
19
+ with:
20
+ enable-cache: true
21
+ cache-dependency-glob: "uv.lock"
22
+ - run: uv python install 3.11
23
+ - run: uv sync --all-extras
24
+ - run: make check
25
+ - run: uv build
26
+ - uses: actions/upload-artifact@v7
27
+ with:
28
+ name: dist
29
+ path: dist/
30
+ if-no-files-found: error
31
+
32
+ publish-testpypi:
33
+ name: Publish to TestPyPI
34
+ needs: build
35
+ if: contains(github.ref, '-rc')
36
+ runs-on: ubuntu-latest
37
+ permissions:
38
+ id-token: write # REQUIRED for Trusted Publishing
39
+ contents: write # For creating GitHub pre-releases
40
+ environment:
41
+ name: release-test
42
+ url: https://test.pypi.org/project/aegis-stack-crawl4ai/
43
+ steps:
44
+ - uses: actions/download-artifact@v8
45
+ with:
46
+ name: dist
47
+ path: dist/
48
+ - uses: pypa/gh-action-pypi-publish@release/v1
49
+ with:
50
+ repository-url: https://test.pypi.org/legacy/
51
+ print-hash: true
52
+ - id: version
53
+ run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
54
+ - uses: softprops/action-gh-release@v3
55
+ with:
56
+ name: "v${{ steps.version.outputs.VERSION }} (Release Candidate)"
57
+ draft: true
58
+ generate_release_notes: true
59
+ prerelease: true
60
+ files: dist/*
61
+
62
+ publish-pypi:
63
+ name: Publish to PyPI
64
+ needs: build
65
+ if: "!contains(github.ref, '-rc')"
66
+ runs-on: ubuntu-latest
67
+ permissions:
68
+ id-token: write # REQUIRED for Trusted Publishing
69
+ contents: write # For creating GitHub releases
70
+ environment:
71
+ name: release
72
+ url: https://pypi.org/project/aegis-stack-crawl4ai/
73
+ steps:
74
+ - uses: actions/download-artifact@v8
75
+ with:
76
+ name: dist
77
+ path: dist/
78
+ - uses: pypa/gh-action-pypi-publish@release/v1
79
+ with:
80
+ print-hash: true
81
+ attestations: true # Sigstore attestations
82
+ - id: version
83
+ run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
84
+ - uses: softprops/action-gh-release@v3
85
+ with:
86
+ name: "v${{ steps.version.outputs.VERSION }}"
87
+ draft: true
88
+ generate_release_notes: true
89
+ body: |
90
+ ## Installation
91
+
92
+ Inside an Aegis Stack project:
93
+
94
+ ```bash
95
+ pip install aegis-stack-crawl4ai==${{ steps.version.outputs.VERSION }}
96
+ aegis add crawl4ai
97
+ ```
98
+
99
+ - [PyPI](https://pypi.org/project/aegis-stack-crawl4ai/${{ steps.version.outputs.VERSION }}/)
100
+ - [Aegis Stack](https://github.com/lbedner/aegis-stack)
101
+ files: dist/*
102
+ prerelease: false
@@ -0,0 +1,16 @@
1
+ name: test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+
8
+ jobs:
9
+ test:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v6
13
+ - uses: astral-sh/setup-uv@v7
14
+ - run: uv python install 3.12
15
+ - run: uv sync --all-extras
16
+ - run: make check
@@ -0,0 +1,10 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ *.egg-info/
7
+ dist/
8
+ build/
9
+ .coverage
10
+ htmlcov/
@@ -0,0 +1,9 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ # Match aegis-stack's own ``.pre-commit-config.yaml`` so plugin
4
+ # authors get the same lint surface as core devs.
5
+ rev: v0.12.7
6
+ hooks:
7
+ - id: ruff
8
+ args: [--fix]
9
+ - id: ruff-format
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
@@ -0,0 +1,16 @@
1
+ .PHONY: install test lint fix check
2
+
3
+ install:
4
+ uv sync --all-extras
5
+
6
+ test:
7
+ uv run pytest -v
8
+
9
+ lint:
10
+ uv run ruff check .
11
+
12
+ fix:
13
+ uv run ruff format .
14
+ uv run ruff check --fix .
15
+
16
+ check: lint test
@@ -0,0 +1,317 @@
1
+ Metadata-Version: 2.5
2
+ Name: aegis-stack-crawl4ai
3
+ Version: 0.1.0
4
+ Summary: Web crawling and scraping for Aegis Stack projects, via Crawl4AI
5
+ Project-URL: Aegis Plugin, https://aegis-stack.io/plugins/aegis-stack-crawl4ai
6
+ Project-URL: Homepage, https://aegis-stack.io/plugins/aegis-stack-crawl4ai
7
+ Project-URL: Crawl4AI, https://github.com/unclecode/crawl4ai
8
+ Author: Aegis Stack
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: aegis-stack,aegis-stack-plugin,crawl4ai,web-crawling
12
+ Requires-Python: >=3.11
13
+ Requires-Dist: aegis-stack>=0.13.1
14
+ Provides-Extra: dev
15
+ Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
16
+ Requires-Dist: pytest>=9.0.0; extra == 'dev'
17
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # aegis-stack-crawl4ai
21
+
22
+ Web crawling and scraping for [Aegis Stack](https://github.com/lbedner/aegis-stack) projects.
23
+ Wraps [crawl4ai](https://github.com/unclecode/crawl4ai) (Apache 2.0) and persists results
24
+ into a generic, query-friendly `crawled_page` table.
25
+
26
+ This is the reference third-party plugin: it exercises the plugin system end to end and
27
+ rides on per-plugin schema isolation. On Postgres the plugin's tables live in their own
28
+ `crawler` schema, apart from the rest of the stack; SQLite has no schemas, so there the
29
+ table lands unqualified in the single database file.
30
+
31
+ ## Install
32
+
33
+ Inside an Aegis Stack project:
34
+
35
+ ```bash
36
+ pip install aegis-stack-crawl4ai
37
+ aegis add crawl4ai
38
+ ```
39
+
40
+ That will:
41
+
42
+ - Add `crawl4ai>=0.8.6` and `alembic>=1.13` to your project's `pyproject.toml`
43
+ - Render the service (`app/services/crawler/`), its router
44
+ (`app/components/backend/api/crawler/`), the dashboard card and modal, and a
45
+ `crawl` CLI
46
+ - Generate an Alembic migration creating `crawler.crawled_page`
47
+ - Mount the routes below under `/api/v1/crawler`
48
+ - Add a `Crawler` row to the dashboard health table, with its own card and modal
49
+
50
+ The install is HTTP-only: pages are fetched as the server sends them, with no browser.
51
+ Client-rendered content is out of scope.
52
+
53
+ ## Why `>=0.8.6`?
54
+
55
+ Crawl4AI 0.8.5 and earlier pull in a transitive `litellm` dependency that was
56
+ [compromised in a PyPI supply-chain attack](https://github.com/unclecode/crawl4ai/releases).
57
+ 0.8.6 is the hotfix release that swaps in a clean fork. Always pin `>=0.8.6`.
58
+
59
+ ## What you get
60
+
61
+ **Dashboard.** A Crawler card, and a modal with three tabs. *Overview* is the counts.
62
+ *Pages* drills down: the sites you have crawled, then that site's pages, then one page's
63
+ stored body with a copy button. *Crawl* starts a crawl and watches it run, with a row per
64
+ page as it lands.
65
+
66
+ **API.** Six routes under `/api/v1/crawler`:
67
+
68
+ | route | does |
69
+ |---|---|
70
+ | `POST /crawl` | fetch one URL, store it, return the row |
71
+ | `POST /crawl-batch` | start a background crawl, return `202` + a `job_id` |
72
+ | `GET /sites` | crawled sites, with page and failure counts |
73
+ | `GET /pages` | recent pages, newest first; `?site=` narrows, `?failed_only=` filters |
74
+ | `GET /pages/{id}` | one stored page |
75
+ | `GET /stats` | counts, distinct URLs, content-type split, last fetch |
76
+
77
+ **CLI.** `<project> crawl stats | fetch | site | list | show | retry-failed`.
78
+
79
+ **Progress.** A batch crawl runs as a framework job, so progress streams over
80
+ `/api/v1/jobs/{job_id}/events` and the dashboard follows it without knowing anything about
81
+ the crawler.
82
+
83
+ ## Crawl options
84
+
85
+ Defaults reproduce a single-page fetch. `crawl4ai`'s `CrawlerRunConfig` takes about a
86
+ hundred parameters; these are the handful that change what you actually get back, and the
87
+ API, the CLI and the dashboard share them.
88
+
89
+ | option | default | does |
90
+ |---|---|---|
91
+ | `depth` | `0` | how many links deep to follow (hard ceiling of 3) |
92
+ | `max_pages` | `25` | ceiling on pages per seed URL when `depth > 0` |
93
+ | `stay_on_domain` | `true` | follow links only within the seed's site |
94
+ | `selector` | none | CSS selector: keep only this part of each page |
95
+ | `min_words` | `0` | drop blocks shorter than this many words (nav, chrome) |
96
+ | `fresh` | `false` | bypass the network cache and row-level dedup |
97
+
98
+ ```bash
99
+ <project> crawl site example.com --depth 1 --max-pages 50 --selector "main article"
100
+ ```
101
+
102
+ ## Settings
103
+
104
+ Composed into your project's `Settings`, so they are ordinary env vars:
105
+
106
+ | setting | default | does |
107
+ |---|---|---|
108
+ | `CRAWLER_DEFAULT_TIMEOUT_S` | `30` | per-URL fetch timeout |
109
+ | `CRAWLER_MAX_CONCURRENCY` | `5` | in-flight requests during a batch |
110
+ | `CRAWLER_USER_AGENT` | `aegis-stack-crawl4ai/0.1` | `User-Agent` sent on every request |
111
+
112
+ ## The `crawled_page` table
113
+
114
+ Generic by design: URL, content, content hash, JSONB metadata, status code, source kind.
115
+ Future ingestion plugins (RSS, PDF, sitemap) can share the schema or follow the same shape.
116
+
117
+ | column | type | notes |
118
+ |----------------|-----------------|-------------------------------------------------------------|
119
+ | `id` | int PK | autoincrement |
120
+ | `source_url` | text | indexed |
121
+ | `site` | varchar(255) | registrable host, `www.` stripped; indexed, and what the sites view groups by |
122
+ | `content` | text | nullable (failures still produce a row) |
123
+ | `content_hash` | varchar(64) | sha256, indexed (use for dedup queries) |
124
+ | `content_type` | varchar(32) | `markdown` / `html` / `json` / `binary` |
125
+ | `doc_metadata` | jsonb | caller-supplied tags, e.g. `{"ign_id": 5208, "cluster": 9}` |
126
+ | `status_code` | int | HTTP status; `>= 400` is your retry queue |
127
+ | `source_kind` | varchar(32) | producer label (`crawl4ai`, `rss`, `pdf_ingest`, ...) |
128
+ | `fetched_at` | timestamptz | indexed |
129
+
130
+ Re-fetching a URL writes a new row; dedup-by-hash is a query you run when you care, not a
131
+ write-path branch.
132
+
133
+ ## Use from Python
134
+
135
+ ```python
136
+ from app.core.db import AsyncSessionLocal
137
+ from app.services.crawler.deps import get_crawler
138
+ from app.services.crawler.options import CrawlOptions
139
+
140
+ crawler = get_crawler() # process-wide instance; the API and health check share it
141
+
142
+ async with AsyncSessionLocal() as session:
143
+ doc = await crawler.fetch(
144
+ session,
145
+ url="https://example.com",
146
+ doc_metadata={"campaign": "march"},
147
+ )
148
+ print(doc.id, doc.status_code, len(doc.content or ""))
149
+
150
+ # Follow links, one level, staying on the site.
151
+ pages = await crawler.crawl(
152
+ session,
153
+ url="https://example.com",
154
+ options=CrawlOptions(depth=1, max_pages=50),
155
+ )
156
+ ```
157
+
158
+ A short-lived script that owns its crawler should build its own and close it:
159
+
160
+ ```python
161
+ from app.services.crawler.service import CrawlerService
162
+
163
+ crawler = CrawlerService()
164
+ try:
165
+ ...
166
+ finally:
167
+ await crawler.aclose()
168
+ ```
169
+
170
+ ## Use from the API
171
+
172
+ ```bash
173
+ curl -X POST http://localhost:8000/api/v1/crawler/crawl \
174
+ -H 'Content-Type: application/json' \
175
+ -d '{"url": "example.com", "doc_metadata": {"campaign": "march"}}'
176
+
177
+ curl -X POST http://localhost:8000/api/v1/crawler/crawl-batch \
178
+ -H 'Content-Type: application/json' \
179
+ -d '{"urls": ["example.com"], "options": {"depth": 1, "max_pages": 50}}'
180
+
181
+ curl http://localhost:8000/api/v1/crawler/sites
182
+ curl "http://localhost:8000/api/v1/crawler/pages?site=example.com&limit=10"
183
+ ```
184
+
185
+ A bare domain is fine anywhere a URL is taken: `example.com` becomes `https://example.com`
186
+ on the way into the request model.
187
+
188
+ ## Bulk fetch example: NWVault recovery
189
+
190
+ The motivating use case for the plugin: walk a local mirror of a deceased site, extract the
191
+ identifiers each page references, fetch the corresponding archived snapshot from
192
+ web.archive.org, and store both the body and the local-file pointer for later reconciliation.
193
+
194
+ ```python
195
+ import asyncio
196
+ from pathlib import Path
197
+ from app.core.db import AsyncSessionLocal
198
+ from app.services.crawler.service import CrawlerService
199
+
200
+ NWVAULT_LOCAL = Path("/path/to/nwvault-legacy")
201
+
202
+
203
+ def parse_ign_link(html_path: Path) -> tuple[int, int] | None:
204
+ """Pull the IGN cluster + id out of a local html page. Returns None if the
205
+ page doesn't reference an archived ratings link."""
206
+ # ... your parser ...
207
+ return None
208
+
209
+
210
+ async def main() -> None:
211
+ crawler = CrawlerService()
212
+ try:
213
+ urls: list[str] = []
214
+ meta: dict[str, dict] = {}
215
+ for html in NWVAULT_LOCAL.rglob("*.html"):
216
+ parsed = parse_ign_link(html)
217
+ if not parsed:
218
+ continue
219
+ cluster, ign_id = parsed
220
+ url = (
221
+ "https://web.archive.org/web/2006/"
222
+ f"http://nwvault.ign.com/View.php?view=Ratings.Viewer"
223
+ f"&cluster={cluster}&id={ign_id}"
224
+ )
225
+ urls.append(url)
226
+ meta[url] = {
227
+ "local_file": str(html.relative_to(NWVAULT_LOCAL)),
228
+ "ign_id": ign_id,
229
+ "cluster": cluster,
230
+ "source": "ign_archive",
231
+ }
232
+
233
+ await crawler.batch_fetch(
234
+ AsyncSessionLocal,
235
+ urls=urls,
236
+ doc_metadata_for=meta,
237
+ )
238
+ finally:
239
+ await crawler.aclose()
240
+
241
+
242
+ asyncio.run(main())
243
+ ```
244
+
245
+ Then query by your domain identifiers:
246
+
247
+ ```sql
248
+ SELECT content
249
+ FROM crawler.crawled_page
250
+ WHERE doc_metadata->>'ign_id' = '5208'
251
+ ORDER BY fetched_at DESC
252
+ LIMIT 1;
253
+ ```
254
+
255
+ Failed fetches don't tank the batch; the retry queue is just:
256
+
257
+ ```sql
258
+ SELECT source_url
259
+ FROM crawler.crawled_page
260
+ WHERE status_code IS NULL OR status_code >= 400;
261
+ ```
262
+
263
+ or `<project> crawl retry-failed`.
264
+
265
+ ## Layout
266
+
267
+ The plugin follows the host project's own conventions rather than inventing its
268
+ own: business logic under `app/services/`, reads in a `queries` module, the HTTP
269
+ layer with the other routers, display code with the other dashboard code.
270
+
271
+ ```
272
+ aegis-stack-crawl4ai/
273
+ ├── pyproject.toml # entry point: aegis.plugins:crawl4ai
274
+ ├── src/aegis_stack_crawl4ai/
275
+ │ ├── plugin.py # get_spec() returns the PluginSpec
276
+ │ └── templates/{{ project_slug }}/
277
+ │ ├── app/services/crawler/
278
+ │ │ ├── service.py # AsyncWebCrawler wrapper
279
+ │ │ ├── queries.py # every read, so an N+1 audit is one file
280
+ │ │ ├── models.py # CrawledPage SQLModel
281
+ │ │ ├── schemas.py # Pydantic request / response
282
+ │ │ ├── options.py # CrawlOptions, the shared knobs
283
+ │ │ ├── urls.py # bare domain -> fetchable URL
284
+ │ │ ├── jobs.py # what a crawl job does
285
+ │ │ ├── dispatch.py # where it runs
286
+ │ │ ├── deps.py # FastAPI DI, one crawler per process
287
+ │ │ ├── settings.py # settings mixin (leaf module)
288
+ │ │ └── health.py # dashboard health check
289
+ │ ├── app/components/backend/api/crawler/
290
+ │ │ └── router.py # FastAPI router
291
+ │ ├── app/components/frontend/dashboard/
292
+ │ │ ├── crawler_ui.py # names, routes and cells the surfaces share
293
+ │ │ ├── cards/crawler_card.py
294
+ │ │ └── modals/crawler_*.py # modal, pages tab, crawl tab
295
+ │ ├── app/cli/crawl.py # crawl commands
296
+ │ └── tests/ # shipped into the project and run there
297
+ └── tests/
298
+ └── test_plugin.py # spec contract tests
299
+ ```
300
+
301
+ ## Develop
302
+
303
+ ```bash
304
+ make install # uv sync
305
+ make test # pytest
306
+ make check # lint + test
307
+ make fix # ruff format + autofix
308
+ ```
309
+
310
+ `tests/test_plugin.py` checks the spec contract here. The tests under
311
+ `templates/{{ project_slug }}/tests/` ship into the generated project and run
312
+ against the real service there, including a layout test that holds the plugin to
313
+ the host project's structure.
314
+
315
+ ## License
316
+
317
+ Apache 2.0, same as upstream crawl4ai.