Thin Python client for the SafeBrowse localhost daemon
Project description
safebrowse-client
Thin Python client for the SafeBrowse localhost daemon.
The client is intentionally narrow: policy enforcement lives in the daemon, while this package provides convenient request helpers for the current /v6/* API surface.
Model-guard support is exposed through daemon responses such as GET /health and compiledObservation.modelAssessment. The Python client does not package or download trained model bundles; compatible sidecars and bundles are private deployment material.
Install
pip install safebrowse-client
What It Covers
GET /healthPOST /v6/session/startPOST /v6/observePOST /v6/action/evaluatePOST /v6/artifact/ingestPOST /v6/artifact/extractPOST /v6/approval/issuePOST /v6/tool/preparePOST /v6/tool/callback/verifyPOST /v6/memory/stagePOST /v6/memory/promotePOST /v6/memory/rollbackPOST /v6/replay/bundle
Basic Example
from safebrowse_client import SafeBrowseClient, build_html_surface_capture
client = SafeBrowseClient("http://127.0.0.1:8787")
session = client.start_session(
{
"taskId": "docs-review-1",
"userGoal": "Read the page and stay read-only unless explicit authority is minted.",
"allowedOrigins": ["https://docs.python.org"],
"allowedVerbs": ["navigate", "api_read"],
}
)
compiled = client.observe(
{
"sessionId": session["session"]["sessionId"],
"capture": build_html_surface_capture(
url="https://docs.python.org/3/",
visible_text="Python 3 documentation home page",
html="<main>Python 3 documentation home page</main>",
),
}
)
Raw Email and OOXML Helpers
The capture builders support either structured extracted fields or raw bytes:
build_email_surface_capture(..., raw_mime_bytes=...)build_docx_surface_capture(..., content_bytes=...)build_xlsx_surface_capture(..., content_bytes=...)build_pptx_surface_capture(..., content_bytes=...)build_external_api_surface_capture(...)build_attachment_bundle_surface_capture(...)
Example:
from safebrowse_client import build_email_surface_capture
capture = build_email_surface_capture(
url="https://mail.example.com/message/123",
provider_id="mail.example.com",
subject="Quarterly report",
body_text="Please review the attachment.",
raw_mime_bytes=b"From: sender@example.com\r\nSubject: Quarterly report\r\n\r\nPlease review the attachment.",
)
Model-Connected Browser Template
The wheel also includes a starter template:
from safebrowse_client import write_model_connected_browser_agent_template
path = write_model_connected_browser_agent_template("model_connected_browser_agent.py")
print(path)
Repository:
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file safebrowse_client-0.1.5.tar.gz.
File metadata
- Download URL: safebrowse_client-0.1.5.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3050a996a72f382031e391c7528d47b496751889cc31c6985c885f7c07bc499
|
|
| MD5 |
47aa30c00d069092f3d9d6aaf97ac161
|
|
| BLAKE2b-256 |
5d5c6801bd374386720eedeadc3faf66e4b6499d2fed3c9c180d196c1a2640e5
|
File details
Details for the file safebrowse_client-0.1.5-py3-none-any.whl.
File metadata
- Download URL: safebrowse_client-0.1.5-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e6eaccb4066e73ca13f5dc6ef76b180c1903a5021e7804359ab3cdc4f4854f7
|
|
| MD5 |
73423539c42368bce9b56d3684cc63ec
|
|
| BLAKE2b-256 |
861e8a6d3175261e381f3a5ac7ec5adefff1b8aacf839c8e9f4b80bda5a465b0
|