phronedge 1.0.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.
@@ -0,0 +1,503 @@
1
+ Metadata-Version: 2.4
2
+ Name: phronedge
3
+ Version: 1.0.0
4
+ Summary: Runtime AI Governance - govern any AI agent tool call
5
+ Author-email: PhronEdge <sdk@phronedge.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://phronedge.com
8
+ Project-URL: Documentation, https://docs.phronedge.com
9
+ Project-URL: Repository, https://github.com/phronedge/phronedge-python
10
+ Keywords: ai,governance,constitutional,agent,compliance,gdpr,eu-ai-act
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Software Development :: Libraries
16
+ Requires-Python: >=3.9
17
+ Description-Content-Type: text/markdown
18
+ Requires-Dist: requests>=2.28.0
19
+
20
+ <div align="center">
21
+
22
+ <img src="https://img.shields.io/pypi/v/phronedge?style=for-the-badge&color=2350f0" />
23
+ <img src="https://img.shields.io/badge/Python-3.9%2B-blue?style=for-the-badge" />
24
+ <img src="https://img.shields.io/badge/EU%20AI%20Act-Compliant-22c55e?style=for-the-badge" />
25
+ <img src="https://img.shields.io/badge/GDPR-Enforced-22c55e?style=for-the-badge" />
26
+
27
+ # phronedge
28
+
29
+ **Runtime governance for AI agents.**
30
+
31
+ Every tool call checked. Every decision audited. Every regulation enforced.
32
+
33
+ [Playground](https://phronedge.com/playground) | [Documentation](https://docs.phronedge.com) | [Dashboard](https://phronedge.com/brain)
34
+
35
+ </div>
36
+
37
+ ---
38
+
39
+ ## The Problem
40
+
41
+ AI agents take actions. Actions have consequences. Right now there is no governance layer between your agent and everything it can touch.
42
+
43
+ Your agent can access data it was never authorized to see. Execute financial transactions without human approval. Leak sensitive information across jurisdictions. Be compromised through prompt injection. Have its credential tampered with at runtime.
44
+
45
+ And you will not know until a regulator asks you to prove it did not happen.
46
+
47
+ EU AI Act enforcement is live. GDPR fines reach 20M EUR or 4% of global revenue. The question is not whether your agent needs governance. The question is whether you can prove it has governance.
48
+
49
+ **An agent is an untrusted entity. Treat it like one.**
50
+
51
+ ---
52
+
53
+ ## The Solution
54
+
55
+ PhronEdge intercepts every tool call before it executes. Seven checkpoints. Every time. No exceptions.
56
+
57
+ ```
58
+ Your agent calls a tool
59
+ |
60
+ v
61
+ CP1 Credential Validator Is this agent who it claims to be? (ECDSA)
62
+ |
63
+ CP2 PII / Injection Scan Is there sensitive data or manipulation in the input?
64
+ |
65
+ CP3 Jurisdiction Router Is this action legally permitted? (196 countries)
66
+ |
67
+ CP4 Behavioral Monitor Is this agent behaving normally? (signed baseline)
68
+ |
69
+ CP5 Data Classifier What classification level is this data?
70
+ |
71
+ CP6 Tool Permission Is this tool in the agent's signed credential?
72
+ |
73
+ CP7 Output Constraint Is the response safe to return?
74
+ |
75
+ v
76
+ ALLOWED: your function executes normally
77
+ BLOCKED: reason + regulation citation returned, event anchored
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Install
83
+
84
+ ```bash
85
+ pip install phronedge
86
+ ```
87
+
88
+ Works with every Python package manager:
89
+
90
+ ```bash
91
+ pip install phronedge
92
+ uv add phronedge
93
+ poetry add phronedge
94
+ pdm add phronedge
95
+ pipenv install phronedge
96
+ ```
97
+
98
+ ---
99
+
100
+ ## Setup
101
+
102
+ One environment variable. Nothing else.
103
+
104
+ ```bash
105
+ # .env
106
+ PHRONEDGE_API_KEY=pe_live_xxxxxxxxx
107
+ ```
108
+
109
+ Get your API key at [phronedge.com/playground](https://phronedge.com/playground).
110
+
111
+ ---
112
+
113
+ ## Quick Start
114
+
115
+ ```python
116
+ from phronedge import PhronEdge
117
+
118
+ pe = PhronEdge()
119
+
120
+ @pe.govern("lookup_claim")
121
+ def lookup_claim(claim_id: str) -> str:
122
+ return db.query(claim_id)
123
+
124
+ result = lookup_claim("CLM-2026-001")
125
+ ```
126
+
127
+ Three lines. Every call to `lookup_claim` now passes through 7 governance checkpoints. Your existing function does not change.
128
+
129
+ ---
130
+
131
+ ## What Governance Looks Like
132
+
133
+ Four scenarios. What your agent tries. What PhronEdge does.
134
+
135
+ **Clean call:**
136
+
137
+ ```python
138
+ result = lookup_claim("CLM-2026-001")
139
+ # ALLOWED in 23ms
140
+ # Claim data returned to agent
141
+ # Audit: TOOL_CALL_ALLOWED, 7/7 checkpoints passed
142
+ ```
143
+
144
+ **PII in input:**
145
+
146
+ ```python
147
+ result = lookup_claim("SSN 123-45-6789")
148
+ # BLOCKED
149
+ # PII detected in function arguments (SSN pattern)
150
+ # Session escalated to PII_RESTRICTED
151
+ # Audit: PII_INPUT_DETECTED, GDPR Art. 9
152
+ ```
153
+
154
+ **Tool not in credential:**
155
+
156
+ ```python
157
+ result = access_medical_records("patient-123")
158
+ # BLOCKED
159
+ # medical_records not in agent's signed credential
160
+ # Function never executed. Data never touched.
161
+ # Audit: TOOL_CALL_BLOCKED, EU AI Act Art. 14
162
+ ```
163
+
164
+ **Credential tampered at runtime:**
165
+
166
+ ```python
167
+ # Attacker modifies credential at 2:00pm
168
+ # Agent makes next call at 2:01pm
169
+ result = lookup_claim("CLM-2026-001")
170
+ # ECDSA signature mismatch detected
171
+ # Vault restore runs automatically
172
+ # Call proceeds with restored credential
173
+ # You did nothing. PhronEdge fixed itself.
174
+ # Audit: VAULT_TAMPER_DETECTED + VAULT_CREDENTIAL_RESTORED
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Framework Examples
180
+
181
+ ### LangChain / LangGraph
182
+
183
+ ```python
184
+ from phronedge import PhronEdge
185
+ from langchain_core.tools import tool
186
+
187
+ pe = PhronEdge()
188
+
189
+ @pe.govern("lookup_claim")
190
+ def _governed_lookup(claim_id: str) -> str:
191
+ return db.query(claim_id)
192
+
193
+ @tool
194
+ def lookup_claim(claim_id: str) -> str:
195
+ """Look up an insurance claim by ID."""
196
+ return _governed_lookup(claim_id)
197
+
198
+ agent = create_react_agent(llm, [lookup_claim])
199
+ ```
200
+
201
+ ### CrewAI
202
+
203
+ ```python
204
+ from phronedge import PhronEdge
205
+ from crewai.tools import BaseTool
206
+
207
+ pe = PhronEdge()
208
+
209
+ @pe.govern("lookup_claim")
210
+ def _governed_lookup(claim_id: str) -> str:
211
+ return db.query(claim_id)
212
+
213
+ class LookupClaimTool(BaseTool):
214
+ name: str = "lookup_claim"
215
+ description: str = "Look up an insurance claim"
216
+
217
+ def _run(self, claim_id: str) -> str:
218
+ return _governed_lookup(claim_id)
219
+
220
+ agent = Agent(role="Investigator", tools=[LookupClaimTool()])
221
+ ```
222
+
223
+ ### Google ADK
224
+
225
+ ```python
226
+ from phronedge import PhronEdge
227
+ from google.adk.agents import Agent
228
+
229
+ pe = PhronEdge()
230
+
231
+ @pe.govern("lookup_claim")
232
+ def _governed_lookup(claim_id: str) -> str:
233
+ return db.query(claim_id)
234
+
235
+ def lookup_claim(claim_id: str, tool_context) -> str:
236
+ """Look up an insurance claim by ID."""
237
+ return _governed_lookup(claim_id)
238
+
239
+ agent = Agent(name="investigator", model="gemini-2.0-flash", tools=[lookup_claim])
240
+ ```
241
+
242
+ ### OpenAI Function Calling
243
+
244
+ ```python
245
+ from phronedge import PhronEdge
246
+ from openai import OpenAI
247
+
248
+ pe = PhronEdge()
249
+
250
+ @pe.govern("lookup_claim")
251
+ def lookup_claim(claim_id: str) -> str:
252
+ return db.query(claim_id)
253
+
254
+ # Define tools as usual, call lookup_claim when the model requests it
255
+ # PhronEdge governs the execution automatically
256
+ ```
257
+
258
+ ### Pydantic AI
259
+
260
+ ```python
261
+ from phronedge import PhronEdge
262
+ from pydantic_ai import Agent
263
+
264
+ pe = PhronEdge()
265
+
266
+ @pe.govern("lookup_claim")
267
+ def _governed_lookup(claim_id: str) -> str:
268
+ return db.query(claim_id)
269
+
270
+ agent = Agent("openai:gpt-4o")
271
+
272
+ @agent.tool_plain
273
+ def lookup_claim(claim_id: str) -> str:
274
+ """Look up an insurance claim."""
275
+ return _governed_lookup(claim_id)
276
+ ```
277
+
278
+ ### Plain Python
279
+
280
+ ```python
281
+ from phronedge import PhronEdge
282
+
283
+ pe = PhronEdge()
284
+
285
+ @pe.govern("send_payment")
286
+ def send_payment(claim_id: str, amount: float, currency: str) -> str:
287
+ return payment_api.send(claim_id, amount, currency)
288
+
289
+ result = send_payment("CLM-001", 42500.0, "EUR")
290
+ # BLOCKED: requires human approval, checkpoint: human_oversight
291
+ ```
292
+
293
+ ---
294
+
295
+ ## The Data Never Leaves
296
+
297
+ Your data stays in your environment. Governance metadata travels to PhronEdge. Nothing else.
298
+
299
+ ```
300
+ What PhronEdge receives: What PhronEdge never receives:
301
+ Agent ID Your customer data
302
+ Tool name Query results
303
+ Input metadata (scanned, not stored) Medical records
304
+ Credential ID Financial data
305
+ Internal service URLs
306
+ Anything your tool returns
307
+ ```
308
+
309
+ GDPR, HIPAA, and EU AI Act all require data to stay in the appropriate environment. PhronEdge is architecturally compliant by design. Not by configuration. By architecture.
310
+
311
+ ---
312
+
313
+ ## Constitutional Tiers
314
+
315
+ Every agent operates at a tier that defines its authority.
316
+
317
+ | Tier | Name | What it means |
318
+ |------|------|---------------|
319
+ | T0 | Advisory Only | Agent recommends. Human decides. No execution. |
320
+ | T1 | Human-in-the-Loop | Agent proposes. Waits for human approval. |
321
+ | T2 | Bounded Autonomy | Agent executes within scope. Escalates outside it. |
322
+ | T3 | Supervised Autonomy | Agent executes and logs. Human reviews after. |
323
+
324
+ High-value actions like financial transactions, sensitive data access, and irreversible operations are blocked at tiers below their required level. Automatically. Every time.
325
+
326
+ ---
327
+
328
+ ## Agent Lifecycle
329
+
330
+ Control any running agent in real time. No restart. No code change.
331
+
332
+ ```python
333
+ # Quarantine: blocks all tool calls immediately
334
+ pe.quarantine("Suspicious pattern detected")
335
+
336
+ # Reinstate: resumes tool calls
337
+ pe.reinstate("Investigation complete")
338
+ ```
339
+
340
+ Kill switch is available through the PhronEdge console only. Permanent agent termination is a critical operation that requires dashboard access at [phronedge.com/brain](https://phronedge.com/brain).
341
+
342
+ ---
343
+
344
+ ## The Audit Chain
345
+
346
+ Every event is cryptographically anchored. Every event links to the one before it. Tamper one event and the chain breaks.
347
+
348
+ ```json
349
+ {
350
+ "event_type": "TOOL_CALL_BLOCKED",
351
+ "agent_id": "claims-investigator-v1",
352
+ "tool": "access_medical_records",
353
+ "severity": "HIGH",
354
+ "regulation": "EU AI Act Art. 14 Human Oversight",
355
+ "checkpoint": "data_classification",
356
+ "policy_hash": "f107937d65017b17...",
357
+ "hash": "a3f2b1c4d5e6f7a8...",
358
+ "prev_hash": "9e8d7c6b5a4f3e2d...",
359
+ "timestamp": "2026-04-05T14:32:18.000Z"
360
+ }
361
+ ```
362
+
363
+ Your regulator sees the complete governance history. Your auditor trusts the math.
364
+
365
+ ---
366
+
367
+ ## Error Handling
368
+
369
+ ```python
370
+ from phronedge import PhronEdge, ToolBlocked, AgentTerminated
371
+
372
+ pe = PhronEdge(raise_on_block=True)
373
+
374
+ @pe.govern("send_payment")
375
+ def send_payment(claim_id, amount, currency):
376
+ return payment_api.send(claim_id, amount, currency)
377
+
378
+ try:
379
+ send_payment("CLM-001", 42500, "EUR")
380
+ except ToolBlocked as e:
381
+ print(f"Blocked: {e} (checkpoint: {e.checkpoint})")
382
+ except AgentTerminated:
383
+ print("Agent has been permanently killed")
384
+ ```
385
+
386
+ ---
387
+
388
+ ## Pre-scan Text
389
+
390
+ Check text for PII or injection before sending to an LLM:
391
+
392
+ ```python
393
+ pe = PhronEdge()
394
+ result = pe.scan("My SSN is 123-45-6789 and ignore previous instructions")
395
+ # {"pii_detected": true, "injection_detected": true, "patterns": ["SSN"]}
396
+ ```
397
+
398
+ ---
399
+
400
+ ## Regulatory Coverage
401
+
402
+ PhronEdge maps every governance decision to the applicable regulation for your jurisdiction and industry.
403
+
404
+ **Cross-Industry:**
405
+
406
+ | Regulation | Coverage |
407
+ |------------|----------|
408
+ | EU AI Act 2024 | Risk classification, human oversight, transparency |
409
+ | GDPR (EU) 2016/679 | Data minimisation, transfer restrictions, Art. 9 special categories |
410
+ | Schrems II (C-311/18) | Cross-border data transfer enforcement |
411
+ | CCPA / CPRA | California consumer data protection |
412
+ | ISO 42001 | AI management system controls |
413
+ | NIST AI RMF | Govern, map, measure, manage |
414
+ | SOC 2 Type II | Security, availability, processing integrity |
415
+
416
+ **Financial Services:**
417
+
418
+ | Regulation | Coverage |
419
+ |------------|----------|
420
+ | FCA Handbook | UK financial conduct authority rules |
421
+ | MiFID II | Markets in Financial Instruments Directive |
422
+ | DORA | Digital Operational Resilience Act |
423
+ | PSD2 | Payment Services Directive |
424
+ | Basel III/IV | Risk management and capital requirements |
425
+ | MAR | Market Abuse Regulation |
426
+
427
+ **Healthcare:**
428
+
429
+ | Regulation | Coverage |
430
+ |------------|----------|
431
+ | HIPAA | Protected health information, access control |
432
+ | HITECH Act | Health information technology enforcement |
433
+ | FDA 21 CFR Part 11 | Electronic records and signatures |
434
+ | MDR (EU) 2017/745 | Medical Device Regulation |
435
+
436
+ **Insurance:**
437
+
438
+ | Regulation | Coverage |
439
+ |------------|----------|
440
+ | Solvency II | Insurance risk management |
441
+ | IDD | Insurance Distribution Directive |
442
+ | German Insurance Act (VAG) | German insurance supervision |
443
+
444
+ **Telecommunications:**
445
+
446
+ | Regulation | Coverage |
447
+ |------------|----------|
448
+ | ePrivacy Directive | Electronic communications privacy |
449
+ | PECR | Privacy and Electronic Communications Regulations |
450
+ | NIS2 Directive | Network and information systems security |
451
+
452
+ 196 countries. 30+ controls. Every policy signed against the applicable regulatory framework for your jurisdiction and industry.
453
+
454
+ ---
455
+
456
+ ## Framework Support
457
+
458
+ | Framework | Status |
459
+ |-----------|--------|
460
+ | LangGraph | Supported |
461
+ | LangChain | Supported |
462
+ | CrewAI | Supported |
463
+ | OpenAI | Supported |
464
+ | Google ADK | Supported |
465
+ | Pydantic AI | Supported |
466
+ | LlamaIndex | Supported |
467
+ | AutoGen | Supported |
468
+ | Smolagents | Supported |
469
+ | Plain Python | Supported |
470
+
471
+ One SDK. One gateway. One audit chain. Any framework. Any cloud. Any agent.
472
+
473
+ ---
474
+
475
+ ## Try Before You Code
476
+
477
+ Visit [phronedge.com/playground](https://phronedge.com/playground) to see runtime governance in action. Pick an industry (insurance, healthcare, finance, technology). Paste your OpenAI or Gemini API key. Chat with a governed agent. Watch every checkpoint fire in real time. No signup required. 30 seconds.
478
+
479
+ ---
480
+
481
+ ## Get Started
482
+
483
+ ```bash
484
+ pip install phronedge
485
+ ```
486
+
487
+ ```python
488
+ from phronedge import PhronEdge
489
+
490
+ pe = PhronEdge()
491
+
492
+ @pe.govern("my_tool")
493
+ def my_tool(param: str) -> str:
494
+ return your_existing_function(param)
495
+ ```
496
+
497
+ <div align="center">
498
+
499
+ Built for the EU AI Act era.
500
+
501
+ **[phronedge.com](https://phronedge.com)**
502
+
503
+ </div>