Python SDK for the PolicyMesh AI Agent Control Platform
Project description
PolicyMesh Python SDK
The official Python SDK for the PolicyMesh AI Agent Control Platform.
Agents propose. PolicyMesh enforces.
Installation
pip install policymesh
Quick Start
from policymesh import PolicyMeshClient
# Initialize the client with your org ID
client = PolicyMeshClient(org_id="your_org_id")
# Evaluate an agent action
decision = client.evaluate(
agent_id="my_agent",
action_type="data_export",
data_classification="confidential",
record_count=1500,
description="Exporting customer records to external email"
)
print(decision.decision) # "block"
print(decision.policy_matched) # "Sensitive Data Export Block"
print(decision.is_blocked) # True
Using the Guard Decorator
from policymesh import PolicyMeshClient
client = PolicyMeshClient(org_id="your_org_id")
@client.guard(action_type="production_deploy", environment="production")
def deploy_to_production():
# This function will be blocked if PolicyMesh says so
print("Deploying to production...")
# If blocked, raises PolicyBlockedError before the function runs
deploy_to_production()
Simple Boolean Check
# Returns True if allowed, False if blocked
if client.allow(agent_id="my_agent", action_type="data_access"):
# proceed with action
pass
Handling Decisions
from policymesh import PolicyMeshClient, PolicyBlockedError, PolicyEscalateError
client = PolicyMeshClient(org_id="your_org_id")
try:
decision = client.evaluate(
agent_id="my_agent",
action_type="production_deploy",
environment="production"
)
if decision.is_flagged:
print("Action flagged but allowed. Proceeding with caution.")
except PolicyBlockedError as e:
print(f"Action blocked: {e.policy_matched}")
except PolicyEscalateError as e:
print(f"Action requires approval: {e.policy_matched}")
Action Types
| Action Type | Description |
|---|---|
data_export |
Exporting data to external systems |
external_email |
Sending emails to external addresses |
production_deploy |
Deploying to production environments |
permission_change |
Modifying user permissions or access |
payment |
Processing payments or vendor actions |
data_access |
Accessing sensitive data |
custom |
Custom action types |
Data Classifications
| Classification | Description |
|---|---|
public |
Publicly available data |
internal |
Internal company data |
confidential |
Confidential business data |
restricted |
Highly restricted or regulated data |
Links
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
policymesh-0.1.0.tar.gz
(5.8 kB
view details)
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 policymesh-0.1.0.tar.gz.
File metadata
- Download URL: policymesh-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71b5b5a6f505134044dcc0346f2dfda3e0625e02bb32699c47fac5029f91f0e9
|
|
| MD5 |
fe8ff91a175877d0668f6f65f73c74bd
|
|
| BLAKE2b-256 |
fb9fdfebd08617492ed7afdbcc9910950149561d6093deb71fb02b0c9dd18bc1
|
File details
Details for the file policymesh-0.1.0-py3-none-any.whl.
File metadata
- Download URL: policymesh-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb6027a895b38d613771b1f48c69d3f31096d5c5c5cfacee3db2dc3c5b4d79db
|
|
| MD5 |
c82ed9720624a53f28ab936845cfcc21
|
|
| BLAKE2b-256 |
1b7a884bb0f0db141a111a1e66210cf7f05d834fc623d8e665535c0c4ba1ac71
|