ct-toolkit 0.4.4__tar.gz → 0.5.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.
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/PKG-INFO +113 -81
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/README.md +104 -67
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/__init__.py +1 -1
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/cli.py +413 -6
- ct_toolkit-0.5.0/ct_toolkit/core/tool_guard.py +492 -0
- ct_toolkit-0.5.0/ct_toolkit/core/tool_guard_settings.py +209 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/wrapper.py +145 -3
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/__init__.py +13 -1
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/loss.py +8 -3
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/embedding.py +14 -6
- ct_toolkit-0.5.0/ct_toolkit/provenance/ledger.py +207 -0
- ct_toolkit-0.5.0/ct_toolkit/provenance/log.py +1176 -0
- ct_toolkit-0.5.0/ct_toolkit/provenance/tool_calls.py +136 -0
- ct_toolkit-0.5.0/ct_toolkit/proxy.py +496 -0
- ct_toolkit-0.5.0/ct_toolkit/server.py +2159 -0
- ct_toolkit-0.5.0/ct_toolkit/utils/cache.py +51 -0
- ct_toolkit-0.5.0/ct_toolkit/utils/trajectory_scrub.py +228 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/PKG-INFO +113 -81
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/SOURCES.txt +7 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/requires.txt +8 -12
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/pyproject.toml +13 -18
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_distributed_headers_and_cli.py +45 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_optional_dependencies.py +6 -3
- ct_toolkit-0.4.4/ct_toolkit/provenance/log.py +0 -755
- ct_toolkit-0.4.4/ct_toolkit/server.py +0 -1198
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/LICENSE +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/__main__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/async_wrapper.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/circuit_breaker.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/compatibility.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/compression_guard.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/exceptions.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/integrity.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/core/kernel.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/analysis.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/engine.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/l2_judge.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/l3_icm.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/divergence/scheduler.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/endorsement/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/endorsement/probes/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/endorsement/reflective.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/templates/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/templates/defense.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/templates/finance.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/templates/general.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/identity/templates/medical.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/kernels/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/kernels/default.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/kernels/defense.yaml +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/autogen.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/crewai.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/deepagents.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/langchain.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/middleware/litellm.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/profile_checksums.sha256 +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/provenance/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/provenance/vault/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/utils/__init__.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/utils/logger.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/utils/metrics.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/utils/sensitive_masker.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit/utils/telemetry.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/dependency_links.txt +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/entry_points.txt +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/ct_toolkit.egg-info/top_level.txt +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/setup.cfg +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_analysis.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_async_and_streaming.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_background_latency.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_cli.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_cli_extended.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_deep_agents_integration.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_enterprise_db_and_otel.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_l1_semantic.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_loss.py +0 -0
- {ct_toolkit-0.4.4 → ct_toolkit-0.5.0}/tests/test_summarization_drift.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ct-toolkit
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Computational Theseus Toolkit — Identity Continuity Guardrails for Agentic Systems
|
|
5
5
|
Author: Hakan Damar
|
|
6
6
|
License: Apache-2.0
|
|
@@ -25,13 +25,13 @@ Requires-Dist: jinja2>=3.1.0
|
|
|
25
25
|
Requires-Dist: pyasn1>=0.6.5
|
|
26
26
|
Requires-Dist: urllib3>=2.8.0
|
|
27
27
|
Requires-Dist: idna>=3.15
|
|
28
|
+
Requires-Dist: typer>=0.12.0
|
|
29
|
+
Requires-Dist: rich>=13.0.0
|
|
30
|
+
Requires-Dist: fastapi>=0.110.0
|
|
31
|
+
Requires-Dist: starlette>=1.3.1
|
|
32
|
+
Requires-Dist: uvicorn>=0.29.0
|
|
28
33
|
Provides-Extra: server
|
|
29
|
-
Requires-Dist: fastapi>=0.110.0; extra == "server"
|
|
30
|
-
Requires-Dist: starlette>=1.3.1; extra == "server"
|
|
31
|
-
Requires-Dist: uvicorn>=0.29.0; extra == "server"
|
|
32
34
|
Provides-Extra: cli
|
|
33
|
-
Requires-Dist: rich>=13.0.0; extra == "cli"
|
|
34
|
-
Requires-Dist: typer[all]>=0.12.0; extra == "cli"
|
|
35
35
|
Provides-Extra: observability
|
|
36
36
|
Requires-Dist: opentelemetry-api>=1.25.0; extra == "observability"
|
|
37
37
|
Requires-Dist: opentelemetry-sdk>=1.25.0; extra == "observability"
|
|
@@ -51,18 +51,13 @@ Requires-Dist: pyautogen>=0.4.0; extra == "autogen"
|
|
|
51
51
|
Provides-Extra: docs
|
|
52
52
|
Requires-Dist: mkdocs-material>=9.7.7; extra == "docs"
|
|
53
53
|
Requires-Dist: pymdown-extensions>=10.21.3; extra == "docs"
|
|
54
|
+
Provides-Extra: embeddings
|
|
55
|
+
Requires-Dist: fastembed>=0.3.0; extra == "embeddings"
|
|
54
56
|
Provides-Extra: ml
|
|
55
57
|
Requires-Dist: torch>=2.13.0; extra == "ml"
|
|
56
58
|
Requires-Dist: fastembed>=0.3.0; extra == "ml"
|
|
57
59
|
Provides-Extra: all
|
|
58
|
-
Requires-Dist:
|
|
59
|
-
Requires-Dist: starlette>=1.3.1; extra == "all"
|
|
60
|
-
Requires-Dist: uvicorn>=0.29.0; extra == "all"
|
|
61
|
-
Requires-Dist: rich>=13.0.0; extra == "all"
|
|
62
|
-
Requires-Dist: typer[all]>=0.12.0; extra == "all"
|
|
63
|
-
Requires-Dist: instructor>=1.3.0; extra == "all"
|
|
64
|
-
Requires-Dist: pillow>=11.3.0; extra == "all"
|
|
65
|
-
Requires-Dist: langsmith>=0.8.18; extra == "all"
|
|
60
|
+
Requires-Dist: ct-toolkit[langchain,observability,ollama,postgres,structured,vision]; extra == "all"
|
|
66
61
|
Provides-Extra: dev
|
|
67
62
|
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
68
63
|
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
|
|
@@ -80,7 +75,77 @@ Dynamic: license-file
|
|
|
80
75
|
[](https://theseus-guard.github.io/ct-toolkit/)
|
|
81
76
|
[](https://pepy.tech/projects/ct-toolkit)
|
|
82
77
|
|
|
83
|
-
CT Toolkit is an open-source security layer
|
|
78
|
+
CT Toolkit is an open-source security layer that keeps AI agents aligned with their original constitution over time. It watches what your agents say and do, reviews the tool calls they ask for, and records everything in a tamper-evident provenance chain you can inspect in a web dashboard.
|
|
79
|
+
|
|
80
|
+

|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Quick Start
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Core install: the library, the ct-toolkit CLI, the web dashboard and the tool-call guard
|
|
88
|
+
pip install ct-toolkit
|
|
89
|
+
|
|
90
|
+
# Optional extras: ml (torch, fastembed), postgres, observability, structured, vision, all
|
|
91
|
+
pip install "ct-toolkit[all]"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Wrap your model client in one line:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from ct_toolkit import TheseusWrapper, WrapperConfig
|
|
98
|
+
|
|
99
|
+
# Protect against silent provider context compression
|
|
100
|
+
config = WrapperConfig(compression_passive_detection=True)
|
|
101
|
+
|
|
102
|
+
# One-line injection for any LLM provider
|
|
103
|
+
client = TheseusWrapper(provider="openai", config=config)
|
|
104
|
+
|
|
105
|
+
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
106
|
+
response = client.chat("What are your core security axioms?")
|
|
107
|
+
|
|
108
|
+
print(response.content)
|
|
109
|
+
print(f"Divergence Score: {response.divergence_score}")
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Open the dashboard on the provenance vault your wrapper writes to:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
116
|
+
# then open http://127.0.0.1:8001/dashboard
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
To put the tool-call guard in front of a coding agent, run the local proxy and point the agent's base URL at it. The [OpenCode with AWS Bedrock guide](https://theseus-guard.github.io/ct-toolkit/guides/opencode-bedrock/) shows the full setup.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
ct-toolkit proxy --upstream https://api.openai.com --port 8788 --tool-guard-mode observe
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Why CT Toolkit?
|
|
128
|
+
|
|
129
|
+
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
130
|
+
|
|
131
|
+
- **Tool-Call Guard**: Reviews the tool calls an agent asks for before the harness runs them: undeclared tools, hosts the conversation never mentions, and risky commands or credential reads. Runs without a second model; `observe` records findings, `enforce` removes high-severity calls. Available as a library wrapper, a local proxy (`ct-toolkit proxy`) and the guardrail server.
|
|
132
|
+
- **Provenance Ledger of All Traffic**: Every request that passes through the proxy is recorded: model turns, other API calls and each tool-call decision. Text is stored as hashes only, and the chain is HMAC-signed, so you can audit what went through CT Toolkit and verify that no entry was changed.
|
|
133
|
+
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection. Divergence is graded into L1, L2 and L3 tiers.
|
|
134
|
+
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
135
|
+
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
136
|
+
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
137
|
+
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
138
|
+
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
139
|
+
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
140
|
+
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## CLI & Web Dashboard
|
|
145
|
+
|
|
146
|
+
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard. The dashboard shows the divergence timeline and tier breakdown, the staged kernel rules, the provenance ledger and the tool-call guard decisions, with paging, sorting and filtering on each table.
|
|
147
|
+
|
|
148
|
+
Example output of `ct-toolkit status`:
|
|
84
149
|
|
|
85
150
|
```text
|
|
86
151
|
$ ct-toolkit status
|
|
@@ -92,7 +157,7 @@ $ ct-toolkit status
|
|
|
92
157
|
| | | | | | |____ ____) | |____| |__| |____) | | |__| | |__| |/ ____ \| | \ \| |__| |
|
|
93
158
|
|_| |_| |_|______|_____/|______|_____/|_____/ \_____|\____//_/ \_\_| \_\_____/
|
|
94
159
|
|
|
95
|
-
Computational Theseus Toolkit (CT Toolkit) v0.
|
|
160
|
+
Computational Theseus Toolkit (CT Toolkit) v0.5.0
|
|
96
161
|
Identity Continuity Guardrails for Agentic Systems
|
|
97
162
|
|
|
98
163
|
╭──────────────────── CT Toolkit Audit & Telemetry Status ─────────────────────╮
|
|
@@ -123,65 +188,7 @@ $ ct-toolkit status
|
|
|
123
188
|
└────────────────┴──────────────────┴────────────────────┴─────────────────────┘
|
|
124
189
|
```
|
|
125
190
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
## 📖 Official Documentation
|
|
129
|
-
|
|
130
|
-
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
131
|
-
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
132
|
-
|
|
133
|
-
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
134
|
-
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
135
|
-
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## Why CT Toolkit?
|
|
140
|
-
|
|
141
|
-
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
142
|
-
|
|
143
|
-
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
144
|
-
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection.
|
|
145
|
-
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
146
|
-
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
147
|
-
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
148
|
-
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
149
|
-
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
150
|
-
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
151
|
-
|
|
152
|
-

|
|
153
|
-
|
|
154
|
-
---
|
|
155
|
-
|
|
156
|
-
## Quick Start
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
# Core lightweight install
|
|
160
|
-
pip install ct-toolkit
|
|
161
|
-
|
|
162
|
-
# Or install with optional extras (cli, server, enterprise, embeddings, observability, all)
|
|
163
|
-
pip install "ct-toolkit[all]"
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
```python
|
|
167
|
-
from ct_toolkit import TheseusWrapper, WrapperConfig
|
|
168
|
-
|
|
169
|
-
# Protect against silent provider context compression
|
|
170
|
-
config = WrapperConfig(compression_passive_detection=True)
|
|
171
|
-
|
|
172
|
-
# One-line injection for any LLM provider
|
|
173
|
-
client = TheseusWrapper(provider="openai", config=config)
|
|
174
|
-
|
|
175
|
-
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
176
|
-
response = client.chat("What are your core security axioms?")
|
|
177
|
-
|
|
178
|
-
print(response.content)
|
|
179
|
-
print(f"Divergence Score: {response.divergence_score}")
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
### 🔍 Standalone Auditor & Dashboard (CLI & Web UI)
|
|
183
|
-
|
|
184
|
-
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard:
|
|
191
|
+
Common commands:
|
|
185
192
|
|
|
186
193
|
```bash
|
|
187
194
|
# View Provenance Chain integrity, L1/L2/L3 tier breakdown, and staged rules in terminal
|
|
@@ -193,6 +200,19 @@ ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
|
193
200
|
# Audit a local Ollama model
|
|
194
201
|
ct-toolkit audit --url http://localhost:11434/v1 --kernel defense
|
|
195
202
|
|
|
203
|
+
# Review the tool calls in a saved model response (exit code 1 on a high-severity finding)
|
|
204
|
+
ct-toolkit tool-guard check ./response.json --mode enforce
|
|
205
|
+
|
|
206
|
+
# Run a local tool-call proxy that removes risky calls; point the harness's base URL at http://127.0.0.1:8788
|
|
207
|
+
ct-toolkit proxy --upstream https://api.openai.com --port 8788 --tool-guard-mode enforce
|
|
208
|
+
|
|
209
|
+
# List, count and inspect tool-call decisions in the provenance vault
|
|
210
|
+
ct-toolkit tool-guard list --vault ./ct_provenance.db --verdict blocked
|
|
211
|
+
ct-toolkit tool-guard stats --vault ./ct_provenance.db
|
|
212
|
+
|
|
213
|
+
# Redact credentials, emails, home directories and public IPs from a trajectory (dry run without --out)
|
|
214
|
+
ct-toolkit scrub ./trajectories --out ./trajectories_clean
|
|
215
|
+
|
|
196
216
|
# List available kernels and templates
|
|
197
217
|
ct-toolkit list-kernels
|
|
198
218
|
ct-toolkit list-templates
|
|
@@ -201,10 +221,6 @@ ct-toolkit list-templates
|
|
|
201
221
|
ct-toolkit setup personal_kernel --dest ./config
|
|
202
222
|
```
|
|
203
223
|
|
|
204
|
-
If you want a runnable application example instead of a CLI-only flow, see [**ct-toolkit-fastapi**](https://github.com/hakandamar/ct-toolkit-fastapi), a small FastAPI validation project that developers can use to test CT Toolkit locally with automated endpoints and pytest coverage.
|
|
205
|
-
|
|
206
|
-
For Deep Agents workflows, see [**ct-toolkit-deep-agents**](https://github.com/hakandamar/ct-toolkit-deep-agents), a reference integration project for validating CT Toolkit in multi-agent orchestration scenarios.
|
|
207
|
-
|
|
208
224
|
### Security Hardening
|
|
209
225
|
|
|
210
226
|
The profile setup command fails closed by default. Downloaded kernel, identity, and probe files must match the trusted SHA-256 manifest packaged with CT Toolkit before they are written to disk. HTTPS certificate validation is enabled and redirects to another host or scheme are rejected.
|
|
@@ -213,13 +229,29 @@ The L2 judge does not evaluate Jinja2 expressions in user requests or model resp
|
|
|
213
229
|
|
|
214
230
|
---
|
|
215
231
|
|
|
232
|
+
## 📖 Documentation & Examples
|
|
233
|
+
|
|
234
|
+
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
235
|
+
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
236
|
+
|
|
237
|
+
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
238
|
+
- [**OpenCode with AWS Bedrock**](https://theseus-guard.github.io/ct-toolkit/guides/opencode-bedrock/): Route a coding agent through the tool-call guard and the provenance ledger.
|
|
239
|
+
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
240
|
+
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
241
|
+
|
|
242
|
+
If you want a runnable application example instead of a CLI-only flow, see [**ct-toolkit-fastapi**](https://github.com/hakandamar/ct-toolkit-fastapi), a small FastAPI validation project that developers can use to test CT Toolkit locally with automated endpoints and pytest coverage.
|
|
243
|
+
|
|
244
|
+
For Deep Agents workflows, see [**ct-toolkit-deep-agents**](https://github.com/hakandamar/ct-toolkit-deep-agents), a reference integration project for validating CT Toolkit in multi-agent orchestration scenarios.
|
|
245
|
+
|
|
246
|
+
---
|
|
247
|
+
|
|
216
248
|
## 🚦 Project Health & Status
|
|
217
249
|
|
|
218
250
|
| Metric | Status |
|
|
219
251
|
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
220
|
-
| **Tests** | ✅
|
|
252
|
+
| **Tests** | ✅ 617 passed, 13 skipped |
|
|
221
253
|
| **Downloads** | [](https://pepy.tech/projects/ct-toolkit) |
|
|
222
|
-
| **Last Phase** | ✅ v0.
|
|
254
|
+
| **Last Phase** | ✅ v0.5.0: provenance ledger of all proxied traffic, graded divergence scoring, paged dashboard tables |
|
|
223
255
|
|
|
224
256
|
### Framework & Model Support
|
|
225
257
|
|
|
@@ -8,7 +8,77 @@
|
|
|
8
8
|
[](https://theseus-guard.github.io/ct-toolkit/)
|
|
9
9
|
[](https://pepy.tech/projects/ct-toolkit)
|
|
10
10
|
|
|
11
|
-
CT Toolkit is an open-source security layer
|
|
11
|
+
CT Toolkit is an open-source security layer that keeps AI agents aligned with their original constitution over time. It watches what your agents say and do, reviews the tool calls they ask for, and records everything in a tamper-evident provenance chain you can inspect in a web dashboard.
|
|
12
|
+
|
|
13
|
+

|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Core install: the library, the ct-toolkit CLI, the web dashboard and the tool-call guard
|
|
21
|
+
pip install ct-toolkit
|
|
22
|
+
|
|
23
|
+
# Optional extras: ml (torch, fastembed), postgres, observability, structured, vision, all
|
|
24
|
+
pip install "ct-toolkit[all]"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Wrap your model client in one line:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from ct_toolkit import TheseusWrapper, WrapperConfig
|
|
31
|
+
|
|
32
|
+
# Protect against silent provider context compression
|
|
33
|
+
config = WrapperConfig(compression_passive_detection=True)
|
|
34
|
+
|
|
35
|
+
# One-line injection for any LLM provider
|
|
36
|
+
client = TheseusWrapper(provider="openai", config=config)
|
|
37
|
+
|
|
38
|
+
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
39
|
+
response = client.chat("What are your core security axioms?")
|
|
40
|
+
|
|
41
|
+
print(response.content)
|
|
42
|
+
print(f"Divergence Score: {response.divergence_score}")
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Open the dashboard on the provenance vault your wrapper writes to:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
49
|
+
# then open http://127.0.0.1:8001/dashboard
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
To put the tool-call guard in front of a coding agent, run the local proxy and point the agent's base URL at it. The [OpenCode with AWS Bedrock guide](https://theseus-guard.github.io/ct-toolkit/guides/opencode-bedrock/) shows the full setup.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
ct-toolkit proxy --upstream https://api.openai.com --port 8788 --tool-guard-mode observe
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Why CT Toolkit?
|
|
61
|
+
|
|
62
|
+
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
63
|
+
|
|
64
|
+
- **Tool-Call Guard**: Reviews the tool calls an agent asks for before the harness runs them: undeclared tools, hosts the conversation never mentions, and risky commands or credential reads. Runs without a second model; `observe` records findings, `enforce` removes high-severity calls. Available as a library wrapper, a local proxy (`ct-toolkit proxy`) and the guardrail server.
|
|
65
|
+
- **Provenance Ledger of All Traffic**: Every request that passes through the proxy is recorded: model turns, other API calls and each tool-call decision. Text is stored as hashes only, and the chain is HMAC-signed, so you can audit what went through CT Toolkit and verify that no entry was changed.
|
|
66
|
+
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection. Divergence is graded into L1, L2 and L3 tiers.
|
|
67
|
+
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
68
|
+
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
69
|
+
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
70
|
+
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
71
|
+
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
72
|
+
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
73
|
+
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## CLI & Web Dashboard
|
|
78
|
+
|
|
79
|
+
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard. The dashboard shows the divergence timeline and tier breakdown, the staged kernel rules, the provenance ledger and the tool-call guard decisions, with paging, sorting and filtering on each table.
|
|
80
|
+
|
|
81
|
+
Example output of `ct-toolkit status`:
|
|
12
82
|
|
|
13
83
|
```text
|
|
14
84
|
$ ct-toolkit status
|
|
@@ -20,7 +90,7 @@ $ ct-toolkit status
|
|
|
20
90
|
| | | | | | |____ ____) | |____| |__| |____) | | |__| | |__| |/ ____ \| | \ \| |__| |
|
|
21
91
|
|_| |_| |_|______|_____/|______|_____/|_____/ \_____|\____//_/ \_\_| \_\_____/
|
|
22
92
|
|
|
23
|
-
Computational Theseus Toolkit (CT Toolkit) v0.
|
|
93
|
+
Computational Theseus Toolkit (CT Toolkit) v0.5.0
|
|
24
94
|
Identity Continuity Guardrails for Agentic Systems
|
|
25
95
|
|
|
26
96
|
╭──────────────────── CT Toolkit Audit & Telemetry Status ─────────────────────╮
|
|
@@ -51,65 +121,7 @@ $ ct-toolkit status
|
|
|
51
121
|
└────────────────┴──────────────────┴────────────────────┴─────────────────────┘
|
|
52
122
|
```
|
|
53
123
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
## 📖 Official Documentation
|
|
57
|
-
|
|
58
|
-
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
59
|
-
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
60
|
-
|
|
61
|
-
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
62
|
-
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
63
|
-
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
64
|
-
|
|
65
|
-
---
|
|
66
|
-
|
|
67
|
-
## Why CT Toolkit?
|
|
68
|
-
|
|
69
|
-
In complex agentic workflows, LLMs tend to "drift" from their original instructions. CT Toolkit provides the mathematical and cryptographic guardrails to ensure your agents remain aligned with their core constitution, even across deep hierarchies.
|
|
70
|
-
|
|
71
|
-
- **Async & Streaming Guardrails (`achat`)**: Native `async/await` and streaming (`stream=True`) support with non-blocking background execution for shadow requests and L3 ICM probes.
|
|
72
|
-
- **Contrastive Semantic L1 Engine**: Provider-independent embeddings (`litellm`, `ollama`, local `fastembed`) with positive/negative anchor analysis and semantic rule conflict detection.
|
|
73
|
-
- **Staged Approval (Cooldown)**: Verify risky kernel updates in a sandbox via shadow requests before production promotion.
|
|
74
|
-
- **Passive Context Compression Detection**: Automatically detects silent provider-side history compression (e.g., OpenAI/Anthropic).
|
|
75
|
-
- **Constitutional Kernels & Distributed Propagation**: Axiomatic identity anchors with HMAC-SHA256 signed HTTP header propagation (`propagate_headers` / `from_headers`).
|
|
76
|
-
- **Standalone Auditor & Status CLI**: Rapidly audit any LLM endpoint (`ct-toolkit audit`) and inspect provenance integrity & divergence tiers (`ct-toolkit status` / `dashboard`).
|
|
77
|
-
- **Autonomous Self-Correction**: Active L2->L1 feedback loop that retries and corrects divergent responses before they reach the user.
|
|
78
|
-
- **Enterprise Provenance & Observability**: Immutable HMAC-signed hash chain supporting SQLite and PostgreSQL/SQLAlchemy with paginated verification and OpenTelemetry (OTel) spans/metrics.
|
|
79
|
-
|
|
80
|
-

|
|
81
|
-
|
|
82
|
-
---
|
|
83
|
-
|
|
84
|
-
## Quick Start
|
|
85
|
-
|
|
86
|
-
```bash
|
|
87
|
-
# Core lightweight install
|
|
88
|
-
pip install ct-toolkit
|
|
89
|
-
|
|
90
|
-
# Or install with optional extras (cli, server, enterprise, embeddings, observability, all)
|
|
91
|
-
pip install "ct-toolkit[all]"
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
```python
|
|
95
|
-
from ct_toolkit import TheseusWrapper, WrapperConfig
|
|
96
|
-
|
|
97
|
-
# Protect against silent provider context compression
|
|
98
|
-
config = WrapperConfig(compression_passive_detection=True)
|
|
99
|
-
|
|
100
|
-
# One-line injection for any LLM provider
|
|
101
|
-
client = TheseusWrapper(provider="openai", config=config)
|
|
102
|
-
|
|
103
|
-
# Sync or async (`await client.achat(...)`) with automatic drift analysis
|
|
104
|
-
response = client.chat("What are your core security axioms?")
|
|
105
|
-
|
|
106
|
-
print(response.content)
|
|
107
|
-
print(f"Divergence Score: {response.divergence_score}")
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### 🔍 Standalone Auditor & Dashboard (CLI & Web UI)
|
|
111
|
-
|
|
112
|
-
Audit any LLM endpoint (OpenAI, Ollama, LM Studio) and inspect your provenance chain directly from your terminal or in the interactive Web Audit Dashboard:
|
|
124
|
+
Common commands:
|
|
113
125
|
|
|
114
126
|
```bash
|
|
115
127
|
# View Provenance Chain integrity, L1/L2/L3 tier breakdown, and staged rules in terminal
|
|
@@ -121,6 +133,19 @@ ct-toolkit dashboard --web --vault ./ct_provenance.db --port 8001
|
|
|
121
133
|
# Audit a local Ollama model
|
|
122
134
|
ct-toolkit audit --url http://localhost:11434/v1 --kernel defense
|
|
123
135
|
|
|
136
|
+
# Review the tool calls in a saved model response (exit code 1 on a high-severity finding)
|
|
137
|
+
ct-toolkit tool-guard check ./response.json --mode enforce
|
|
138
|
+
|
|
139
|
+
# Run a local tool-call proxy that removes risky calls; point the harness's base URL at http://127.0.0.1:8788
|
|
140
|
+
ct-toolkit proxy --upstream https://api.openai.com --port 8788 --tool-guard-mode enforce
|
|
141
|
+
|
|
142
|
+
# List, count and inspect tool-call decisions in the provenance vault
|
|
143
|
+
ct-toolkit tool-guard list --vault ./ct_provenance.db --verdict blocked
|
|
144
|
+
ct-toolkit tool-guard stats --vault ./ct_provenance.db
|
|
145
|
+
|
|
146
|
+
# Redact credentials, emails, home directories and public IPs from a trajectory (dry run without --out)
|
|
147
|
+
ct-toolkit scrub ./trajectories --out ./trajectories_clean
|
|
148
|
+
|
|
124
149
|
# List available kernels and templates
|
|
125
150
|
ct-toolkit list-kernels
|
|
126
151
|
ct-toolkit list-templates
|
|
@@ -129,10 +154,6 @@ ct-toolkit list-templates
|
|
|
129
154
|
ct-toolkit setup personal_kernel --dest ./config
|
|
130
155
|
```
|
|
131
156
|
|
|
132
|
-
If you want a runnable application example instead of a CLI-only flow, see [**ct-toolkit-fastapi**](https://github.com/hakandamar/ct-toolkit-fastapi), a small FastAPI validation project that developers can use to test CT Toolkit locally with automated endpoints and pytest coverage.
|
|
133
|
-
|
|
134
|
-
For Deep Agents workflows, see [**ct-toolkit-deep-agents**](https://github.com/hakandamar/ct-toolkit-deep-agents), a reference integration project for validating CT Toolkit in multi-agent orchestration scenarios.
|
|
135
|
-
|
|
136
157
|
### Security Hardening
|
|
137
158
|
|
|
138
159
|
The profile setup command fails closed by default. Downloaded kernel, identity, and probe files must match the trusted SHA-256 manifest packaged with CT Toolkit before they are written to disk. HTTPS certificate validation is enabled and redirects to another host or scheme are rejected.
|
|
@@ -141,13 +162,29 @@ The L2 judge does not evaluate Jinja2 expressions in user requests or model resp
|
|
|
141
162
|
|
|
142
163
|
---
|
|
143
164
|
|
|
165
|
+
## 📖 Documentation & Examples
|
|
166
|
+
|
|
167
|
+
For full API reference, architecture details, examples, and integration guides, visit our documentation site:
|
|
168
|
+
👉 [**https://theseus-guard.github.io/ct-toolkit/**](https://theseus-guard.github.io/ct-toolkit/)
|
|
169
|
+
|
|
170
|
+
- [**Live Examples & Case Studies**](https://theseus-guard.github.io/ct-toolkit/examples/): Real-world scenarios like Financial Auditor Integrity.
|
|
171
|
+
- [**OpenCode with AWS Bedrock**](https://theseus-guard.github.io/ct-toolkit/guides/opencode-bedrock/): Route a coding agent through the tool-call guard and the provenance ledger.
|
|
172
|
+
- [**FastAPI Integration Test Project**](https://github.com/hakandamar/ct-toolkit-fastapi): Reference FastAPI app for validating CT Toolkit end-to-end across L1/L2/L3 guardrails and provenance logs with local model infrastructure.
|
|
173
|
+
- [**Deep Agents Integration Test Project**](https://github.com/hakandamar/ct-toolkit-deep-agents): Reference Deep Agents app for validating CT Toolkit end-to-end with hierarchical agent workflows, L1/L2/L3 guardrails, and provenance logs.
|
|
174
|
+
|
|
175
|
+
If you want a runnable application example instead of a CLI-only flow, see [**ct-toolkit-fastapi**](https://github.com/hakandamar/ct-toolkit-fastapi), a small FastAPI validation project that developers can use to test CT Toolkit locally with automated endpoints and pytest coverage.
|
|
176
|
+
|
|
177
|
+
For Deep Agents workflows, see [**ct-toolkit-deep-agents**](https://github.com/hakandamar/ct-toolkit-deep-agents), a reference integration project for validating CT Toolkit in multi-agent orchestration scenarios.
|
|
178
|
+
|
|
179
|
+
---
|
|
180
|
+
|
|
144
181
|
## 🚦 Project Health & Status
|
|
145
182
|
|
|
146
183
|
| Metric | Status |
|
|
147
184
|
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
148
|
-
| **Tests** | ✅
|
|
185
|
+
| **Tests** | ✅ 617 passed, 13 skipped |
|
|
149
186
|
| **Downloads** | [](https://pepy.tech/projects/ct-toolkit) |
|
|
150
|
-
| **Last Phase** | ✅ v0.
|
|
187
|
+
| **Last Phase** | ✅ v0.5.0: provenance ledger of all proxied traffic, graded divergence scoring, paged dashboard tables |
|
|
151
188
|
|
|
152
189
|
### Framework & Model Support
|
|
153
190
|
|