shieldcortex 0.1.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.
Files changed (32) hide show
  1. shieldcortex-0.1.0/.github/workflows/publish.yml +24 -0
  2. shieldcortex-0.1.0/.github/workflows/test.yml +27 -0
  3. shieldcortex-0.1.0/.gitignore +17 -0
  4. shieldcortex-0.1.0/LICENSE +21 -0
  5. shieldcortex-0.1.0/PKG-INFO +191 -0
  6. shieldcortex-0.1.0/README.md +152 -0
  7. shieldcortex-0.1.0/examples/audit_export.py +29 -0
  8. shieldcortex-0.1.0/examples/basic_scan.py +25 -0
  9. shieldcortex-0.1.0/examples/batch_scanning.py +21 -0
  10. shieldcortex-0.1.0/examples/crewai_memory.py +29 -0
  11. shieldcortex-0.1.0/examples/langchain_callback.py +34 -0
  12. shieldcortex-0.1.0/pyproject.toml +81 -0
  13. shieldcortex-0.1.0/src/shieldcortex/__init__.py +140 -0
  14. shieldcortex-0.1.0/src/shieldcortex/_http.py +234 -0
  15. shieldcortex-0.1.0/src/shieldcortex/_version.py +1 -0
  16. shieldcortex-0.1.0/src/shieldcortex/async_client.py +533 -0
  17. shieldcortex-0.1.0/src/shieldcortex/client.py +539 -0
  18. shieldcortex-0.1.0/src/shieldcortex/errors.py +51 -0
  19. shieldcortex-0.1.0/src/shieldcortex/integrations/__init__.py +0 -0
  20. shieldcortex-0.1.0/src/shieldcortex/integrations/crewai.py +91 -0
  21. shieldcortex-0.1.0/src/shieldcortex/integrations/langchain.py +141 -0
  22. shieldcortex-0.1.0/src/shieldcortex/pagination.py +106 -0
  23. shieldcortex-0.1.0/src/shieldcortex/types.py +444 -0
  24. shieldcortex-0.1.0/tests/__init__.py +0 -0
  25. shieldcortex-0.1.0/tests/conftest.py +12 -0
  26. shieldcortex-0.1.0/tests/fixtures.py +93 -0
  27. shieldcortex-0.1.0/tests/integrations/__init__.py +0 -0
  28. shieldcortex-0.1.0/tests/integrations/test_crewai.py +137 -0
  29. shieldcortex-0.1.0/tests/test_client.py +436 -0
  30. shieldcortex-0.1.0/tests/test_errors.py +50 -0
  31. shieldcortex-0.1.0/tests/test_pagination.py +112 -0
  32. shieldcortex-0.1.0/tests/test_types.py +153 -0
