Skip to main content

crewai-sealgraf

Sealgraf spend-approval tools for CrewAI: before an agent buys anything, it checks the purchase against limits the owner set in advance; purchases above the owner's ask-line wait for the owner's own approval on Sealgraf's surface; every completed purchase is sealed into a receipt neither side can rewrite.

Status: built and tested locally; not yet published to PyPI.

The spend loop

check_permission ── allow ──────────────► buy ──► complete_purchase ──► receipt
       │
       ├── deny ────────────────────────► do not buy
       │
       └── needs_human_approval ──► owner approves in Sealgraf
                                   claim_decision_token ──► buy
                                   complete_purchase ──► receipt

get_receipt reads back either a check (by preauth_id, via GET /v1/preauthorize/{id}) or a sealed receipt (by receipt_id, via GET /v1/receipts/{id}) at any point.

Install

pip install crewai-sealgraf

Configure

The tools need an agent-scope Sealgraf API key. The key is host configuration, never a tool argument (tool arguments are chosen by the model and visible in prompts and logs). Pass it in code or set the environment:

export SEALGRAF_API_KEY=<redacted>
# optional; defaults to https://sealgraf.com
export SEALGRAF_BASE_URL=https://sealgraf.com

Use

from crewai import Agent
from crewai_sealgraf import sealgraf_tools

buyer = Agent(
    role="Purchasing agent",
    goal="Buy approved supplies within the owner's limits",
    backstory="...",
    tools=sealgraf_tools(),          # reads SEALGRAF_API_KEY
)

# or explicitly:
tools = sealgraf_tools(api_key="see_...", base_url="https://sealgraf.com")

The four tools:

Tool Name for the model What it does
SealgrafCheckPermissionTool sealgraf_check_permission Ask before buying. Returns allow (with a single-use decision_token), deny, or needs_human_approval.
SealgrafClaimDecisionTokenTool sealgraf_claim_decision_token After the owner approves, claim the single-use decision token. Fails with a stable code (e.g. not_approved_yet) while the owner has not decided.
SealgrafCompletePurchaseTool sealgraf_complete_purchase After the purchase is made, report it; Sealgraf seals it into a receipt. Amounts are integer minor units (cents).
SealgrafGetReceiptTool sealgraf_get_receipt Read a check's state (by preauth_id) or a sealed receipt (by receipt_id).

Every tool returns the parsed Sealgraf result as JSON — the same shapes as the Sealgraf Dify plugin and MCP surfaces.

Safety behaviour

  • Fail closed. Any failure — timeout, network error, non-2xx, malformed response, a token the server did not actually issue — raises and fails the tool call. A tool never renders an ambiguous answer as permission.
  • Replay honesty. Repeating a check with the same idempotency key returns the original check flagged "replayed": true; a replayed allow does not re-serve the decision token ("decision_token_redelivered": false). Use the token from the first response; if it is lost, run a fresh check without the idempotency key.
  • Tokens are single-use and are passed through untouched; they are never logged by this package.
  • Waiting for approval. After a needs_human_approval check, the owner's decision takes human time. Poll sealgraf_get_receipt for the preauth's state until it reads authorized, then claim — do not call sealgraf_claim_decision_token repeatedly while waiting: every early claim fails with not_approved_yet, and an agent executor will happily retry it in a tight loop (observed live: 6 retries in one run). The refusal is harmless — no token exists before approval — but the polling pattern is cheaper and clearer.

Development

python -m venv .venv && .venv/bin/pip install -e . pytest
.venv/bin/python -m pytest tests/   # mocked HTTP only; no network

Metadata

Release files for crewai-sealgraf 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crewai-sealgraf 0.1.0
File Size Uploaded Provenance Actions
crewai_sealgraf-0.1.0.tar.gz 23.5 kB Without provenance Details for crewai_sealgraf-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for crewai-sealgraf 0.1.0
File Interpreter ABI Platform Actions
crewai_sealgraf-0.1.0-py3-none-any.whl Python 3 none any Details for crewai_sealgraf-0.1.0-py3-none-any.whl

Total release size: 42.0 kB

Release files / crewai_sealgraf-0.1.0.tar.gz

Download URL crewai_sealgraf-0.1.0.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b3e790547b7419dbe37666758045121f2af21b82e974334427e40ca35e3b8ca5
BLAKE2b-256 checksum
How to use checksums
52c690ce18ee1e7928e87e21668a6182aebee6b4e475d5547d3f669aed47af04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / crewai_sealgraf-0.1.0-py3-none-any.whl

Download URL crewai_sealgraf-0.1.0-py3-none-any.whl
Size 18.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4abaf8048497b2868303dca7122d146e168d2f0d1f16e2e97c4cc56b932fe8e
BLAKE2b-256 checksum
How to use checksums
be98fc36752f4b604d32f11bfdc88f32fcc522f168e371d3a1ec8b2a7409c28a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for crewai-sealgraf 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page