breach-intel-client 0.3.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,55 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ *.so
7
+ *.egg
8
+ *.egg-info/
9
+ dist/
10
+ build/
11
+ .eggs/
12
+ *.whl
13
+
14
+ # Virtual environments
15
+ .venv/
16
+ venv/
17
+ env/
18
+
19
+ # Database
20
+ *.db
21
+ *.sqlite3
22
+
23
+ # Environment / secrets
24
+ .env
25
+ .env.*
26
+ !.env.example
27
+
28
+ # pytest
29
+ .pytest_cache/
30
+ .coverage
31
+ htmlcov/
32
+
33
+ # Editors
34
+ .vscode/
35
+ .idea/
36
+ *.swp
37
+ *.swo
38
+ *~
39
+
40
+ # macOS
41
+ .DS_Store
42
+ .AppleDouble
43
+
44
+ # Node / TypeScript (openclaw plugin)
45
+ node_modules/
46
+ *.js.map
47
+ dist/
48
+ *.tsbuildinfo
49
+
50
+ # Logs
51
+ *.log
52
+ logs/
53
+
54
+ # Docker
55
+ .docker/
@@ -0,0 +1,109 @@
1
+ Metadata-Version: 2.4
2
+ Name: breach-intel-client
3
+ Version: 0.3.0
4
+ Summary: Python SDK for the Breach Intel Policy Agent — attach any AI agent to breach logging in one import
5
+ Project-URL: Homepage, https://github.com/parthamehta123/breach-intel
6
+ Project-URL: Repository, https://github.com/parthamehta123/breach-intel
7
+ Project-URL: Bug Tracker, https://github.com/parthamehta123/breach-intel/issues
8
+ Author-email: Partha Mehta <parthamehta123@gmail.com>
9
+ License: MIT
10
+ Keywords: agents,ai,audit,breach,compliance,fintech,healthcare,pharma,policy
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Security
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.9
22
+ Provides-Extra: async
23
+ Requires-Dist: httpx>=0.27; extra == 'async'
24
+ Provides-Extra: dev
25
+ Requires-Dist: httpx>=0.27; extra == 'dev'
26
+ Requires-Dist: pytest>=8; extra == 'dev'
27
+ Requires-Dist: respx>=0.21; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # breach-intel-client
31
+
32
+ > Python SDK for the [Breach Intel Policy Agent](https://github.com/parthamehta123/breach-intel).
33
+ > Drop into any Python AI agent in 2 lines.
34
+
35
+ ```bash
36
+ pip install breach-intel-client
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ ```python
42
+ from breach_intel_client import PolicyAgentClient
43
+
44
+ # Initialize (agent_id from register() below)
45
+ client = PolicyAgentClient(
46
+ base_url="http://your-policy-agent:8080",
47
+ agent_id="your-agent-id",
48
+ vertical="fintech",
49
+ silent=True, # never block your agent if policy agent is down
50
+ )
51
+
52
+ # Wrap your LLM calls
53
+ response = my_llm.generate(prompt)
54
+ result = client.emit_llm_response(response.text, tenant_id="customer-001")
55
+
56
+ if result.is_breach:
57
+ print(f"[BREACH] {result.breach_types} — severity: {result.severity}")
58
+ print(f"Breach ID for audit: {result.breach_id}")
59
+ ```
60
+
61
+ ## Registration
62
+
63
+ Call once at agent startup:
64
+
65
+ ```python
66
+ reg = client.register(
67
+ agent_name="Portfolio Advisor v2",
68
+ owner_id="acme-corp",
69
+ declared_capabilities=["read_portfolio", "get_market_data", "send_report"],
70
+ approved_domains=["api.bloomberg.com", "smtp.acme.com"],
71
+ )
72
+ client.agent_id = reg.agent_id # save this
73
+ ```
74
+
75
+ ## Emitting Events
76
+
77
+ | Method | Use when |
78
+ |--------|----------|
79
+ | `emit_llm_response(text)` | Any LLM output |
80
+ | `emit_tool_call(name, args)` | Before/after tool invocation |
81
+ | `emit_api_request(method, url, body)` | Any outbound HTTP call |
82
+ | `emit(event_type, payload)` | Any other event |
83
+
84
+ ## Async Support
85
+
86
+ ```python
87
+ # pip install breach-intel-client[async]
88
+ from breach_intel_client import AsyncPolicyAgentClient
89
+
90
+ async with AsyncPolicyAgentClient("http://localhost:8080", agent_id="...") as client:
91
+ result = await client.emit_llm_response_async(text, tenant_id="cust-001")
92
+ ```
93
+
94
+ ## Querying Breaches
95
+
96
+ ```python
97
+ # All breaches for this agent
98
+ breaches = client.get_breaches(severity="CRITICAL")
99
+
100
+ # Single record
101
+ breach = client.get_breach("br-xyz")
102
+
103
+ # Tamper check
104
+ integrity = client.verify_breach("br-xyz")
105
+ print(integrity["tampered"]) # False = clean
106
+
107
+ # Summary counts
108
+ print(client.summary())
109
+ ```
@@ -0,0 +1,80 @@
1
+ # breach-intel-client
2
+
3
+ > Python SDK for the [Breach Intel Policy Agent](https://github.com/parthamehta123/breach-intel).
4
+ > Drop into any Python AI agent in 2 lines.
5
+
6
+ ```bash
7
+ pip install breach-intel-client
8
+ ```
9
+
10
+ ## Quick Start
11
+
12
+ ```python
13
+ from breach_intel_client import PolicyAgentClient
14
+
15
+ # Initialize (agent_id from register() below)
16
+ client = PolicyAgentClient(
17
+ base_url="http://your-policy-agent:8080",
18
+ agent_id="your-agent-id",
19
+ vertical="fintech",
20
+ silent=True, # never block your agent if policy agent is down
21
+ )
22
+
23
+ # Wrap your LLM calls
24
+ response = my_llm.generate(prompt)
25
+ result = client.emit_llm_response(response.text, tenant_id="customer-001")
26
+
27
+ if result.is_breach:
28
+ print(f"[BREACH] {result.breach_types} — severity: {result.severity}")
29
+ print(f"Breach ID for audit: {result.breach_id}")
30
+ ```
31
+
32
+ ## Registration
33
+
34
+ Call once at agent startup:
35
+
36
+ ```python
37
+ reg = client.register(
38
+ agent_name="Portfolio Advisor v2",
39
+ owner_id="acme-corp",
40
+ declared_capabilities=["read_portfolio", "get_market_data", "send_report"],
41
+ approved_domains=["api.bloomberg.com", "smtp.acme.com"],
42
+ )
43
+ client.agent_id = reg.agent_id # save this
44
+ ```
45
+
46
+ ## Emitting Events
47
+
48
+ | Method | Use when |
49
+ |--------|----------|
50
+ | `emit_llm_response(text)` | Any LLM output |
51
+ | `emit_tool_call(name, args)` | Before/after tool invocation |
52
+ | `emit_api_request(method, url, body)` | Any outbound HTTP call |
53
+ | `emit(event_type, payload)` | Any other event |
54
+
55
+ ## Async Support
56
+
57
+ ```python
58
+ # pip install breach-intel-client[async]
59
+ from breach_intel_client import AsyncPolicyAgentClient
60
+
61
+ async with AsyncPolicyAgentClient("http://localhost:8080", agent_id="...") as client:
62
+ result = await client.emit_llm_response_async(text, tenant_id="cust-001")
63
+ ```
64
+
65
+ ## Querying Breaches
66
+
67
+ ```python
68
+ # All breaches for this agent
69
+ breaches = client.get_breaches(severity="CRITICAL")
70
+
71
+ # Single record
72
+ breach = client.get_breach("br-xyz")
73
+
74
+ # Tamper check
75
+ integrity = client.verify_breach("br-xyz")
76
+ print(integrity["tampered"]) # False = clean
77
+
78
+ # Summary counts
79
+ print(client.summary())
80
+ ```
@@ -0,0 +1,61 @@
1
+ """
2
+ breach-intel-client — Python SDK for the Breach Intel Policy Agent
3
+
4
+ Zero stdlib dependencies. Drop into any Python AI agent.
5
+
6
+ pip install breach-intel-client
7
+
8
+ Quick start:
9
+ from breach_intel_client import PolicyAgentClient
10
+
11
+ client = PolicyAgentClient("http://localhost:8080", agent_id="your-agent-id")
12
+ result = client.emit_llm_response(llm_output, tenant_id="cust-001")
13
+ if result.is_breach:
14
+ print(f"BREACH: {result.breach_types}")
15
+
16
+ Passive mode (zero code — just set env vars):
17
+ BREACH_INTEL_URL=http://localhost:8080 python your_agent.py
18
+ """
19
+
20
+ from .client import (
21
+ BreachRecord,
22
+ EventResult,
23
+ PolicyAgentClient,
24
+ RegistrationResult,
25
+ )
26
+ from .auto import (
27
+ monitor,
28
+ auto_monitor,
29
+ auto_attach,
30
+ get_client,
31
+ LangChainBreachHandler,
32
+ )
33
+
34
+ # AsyncPolicyAgentClient requires httpx — import conditionally
35
+ try:
36
+ from .client import AsyncPolicyAgentClient # type: ignore
37
+ except ImportError:
38
+ AsyncPolicyAgentClient = None # type: ignore
39
+
40
+ __version__ = "0.3.0"
41
+ __all__ = [
42
+ "PolicyAgentClient",
43
+ "AsyncPolicyAgentClient",
44
+ "EventResult",
45
+ "BreachRecord",
46
+ "RegistrationResult",
47
+ # Auto-instrumentation
48
+ "monitor",
49
+ "auto_monitor",
50
+ "auto_attach",
51
+ "get_client",
52
+ "LangChainBreachHandler",
53
+ ]
54
+
55
+ # ─── Import-time passive activation ──────────────────────────────────────────
56
+ # If BREACH_INTEL_URL is set, auto-attach on import. Silent by default —
57
+ # never breaks the importing application.
58
+
59
+ import os as _os
60
+ if _os.environ.get("BREACH_INTEL_URL"):
61
+ auto_attach()