@@ -0,0 +1,24 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ environment: pypi
12
+ permissions:
13
+ id-token: write
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: "3.12"
19
+ - name: Install build tools
20
+ run: pip install build
21
+ - name: Build package
22
+ run: python -m build
23
+ - name: Publish to PyPI
24
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,27 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-python@v5
18
+ with:
19
+ python-version: ${{ matrix.python-version }}
20
+ - name: Install dependencies
21
+ run: pip install -e ".[dev]"
22
+ - name: Lint
23
+ run: ruff check src/
24
+ - name: Type check
25
+ run: mypy src/shieldcortex/ --ignore-missing-imports
26
+ - name: Test
27
+ run: pytest tests/ -v
@@ -0,0 +1,17 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *$py.class
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+ .eggs/
8
+ *.egg
9
+ .mypy_cache/
10
+ .ruff_cache/
11
+ .pytest_cache/
12
+ .venv/
13
+ venv/
14
+ env/
15
+ *.so
16
+ .coverage
17
+ htmlcov/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Drakon Systems Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: shieldcortex
3
+ Version: 0.1.0
4
+ Summary: Official Python SDK for the ShieldCortex API — AI memory security scanning
5
+ Project-URL: Homepage, https://shieldcortex.ai
6
+ Project-URL: Documentation, https://shieldcortex.ai/docs
7
+ Project-URL: Repository, https://github.com/Drakon-Systems-Ltd/shieldcortex-python
8
+ Project-URL: Bug Tracker, https://github.com/Drakon-Systems-Ltd/shieldcortex-python/issues
9
+ Author-email: Drakon Systems Ltd <support@shieldcortex.ai>
10
+ License: MIT
11
+ License-File: LICENSE
12
+ Keywords: ai,defence,firewall,memory,prompt-injection,security,shieldcortex
13
+ Classifier: Development Status :: 4 - Beta
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Security
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Classifier: Typing :: Typed
25
+ Requires-Python: >=3.9
26
+ Requires-Dist: httpx>=0.27.0
27
+ Provides-Extra: crewai
28
+ Requires-Dist: crewai>=0.28.0; extra == 'crewai'
29
+ Provides-Extra: dev
30
+ Requires-Dist: build>=1.0.0; extra == 'dev'
31
+ Requires-Dist: mypy>=1.8.0; extra == 'dev'
32
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
33
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
34
+ Requires-Dist: respx>=0.21.0; extra == 'dev'
35
+ Requires-Dist: ruff>=0.2.0; extra == 'dev'
36
+ Provides-Extra: langchain
37
+ Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
38
+ Description-Content-Type: text/markdown
39
+
40
+ # shieldcortex
41
+
42
+ [![PyPI](https://img.shields.io/pypi/v/shieldcortex)](https://pypi.org/project/shieldcortex/)
43
+ [![Python](https://img.shields.io/pypi/pyversions/shieldcortex)](https://pypi.org/project/shieldcortex/)
44
+ [![License](https://img.shields.io/pypi/l/shieldcortex)](LICENSE)
45
+
46
+ Official Python SDK for the [ShieldCortex](https://shieldcortex.ai) API — AI memory security scanning.
47
+
48
+ ShieldCortex is a 6-layer defence pipeline that protects AI agent memory from prompt injection, credential leaks, encoding attacks, and more.
49
+
50
+ ## Installation
51
+
52
+ ```bash
53
+ pip install shieldcortex
54
+ ```
55
+
56
+ With framework integrations:
57
+
58
+ ```bash
59
+ pip install shieldcortex[crewai] # CrewAI memory guard
60
+ pip install shieldcortex[langchain] # LangChain callback handler
61
+ ```
62
+
63
+ ## Quick Start
64
+
65
+ ```python
66
+ from shieldcortex import ShieldCortex
67
+
68
+ client = ShieldCortex(api_key="sc_live_...")
69
+
70
+ # Scan user input before storing in memory
71
+ result = client.scan("user input here")
72
+
73
+ if not result.allowed:
74
+ print(f"Blocked: {result.firewall.reason}")
75
+ print(f"Threats: {result.firewall.threat_indicators}")
76
+ else:
77
+ print(f"Safe (trust: {result.trust.score})")
78
+ ```
79
+
80
+ ## Async Support
81
+
82
+ ```python
83
+ from shieldcortex import AsyncShieldCortex
84
+
85
+ async with AsyncShieldCortex(api_key="sc_live_...") as client:
86
+ result = await client.scan("user input here")
87
+ ```
88
+
89
+ ## Batch Scanning
90
+
91
+ ```python
92
+ from shieldcortex import BatchItem
93
+
94
+ result = client.scan_batch([
95
+ BatchItem(content="memory entry 1"),
96
+ BatchItem(content="memory entry 2"),
97
+ ])
98
+ print(f"Scanned: {result.total_scanned}, Threats: {result.threats}")
99
+ ```
100
+
101
+ ## Audit Logs
102
+
103
+ ```python
104
+ from shieldcortex import AuditQuery
105
+
106
+ # Query with filters
107
+ logs = client.get_audit_logs(AuditQuery(level="BLOCK", limit=10))
108
+
109
+ # Auto-paginate through all entries
110
+ for entry in client.iter_audit_logs():
111
+ print(entry.id, entry.firewall_result)
112
+
113
+ # Export as CSV
114
+ csv = client.export_audit_logs(format="csv")
115
+ ```
116
+
117
+ ## CrewAI Integration
118
+
119
+ Scan all memory writes before they reach your store:
120
+
121
+ ```python
122
+ from shieldcortex import ShieldCortex
123
+ from shieldcortex.integrations.crewai import ShieldCortexMemoryGuard, MemoryBlockedError
124
+
125
+ client = ShieldCortex(api_key="sc_live_...")
126
+ guard = ShieldCortexMemoryGuard(client, mode="strict")
127
+
128
+ try:
129
+ guard.check("content to remember")
130
+ # Safe — save to memory store
131
+ except MemoryBlockedError as e:
132
+ print(f"Blocked: {e.result.firewall.reason}")
133
+ ```
134
+
135
+ ## LangChain Integration
136
+
137
+ Scan LLM inputs and outputs automatically:
138
+
139
+ ```python
140
+ from shieldcortex import AsyncShieldCortex
141
+ from shieldcortex.integrations.langchain import ShieldCortexCallbackHandler
142
+
143
+ client = AsyncShieldCortex(api_key="sc_live_...")
144
+ handler = ShieldCortexCallbackHandler(client, raise_on_block=True)
145
+
146
+ # Pass to any LangChain component
147
+ llm = ChatOpenAI(callbacks=[handler])
148
+ ```
149
+
150
+ ## Error Handling
151
+
152
+ ```python
153
+ from shieldcortex.errors import AuthError, RateLimitError, ValidationError
154
+
155
+ try:
156
+ result = client.scan("content")
157
+ except AuthError:
158
+ print("Invalid API key")
159
+ except RateLimitError as e:
160
+ print(f"Rate limited, retry after {e.retry_after}s")
161
+ except ValidationError:
162
+ print("Invalid request")
163
+ ```
164
+
165
+ ## Full API Coverage
166
+
167
+ The SDK covers all ShieldCortex API endpoints:
168
+
169
+ | Category | Methods |
170
+ |----------|---------|
171
+ | **Scanning** | `scan()`, `scan_batch()`, `scan_skill()` |
172
+ | **Audit** | `get_audit_logs()`, `get_audit_entry()`, `get_audit_stats()`, `get_audit_trends()`, `export_audit_logs()`, `iter_audit_logs()` |
173
+ | **Quarantine** | `get_quarantine()`, `get_quarantine_item()`, `review_quarantine_item()` |
174
+ | **API Keys** | `create_api_key()`, `list_api_keys()`, `revoke_api_key()` |
175
+ | **Teams** | `get_team()`, `update_team()`, `get_team_members()`, `get_usage()` |
176
+ | **Invites** | `create_invite()`, `list_invites()`, `delete_invite()`, `resend_invite()` |
177
+ | **Billing** | `create_checkout_session()`, `create_portal_session()` |
178
+ | **Devices** | `get_devices()`, `register_device()`, `update_device()`, `device_heartbeat()` |
179
+ | **Alerts** | `get_alerts()`, `create_alert()`, `update_alert()`, `delete_alert()` |
180
+ | **Webhooks** | `get_webhooks()`, `create_webhook()`, `update_webhook()`, `delete_webhook()`, `test_webhook()`, `get_webhook_deliveries()` |
181
+ | **Firewall Rules** | `get_firewall_rules()`, `get_active_firewall_rules()`, `create_firewall_rule()`, `update_firewall_rule()`, `delete_firewall_rule()` |
182
+
183
+ ## Documentation
184
+
185
+ - [ShieldCortex Docs](https://shieldcortex.ai/docs)
186
+ - [API Reference](https://shieldcortex.ai/docs)
187
+ - [Examples](examples/)
188
+
189
+ ## License
190
+
191
+ MIT
@@ -0,0 +1,152 @@
1
+ # shieldcortex
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/shieldcortex)](https://pypi.org/project/shieldcortex/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/shieldcortex)](https://pypi.org/project/shieldcortex/)
5
+ [![License](https://img.shields.io/pypi/l/shieldcortex)](LICENSE)
6
+
7
+ Official Python SDK for the [ShieldCortex](https://shieldcortex.ai) API — AI memory security scanning.
8
+
9
+ ShieldCortex is a 6-layer defence pipeline that protects AI agent memory from prompt injection, credential leaks, encoding attacks, and more.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ pip install shieldcortex
15
+ ```
16
+
17
+ With framework integrations:
18
+
19
+ ```bash
20
+ pip install shieldcortex[crewai] # CrewAI memory guard
21
+ pip install shieldcortex[langchain] # LangChain callback handler
22
+ ```
23
+
24
+ ## Quick Start
25
+
26
+ ```python
27
+ from shieldcortex import ShieldCortex
28
+
29
+ client = ShieldCortex(api_key="sc_live_...")
30
+
31
+ # Scan user input before storing in memory
32
+ result = client.scan("user input here")
33
+
34
+ if not result.allowed:
35
+ print(f"Blocked: {result.firewall.reason}")
36
+ print(f"Threats: {result.firewall.threat_indicators}")
37
+ else:
38
+ print(f"Safe (trust: {result.trust.score})")
39
+ ```
40
+
41
+ ## Async Support
42
+
43
+ ```python
44
+ from shieldcortex import AsyncShieldCortex
45
+
46
+ async with AsyncShieldCortex(api_key="sc_live_...") as client:
47
+ result = await client.scan("user input here")
48
+ ```
49
+
50
+ ## Batch Scanning
51
+
52
+ ```python
53
+ from shieldcortex import BatchItem
54
+
55
+ result = client.scan_batch([
56
+ BatchItem(content="memory entry 1"),
57
+ BatchItem(content="memory entry 2"),
58
+ ])
59
+ print(f"Scanned: {result.total_scanned}, Threats: {result.threats}")
60
+ ```
61
+
62
+ ## Audit Logs
63
+
64
+ ```python
65
+ from shieldcortex import AuditQuery
66
+
67
+ # Query with filters
68
+ logs = client.get_audit_logs(AuditQuery(level="BLOCK", limit=10))
69
+
70
+ # Auto-paginate through all entries
71
+ for entry in client.iter_audit_logs():
72
+ print(entry.id, entry.firewall_result)
73
+
74
+ # Export as CSV
75
+ csv = client.export_audit_logs(format="csv")
76
+ ```
77
+
78
+ ## CrewAI Integration
79
+
80
+ Scan all memory writes before they reach your store:
81
+
82
+ ```python
83
+ from shieldcortex import ShieldCortex
84
+ from shieldcortex.integrations.crewai import ShieldCortexMemoryGuard, MemoryBlockedError
85
+
86
+ client = ShieldCortex(api_key="sc_live_...")
87
+ guard = ShieldCortexMemoryGuard(client, mode="strict")
88
+
89
+ try:
90
+ guard.check("content to remember")
91
+ # Safe — save to memory store
92
+ except MemoryBlockedError as e:
93
+ print(f"Blocked: {e.result.firewall.reason}")
94
+ ```
95
+
96
+ ## LangChain Integration
97
+
98
+ Scan LLM inputs and outputs automatically:
99
+
100
+ ```python
101
+ from shieldcortex import AsyncShieldCortex
102
+ from shieldcortex.integrations.langchain import ShieldCortexCallbackHandler
103
+
104
+ client = AsyncShieldCortex(api_key="sc_live_...")
105
+ handler = ShieldCortexCallbackHandler(client, raise_on_block=True)
106
+
107
+ # Pass to any LangChain component
108
+ llm = ChatOpenAI(callbacks=[handler])
109
+ ```
110
+
111
+ ## Error Handling
112
+
113
+ ```python
114
+ from shieldcortex.errors import AuthError, RateLimitError, ValidationError
115
+
116
+ try:
117
+ result = client.scan("content")
118
+ except AuthError:
119
+ print("Invalid API key")
120
+ except RateLimitError as e:
121
+ print(f"Rate limited, retry after {e.retry_after}s")
122
+ except ValidationError:
123
+ print("Invalid request")
124
+ ```
125
+
126
+ ## Full API Coverage
127
+
128
+ The SDK covers all ShieldCortex API endpoints:
129
+
130
+ | Category | Methods |
131
+ |----------|---------|
132
+ | **Scanning** | `scan()`, `scan_batch()`, `scan_skill()` |
133
+ | **Audit** | `get_audit_logs()`, `get_audit_entry()`, `get_audit_stats()`, `get_audit_trends()`, `export_audit_logs()`, `iter_audit_logs()` |
134
+ | **Quarantine** | `get_quarantine()`, `get_quarantine_item()`, `review_quarantine_item()` |
135
+ | **API Keys** | `create_api_key()`, `list_api_keys()`, `revoke_api_key()` |
136
+ | **Teams** | `get_team()`, `update_team()`, `get_team_members()`, `get_usage()` |
137
+ | **Invites** | `create_invite()`, `list_invites()`, `delete_invite()`, `resend_invite()` |
138
+ | **Billing** | `create_checkout_session()`, `create_portal_session()` |
139
+ | **Devices** | `get_devices()`, `register_device()`, `update_device()`, `device_heartbeat()` |
140
+ | **Alerts** | `get_alerts()`, `create_alert()`, `update_alert()`, `delete_alert()` |
141
+ | **Webhooks** | `get_webhooks()`, `create_webhook()`, `update_webhook()`, `delete_webhook()`, `test_webhook()`, `get_webhook_deliveries()` |
142
+ | **Firewall Rules** | `get_firewall_rules()`, `get_active_firewall_rules()`, `create_firewall_rule()`, `update_firewall_rule()`, `delete_firewall_rule()` |
143
+
144
+ ## Documentation
145
+
146
+ - [ShieldCortex Docs](https://shieldcortex.ai/docs)
147
+ - [API Reference](https://shieldcortex.ai/docs)
148
+ - [Examples](examples/)
149
+
150
+ ## License
151
+
152
+ MIT
@@ -0,0 +1,29 @@
1
+ """Audit log querying and export example."""
2
+
3
+ from shieldcortex import ShieldCortex, AuditQuery
4
+
5
+ client = ShieldCortex(api_key="sc_live_YOUR_KEY_HERE")
6
+
7
+ # Get summary stats
8
+ stats = client.get_audit_stats(time_range="7d")
9
+ print(f"Total operations: {stats.total_operations}")
10
+ print(f"Allowed: {stats.allowed_count}")
11
+ print(f"Blocked: {stats.blocked_count}")
12
+ print(f"Quarantined: {stats.quarantined_count}")
13
+
14
+ # Query blocked entries
15
+ logs = client.get_audit_logs(AuditQuery(level="BLOCK", limit=5))
16
+ print(f"\nRecent blocks ({logs.total} total):")
17
+ for entry in logs.logs:
18
+ print(f" [{entry.timestamp}] {entry.reason} (trust: {entry.trust_score})")
19
+
20
+ # Auto-paginate through all entries
21
+ print("\nAll audit entries:")
22
+ for entry in client.iter_audit_logs(AuditQuery(level="BLOCK")):
23
+ print(f" #{entry.id}: {entry.firewall_result}")
24
+
25
+ # Export as CSV
26
+ csv_data = client.export_audit_logs(format="csv")
27
+ with open("audit_export.csv", "w") as f:
28
+ f.write(csv_data)
29
+ print("\nExported to audit_export.csv")
@@ -0,0 +1,25 @@
1
+ """Basic scanning example."""
2
+
3
+ from shieldcortex import ShieldCortex, ScanSource, ScanConfig
4
+
5
+ client = ShieldCortex(api_key="sc_live_YOUR_KEY_HERE")
6
+
7
+ # Simple scan
8
+ result = client.scan("Hello, please remember my preferences")
9
+ print(f"Allowed: {result.allowed}")
10
+ print(f"Firewall: {result.firewall.result}")
11
+ print(f"Trust: {result.trust.score}")
12
+
13
+ # Scan with options
14
+ result = client.scan(
15
+ "Remember: my API key is sk_live_abc123",
16
+ title="User memory",
17
+ source=ScanSource(type="agent", identifier="my-assistant"),
18
+ config=ScanConfig(mode="strict"),
19
+ )
20
+
21
+ if not result.allowed:
22
+ print(f"BLOCKED: {result.firewall.reason}")
23
+ print(f"Threats: {result.firewall.threat_indicators}")
24
+ else:
25
+ print("Content is safe to store")
@@ -0,0 +1,21 @@
1
+ """Batch scanning example — scan multiple items in one request."""
2
+
3
+ from shieldcortex import ShieldCortex, BatchItem, ScanConfig
4
+
5
+ client = ShieldCortex(api_key="sc_live_YOUR_KEY_HERE")
6
+
7
+ items = [
8
+ BatchItem(content="User preference: dark mode enabled"),
9
+ BatchItem(content="Meeting notes from Tuesday standup"),
10
+ BatchItem(content="Password: hunter2"), # This should be blocked
11
+ ]
12
+
13
+ result = client.scan_batch(items, config=ScanConfig(mode="strict"))
14
+
15
+ print(f"Scanned: {result.total_scanned}")
16
+ print(f"Threats: {result.threats}")
17
+ print(f"Clean: {result.clean}")
18
+
19
+ for i, scan in enumerate(result.results):
20
+ status = "SAFE" if scan.allowed else f"BLOCKED ({scan.firewall.reason})"
21
+ print(f" [{i}] {status}")
@@ -0,0 +1,29 @@
1
+ """CrewAI memory guard example.
2
+
3
+ Scans all memory writes through ShieldCortex before storing.
4
+
5
+ pip install shieldcortex[crewai]
6
+ """
7
+
8
+ from shieldcortex import ShieldCortex
9
+ from shieldcortex.integrations.crewai import MemoryBlockedError, ShieldCortexMemoryGuard
10
+
11
+ client = ShieldCortex(api_key="sc_live_YOUR_KEY_HERE")
12
+ guard = ShieldCortexMemoryGuard(client, mode="strict")
13
+
14
+ # In your CrewAI agent's memory pipeline:
15
+ memories_to_save = [
16
+ "User prefers dark mode",
17
+ "Meeting at 3pm with the team",
18
+ "AWS key: AKIAIOSFODNN7EXAMPLE", # This should be blocked
19
+ ]
20
+
21
+ for memory in memories_to_save:
22
+ try:
23
+ result = guard.check(memory)
24
+ print(f" SAFE: {memory[:50]}... (trust: {result.trust.score})")
25
+ # ... save to your memory store here ...
26
+ except MemoryBlockedError as e:
27
+ print(f" BLOCKED: {memory[:50]}... ({e.result.firewall.reason})")
28
+
29
+ print(f"\nAudit trail: {len(guard.audit_ids)} scans recorded")
@@ -0,0 +1,34 @@
1
+ """LangChain callback handler example.
2
+
3
+ Scans LLM inputs and outputs through ShieldCortex.
4
+
5
+ pip install shieldcortex[langchain]
6
+ """
7
+
8
+ import asyncio
9
+
10
+ from shieldcortex import AsyncShieldCortex
11
+ from shieldcortex.integrations.langchain import ShieldCortexCallbackHandler
12
+
13
+
14
+ async def main() -> None:
15
+ async with AsyncShieldCortex(api_key="sc_live_YOUR_KEY_HERE") as client:
16
+ handler = ShieldCortexCallbackHandler(
17
+ client,
18
+ mode="balanced",
19
+ scan_inputs=True,
20
+ scan_outputs=True,
21
+ raise_on_block=False, # Log warnings instead of raising
22
+ )
23
+
24
+ # Use with any LangChain component:
25
+ #
26
+ # from langchain_openai import ChatOpenAI
27
+ # llm = ChatOpenAI(callbacks=[handler])
28
+ # response = await llm.ainvoke("Hello!")
29
+
30
+ print(f"Handler ready. Audit IDs so far: {handler.audit_ids}")
31
+
32
+
33
+ if __name__ == "__main__":
34
+ asyncio.run(main())
@@ -0,0 +1,81 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "shieldcortex"
7
+ version = "0.1.0"
8
+ description = "Official Python SDK for the ShieldCortex API — AI memory security scanning"
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.9"
12
+ authors = [
13
+ { name = "Drakon Systems Ltd", email = "support@shieldcortex.ai" },
14
+ ]
15
+ keywords = [
16
+ "shieldcortex",
17
+ "ai",
18
+ "security",
19
+ "memory",
20
+ "firewall",
21
+ "prompt-injection",
22
+ "defence",
23
+ ]
24
+ classifiers = [
25
+ "Development Status :: 4 - Beta",
26
+ "Intended Audience :: Developers",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.9",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Programming Language :: Python :: 3.13",
34
+ "Topic :: Security",
35
+ "Topic :: Software Development :: Libraries :: Python Modules",
36
+ "Typing :: Typed",
37
+ ]
38
+ dependencies = [
39
+ "httpx>=0.27.0",
40
+ ]
41
+
42
+ [project.optional-dependencies]
43
+ crewai = ["crewai>=0.28.0"]
44
+ langchain = ["langchain-core>=0.1.0"]
45
+ dev = [
46
+ "pytest>=8.0.0",
47
+ "pytest-asyncio>=0.23.0",
48
+ "respx>=0.21.0",
49
+ "mypy>=1.8.0",
50
+ "ruff>=0.2.0",
51
+ "build>=1.0.0",
52
+ ]
53
+
54
+ [project.urls]
55
+ Homepage = "https://shieldcortex.ai"
56
+ Documentation = "https://shieldcortex.ai/docs"
57
+ Repository = "https://github.com/Drakon-Systems-Ltd/shieldcortex-python"
58
+ "Bug Tracker" = "https://github.com/Drakon-Systems-Ltd/shieldcortex-python/issues"
59
+
60
+ [tool.hatch.build.targets.wheel]
61
+ packages = ["src/shieldcortex"]
62
+
63
+ [tool.pytest.ini_options]
64
+ testpaths = ["tests"]
65
+ asyncio_mode = "auto"
66
+
67
+ [tool.mypy]
68
+ strict = true
69
+ warn_unreachable = true
70
+ pretty = true
71
+ show_error_context = true
72
+
73
+ [tool.ruff]
74
+ line-length = 100
75
+ target-version = "py39"
76
+
77
+ [tool.ruff.lint]
78
+ select = ["E", "F", "I", "UP"]
79
+ # UP007/UP045: Don't convert Optional[X] to X | None — types.py dataclass fields
80
+ # are evaluated at runtime by get_type_hints(), and X | None requires Python 3.10+.
81
+ ignore = ["UP007", "UP045"]