@allansantos-dev/smart-tool 0.9.40 → 0.9.42
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 +43 -0
- package/README.md +11 -7
- package/client_hooks.py +94 -31
- package/config.py +1 -1
- package/dependency_notice.py +136 -32
- package/document_text.py +274 -47
- package/freshness.py +16 -10
- package/hook_decision.py +9 -7
- package/hooks/session_audit.py +1 -1
- package/index_profile.py +1 -1
- package/index_scope.py +9 -1
- package/indexer.py +4 -2
- package/model_breaker.py +70 -0
- package/model_client.py +17 -10
- package/model_health.py +46 -4
- package/package.json +1 -1
- package/project_monitor.py +17 -2
- package/scout.py +1 -1
- package/setup_ui.py +55 -22
- package/smart_tool_daemon.py +120 -64
- package/usage_meter.py +13 -0
- package/version.py +1 -1
- package/web_fetch.py +7 -7
package/version.py
CHANGED
package/web_fetch.py
CHANGED
|
@@ -38,8 +38,7 @@ SELECT_BUDGET_CHARS = 15_000
|
|
|
38
38
|
CHUNK_CHARS = 2_000
|
|
39
39
|
PAGE_FORMAT = 2
|
|
40
40
|
MAX_DOWNLOAD_BYTES = 5 * 1024 * 1024
|
|
41
|
-
|
|
42
|
-
PDF_TIMEOUT_S = 30
|
|
41
|
+
PDF_INTERACTIVE_TIMEOUT_S = 30 # Override of document_text.PDF_TIMEOUT_S: a person waits for this answer, the indexer does not.
|
|
43
42
|
MAX_REDIRECTS = 5
|
|
44
43
|
HTTP_TIMEOUT_S = 20
|
|
45
44
|
READ_CHUNK = 64 * 1024
|
|
@@ -212,12 +211,13 @@ def thin(text):
|
|
|
212
211
|
|
|
213
212
|
|
|
214
213
|
def pdf_text(body, url, deadline):
|
|
215
|
-
"""Text of a PDF (pypdf, pure Python), page by page
|
|
216
|
-
sends it here, so a PDF used to be a dead end (9 times in 10 days of transcripts).
|
|
217
|
-
parse for minutes, so it runs in a subprocess killed at the request's deadline (at most
|
|
218
|
-
|
|
214
|
+
"""Text of a PDF (pypdf, pure Python), page by page, with the page and character caps of document_text. The native
|
|
215
|
+
WebFetch reads PDFs and the hook sends it here, so a PDF used to be a dead end (9 times in 10 days of transcripts).
|
|
216
|
+
A hostile PDF can make pypdf parse for minutes, so it runs in a subprocess killed at the request's deadline (at most
|
|
217
|
+
PDF_INTERACTIVE_TIMEOUT_S, passed to document_text.run_pdf instead of the indexer's document_text.PDF_TIMEOUT_S)."""
|
|
218
|
+
timeout = min(PDF_INTERACTIVE_TIMEOUT_S, _left(deadline))
|
|
219
219
|
try:
|
|
220
|
-
return document_text.run_pdf(body, timeout, PDF_MAX_PAGES,
|
|
220
|
+
return document_text.run_pdf(body, timeout, document_text.PDF_MAX_PAGES, document_text.PDF_MAX_CHARS)
|
|
221
221
|
except document_text.PdfTimeout:
|
|
222
222
|
raise FetchError(f"PDF not read in {timeout:.0f}s ({url}).") from None
|
|
223
223
|
except document_text.PdfUnreadable as exc:
|