cortexhub 0.1.0__py3-none-any.whl

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,275 @@
1
+ Metadata-Version: 2.4
2
+ Name: cortexhub
3
+ Version: 0.1.0
4
+ Summary: CortexHub Python SDK - Policy-as-Code for AI Agents
5
+ Project-URL: Homepage, https://cortexhub.ai
6
+ Project-URL: Documentation, https://docs.cortexhub.ai
7
+ Project-URL: Repository, https://github.com/cortexhub/sdks
8
+ Project-URL: Issues, https://github.com/cortexhub/sdks/issues
9
+ Author-email: CortexHub <hello@cortexhub.ai>
10
+ License: MIT
11
+ Keywords: agents,ai,authorization,cedar,governance,policy
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: <3.14,>=3.10
22
+ Requires-Dist: cedarpy>=4.0.0
23
+ Requires-Dist: detect-secrets>=1.5.0
24
+ Requires-Dist: httpx>=0.28.0
25
+ Requires-Dist: opentelemetry-api>=1.20.0
26
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20.0
27
+ Requires-Dist: opentelemetry-sdk>=1.20.0
28
+ Requires-Dist: pip>=23.0
29
+ Requires-Dist: presidio-analyzer>=2.2.360
30
+ Requires-Dist: presidio-anonymizer>=2.2.360
31
+ Requires-Dist: pydantic>=2.9.0
32
+ Requires-Dist: python-dotenv>=1.0.0
33
+ Requires-Dist: structlog>=24.4.0
34
+ Provides-Extra: all
35
+ Requires-Dist: anthropic>=0.40.0; extra == 'all'
36
+ Requires-Dist: claude-agent-sdk>=0.0.1; extra == 'all'
37
+ Requires-Dist: crewai>=0.50.0; extra == 'all'
38
+ Requires-Dist: langchain-core>=0.2.0; extra == 'all'
39
+ Requires-Dist: langchain-openai>=0.1.0; extra == 'all'
40
+ Requires-Dist: langgraph>=0.2.0; extra == 'all'
41
+ Requires-Dist: openai-agents>=0.0.3; extra == 'all'
42
+ Provides-Extra: claude-agents
43
+ Requires-Dist: anthropic>=0.40.0; extra == 'claude-agents'
44
+ Requires-Dist: claude-agent-sdk>=0.0.1; extra == 'claude-agents'
45
+ Provides-Extra: crewai
46
+ Requires-Dist: crewai>=0.50.0; extra == 'crewai'
47
+ Provides-Extra: dev
48
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
49
+ Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
50
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
51
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
52
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
53
+ Provides-Extra: langgraph
54
+ Requires-Dist: langchain-core>=0.2.0; extra == 'langgraph'
55
+ Requires-Dist: langchain-openai>=0.1.0; extra == 'langgraph'
56
+ Requires-Dist: langgraph>=0.2.0; extra == 'langgraph'
57
+ Provides-Extra: openai-agents
58
+ Requires-Dist: openai-agents>=0.0.3; extra == 'openai-agents'
59
+ Description-Content-Type: text/markdown
60
+
61
+ # CortexHub Python SDK
62
+
63
+ **Runtime Governance for AI Agents** - Policy enforcement, PII/secrets detection, complete audit trails with OpenTelemetry.
64
+
65
+ ## Installation
66
+
67
+ ```bash
68
+ # Core SDK
69
+ pip install cortexhub
70
+
71
+ # With framework support (choose one or more)
72
+ pip install cortexhub[langchain] # LangChain/LangGraph
73
+ pip install cortexhub[crewai] # CrewAI
74
+ pip install cortexhub[openai-agents] # OpenAI Agents SDK
75
+ pip install cortexhub[llamaindex] # LlamaIndex
76
+ pip install cortexhub[litellm] # LiteLLM
77
+
78
+ # All frameworks (for development)
79
+ pip install cortexhub[all]
80
+ ```
81
+
82
+ ## Quick Start
83
+
84
+ ```python
85
+ from cortexhub import init, Framework
86
+
87
+ # Initialize CortexHub FIRST, before importing your framework
88
+ cortex = init(
89
+ agent_id="customer_support_agent",
90
+ framework=Framework.LANGCHAIN, # or CREWAI, OPENAI_AGENTS, etc.
91
+ )
92
+
93
+ # Now import and use your framework
94
+ from langchain_core.tools import tool
95
+
96
+ @tool
97
+ def process_refund(customer_id: str, amount: float) -> dict:
98
+ """Process a customer refund."""
99
+ return {"status": "processed", "amount": amount}
100
+
101
+ # All tool calls are now governed!
102
+ ```
103
+
104
+ ## Supported Frameworks
105
+
106
+ | Framework | Enum Value | Install |
107
+ |-----------|------------|---------|
108
+ | LangChain | `Framework.LANGCHAIN` | `pip install cortexhub[langchain]` |
109
+ | LangGraph | `Framework.LANGCHAIN` | `pip install cortexhub[langchain]` |
110
+ | CrewAI | `Framework.CREWAI` | `pip install cortexhub[crewai]` |
111
+ | OpenAI Agents | `Framework.OPENAI_AGENTS` | `pip install cortexhub[openai-agents]` |
112
+ | LlamaIndex | `Framework.LLAMAINDEX` | `pip install cortexhub[llamaindex]` |
113
+ | LiteLLM | `Framework.LITELLM` | `pip install cortexhub[litellm]` |
114
+
115
+ ## Configuration
116
+
117
+ ```bash
118
+ # Required: API key for telemetry
119
+ export CORTEXHUB_API_KEY=ch_live_...
120
+
121
+ # Optional: Backend URL (defaults to production)
122
+ export CORTEXHUB_API_URL=https://api.cortexhub.ai
123
+
124
+ # Optional: OpenAI key for LLM-based examples
125
+ export OPENAI_API_KEY=sk-...
126
+ ```
127
+
128
+ ## Features
129
+
130
+ - **Policy Enforcement** - Cedar-based policies, local evaluation
131
+ - **PII Detection** - Presidio-powered, 50+ entity types, configurable
132
+ - **Secrets Detection** - detect-secrets integration, 30+ secret types
133
+ - **Configurable Guardrails** - Select specific PII/secret types to redact
134
+ - **Custom Patterns** - Add company-specific regex patterns
135
+ - **OpenTelemetry** - Industry-standard observability
136
+ - **Framework Adapters** - Automatic interception for all major frameworks
137
+ - **Privacy Mode** - Metadata-only by default, safe for production
138
+
139
+ ## Privacy Modes
140
+
141
+ ```python
142
+ # Production (default) - only metadata sent
143
+ cortex = init(agent_id="...", framework=..., privacy=True)
144
+ # Sends: tool names, arg schemas, PII types detected
145
+ # Never: raw values, prompts, responses
146
+
147
+ # Development - full data for testing policies
148
+ cortex = init(agent_id="...", framework=..., privacy=False)
149
+ # Also sends: raw args, results, prompts (for policy testing)
150
+ ```
151
+
152
+ ## Policy Enforcement
153
+
154
+ Policies are created in the CortexHub dashboard from detected risks. The SDK automatically fetches and enforces them:
155
+
156
+ ```python
157
+ from cortexhub.errors import PolicyViolationError, ApprovalRequiredError
158
+
159
+ # Policies are fetched automatically during init()
160
+ # If policies exist, enforcement mode is enabled
161
+
162
+ try:
163
+ agent.run("Process a $10,000 refund")
164
+ except PolicyViolationError as e:
165
+ print(f"Blocked by policy: {e.policy_name}")
166
+ print(f"Reason: {e.reasoning}")
167
+ except ApprovalRequiredError as e:
168
+ print(f"\n⏸️ APPROVAL REQUIRED")
169
+ print(f" Approval ID: {e.approval_id}")
170
+ print(f" Tool: {e.tool_name}")
171
+ print(f" Reason: {e.reason}")
172
+ print(f" Expires: {e.expires_at}")
173
+ print(f"\n Decision endpoint: {e.decision_endpoint}")
174
+ print(f" Configure a webhook to receive approval.decisioned event")
175
+ ```
176
+
177
+ ## Guardrail Configuration
178
+
179
+ Guardrails detect PII and secrets in LLM prompts. Configure in the dashboard:
180
+
181
+ 1. **Select types to redact**: Choose specific PII types (email, phone, etc.)
182
+ 2. **Add custom patterns**: Regex for company-specific data (employee IDs, etc.)
183
+ 3. **Choose action**: Redact, block, or monitor only
184
+
185
+ The SDK applies your configuration automatically:
186
+
187
+ ```python
188
+ # With guardrail policy active:
189
+ # Input prompt: "Contact john@email.com about employee EMP-123456"
190
+ # After redaction: "Contact [REDACTED-EMAIL_ADDRESS] about employee [REDACTED-CUSTOM_EMPLOYEE_ID]"
191
+ # Only configured types are redacted
192
+ ```
193
+
194
+ ## Examples
195
+
196
+ ```bash
197
+ cd python/examples
198
+
199
+ # LangChain customer support
200
+ python langchain_example.py
201
+
202
+ # LangGraph fraud investigation
203
+ python langgraph_example.py
204
+
205
+ # CrewAI financial operations
206
+ python crewai_example.py
207
+
208
+ # OpenAI Agents research assistant
209
+ python openai_agents_example.py
210
+
211
+ # LiteLLM multi-provider
212
+ python litellm_example.py
213
+ ```
214
+
215
+ ## Important: Initialization Order
216
+
217
+ **Always initialize CortexHub FIRST**, before importing your framework:
218
+
219
+ ```python
220
+ # ✅ CORRECT
221
+ from cortexhub import init, Framework
222
+ cortex = init(agent_id="my_agent", framework=Framework.LANGCHAIN)
223
+
224
+ from langchain_core.tools import tool # Import AFTER init
225
+
226
+ # ❌ WRONG
227
+ from langchain_core.tools import tool # Framework imported first
228
+ from cortexhub import init, Framework
229
+ cortex = init(...) # Too late!
230
+ ```
231
+
232
+ This ensures:
233
+ 1. CortexHub sets up OpenTelemetry before frameworks that also use it
234
+ 2. Framework decorators/classes are properly wrapped
235
+
236
+ ## Architecture
237
+
238
+ ```
239
+ Agent Decides → [CortexHub] → Agent Executes
240
+
241
+ ┌─────┴─────┐
242
+ │ │
243
+ Policy Guardrails
244
+ Engine (PII/Secrets)
245
+ │ │
246
+ └─────┬─────┘
247
+
248
+ OpenTelemetry
249
+ (to backend)
250
+ ```
251
+
252
+ ## Development
253
+
254
+ ```bash
255
+ cd python
256
+
257
+ # Install with all frameworks
258
+ uv sync --all-extras
259
+
260
+ # Run tests
261
+ uv run pytest
262
+
263
+ # Lint
264
+ uv run ruff check .
265
+ ```
266
+
267
+ ## Links
268
+
269
+ - [Documentation](https://docs.cortexhub.ai)
270
+ - [Dashboard](https://app.cortexhub.ai)
271
+ - [Issues](https://github.com/cortexhub/sdks/issues)
272
+
273
+ ## License
274
+
275
+ MIT
@@ -0,0 +1,38 @@
1
+ cortexhub/__init__.py,sha256=hnwsiUy5BT3QaPNK5yXqex6zRzZlok43S04y-dkNWSE,4376
2
+ cortexhub/auto_protect.py,sha256=yW-iW9cdGg-fM8EtR_Z9UkMczn51U8BKh5pOBgV1VqE,3951
3
+ cortexhub/client.py,sha256=pXZI3Fc2SqBWCSmnRB9j6qAq8-qky1EYw9mvEVBXwn0,94080
4
+ cortexhub/config.py,sha256=kpwVMTRcSisJy8HHBL3ZBeQoMN3lE7zziRzEYaq92LI,941
5
+ cortexhub/errors.py,sha256=hsknLHaVCqk5MkpXvahxYIUshDt2VGZfbBWRronFvVM,3697
6
+ cortexhub/frameworks.py,sha256=WCPokPRVafLqe73MDbJasi8FyNHTM2T4wfaBg0LuWoM,2223
7
+ cortexhub/pipeline.py,sha256=EvkrEz7dGnzc0tlv02B3Kx2KQfdX4gsTuhUxj-MwuFI,3256
8
+ cortexhub/version.py,sha256=L1gsFyWfMZYvly7nYjyH0nlWRAsm65S61_B-imDPgXE,68
9
+ cortexhub/adapters/__init__.py,sha256=Lb6RquGPGs4exdfSB6Qb6q6HyGczozuLWSaLCtgZdyo,130
10
+ cortexhub/adapters/base.py,sha256=_ODoJFLQLYnowse3MHQk8bN9KjE1oQr8QDNNlvPSwSs,4094
11
+ cortexhub/adapters/claude_agents.py,sha256=gXjONi7Otl6kfQQLHENsrJ_gsBw2ilATCa1zwNNR6EY,12601
12
+ cortexhub/adapters/crewai.py,sha256=Y7ibOD1sFahDQ39XRZw_Kx2PCcZvKpyQKOSo0aZvs_0,12521
13
+ cortexhub/adapters/langgraph.py,sha256=FpIcAITNnIk6OUK9rCyCA2nVxQvs0ibyCFH0j-CjHv0,15024
14
+ cortexhub/adapters/openai_agents.py,sha256=NtTsUjrRv3nzd-1VXLu7_imW9l2LzCvna1u02QTDRh8,7600
15
+ cortexhub/audit/__init__.py,sha256=tKE9CdpAIpP04oeLOza96jwZs4er5G5bRBWGibvh4Xw,545
16
+ cortexhub/audit/events.py,sha256=w1uHbYzwBTDRm8gKAY_TQlXHjUj2nZt-iXk0NcqzRak,5965
17
+ cortexhub/backend/__init__.py,sha256=Yt5fcaW24l6YwPCLvKbcKAXhhrWTUjwgqJsLOIzgIAo,133
18
+ cortexhub/backend/client.py,sha256=dYd2aWJORysrEfJ5T_QPLwvs0xUQLrhMVT4FWUVOg6c,13680
19
+ cortexhub/context/__init__.py,sha256=BWoR2s4ogOs1YXPFBO7e8_UOZ_5AWYfMlv5PTVORN2Y,144
20
+ cortexhub/context/enricher.py,sha256=cComyfE10EbaCAI8KLM0ED6j-wKYBc26MRnIn-dxhmU,5322
21
+ cortexhub/guardrails/__init__.py,sha256=RH1u8w3FFLd6u7-OYgj42PqAJO9jXsl8-tcLiL24uOo,103
22
+ cortexhub/guardrails/injection.py,sha256=BZqd4qxD2dbM52yajmNBADKazp0DDeRFqjhuYRPGwfo,5786
23
+ cortexhub/guardrails/pii.py,sha256=ruSVtp2rflRjvnvAqAXdNhOTDO5SSbSbfIEzlfb92c8,12818
24
+ cortexhub/guardrails/secrets.py,sha256=9LW93WTTH6lYwD-zumNtSsDPXqjt0SX_fPoo_tEML68,6081
25
+ cortexhub/interceptors/__init__.py,sha256=_rTpQs6CPDVtYXVbinGOWzdhczCkcwTsXNpZkXWxwDo,89
26
+ cortexhub/interceptors/llm.py,sha256=MtYD4M3-9XKmBZH5rYLBxOwFeWFbw4guSt7y93n8DgQ,2068
27
+ cortexhub/interceptors/mcp.py,sha256=SDoVZn0mLQdxOBs3X15DqA6hKzh6UydMuS1FhZaHKcU,3323
28
+ cortexhub/policy/__init__.py,sha256=JcTQQ5nk39dB3L4MmuFxLgfjq3GLi6a8zpTPGlf5q94,212
29
+ cortexhub/policy/effects.py,sha256=aelpCh1aGAJJmJHNgRTJjMAuMktDtR0NgfIb1AocC6c,2694
30
+ cortexhub/policy/evaluator.py,sha256=loDHNqgnQDCDXLaJAhlnVbp9t1YxzcUn0c5r6L5gqHs,10021
31
+ cortexhub/policy/loader.py,sha256=KmoPC5aLQjzuVsJd8Dg0npZXQ5WCBRktgdNmG875D-U,4699
32
+ cortexhub/policy/models.py,sha256=81NPX36yru0AZ22Wivytv3uxlwir4VsTN4MZgq4bdiA,3877
33
+ cortexhub/policy/sync.py,sha256=7kAc3rd5WftipR8XKwvU8SwukIoY-0gcGW2fsf-ij_I,5999
34
+ cortexhub/telemetry/__init__.py,sha256=RSY38hHnYtbRURLoWAhbYYxYMtCItVYZBNN6Bfny8uA,1049
35
+ cortexhub/telemetry/otel.py,sha256=T2pC-K_S_KmrLvfcd3oHMbEwC5ibGZ-PXTZSY0xJgcQ,16633
36
+ cortexhub-0.1.0.dist-info/METADATA,sha256=XSJRddscqapbULDxf9i19lNq9SIhf3iZ-11WJeVg5YM,8629
37
+ cortexhub-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
38
+ cortexhub-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any