blocklog 0.2.0__tar.gz → 0.2.4__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.
- {blocklog-0.2.0 → blocklog-0.2.4}/PKG-INFO +90 -6
- blocklog-0.2.0/src/blocklog.egg-info/PKG-INFO → blocklog-0.2.4/README.md +68 -38
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/api-reference.md +75 -43
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/examples.md +0 -1
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/index.md +2 -2
- blocklog-0.2.4/docs/installation.md +26 -0
- blocklog-0.2.4/docs/integrations.md +208 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/troubleshooting.md +1 -1
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/02_stock_trading_agent.py +1 -2
- blocklog-0.2.4/examples/04_team_management.py +38 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/pyproject.toml +19 -5
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/__init__.py +38 -2
- blocklog-0.2.4/src/blocklog/_init_fn.py +185 -0
- blocklog-0.2.4/src/blocklog/api/auth.py +143 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/decisions.py +58 -43
- blocklog-0.2.4/src/blocklog/api/teams.py +197 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/verify.py +9 -9
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/async_client.py +11 -5
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/client.py +32 -14
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/config.py +3 -1
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/context/managers.py +5 -7
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/decorators/agent.py +19 -4
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/decorators/tool.py +9 -3
- blocklog-0.2.4/src/blocklog/exceptions.py +70 -0
- blocklog-0.2.4/src/blocklog/integrations/langchain.py +189 -0
- blocklog-0.2.4/src/blocklog/integrations/langgraph.py +560 -0
- blocklog-0.2.4/src/blocklog/integrations/litellm.py +361 -0
- blocklog-0.2.4/src/blocklog/integrations/openai_agents.py +374 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/managers/decision.py +138 -10
- blocklog-0.2.4/src/blocklog/models/auth.py +35 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/models/events.py +2 -2
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/models/responses.py +2 -2
- blocklog-0.2.4/src/blocklog/models/teams.py +101 -0
- blocklog-0.2.4/src/blocklog/signing/ed25519.py +18 -0
- blocklog-0.2.4/src/blocklog/team_utils.py +21 -0
- blocklog-0.2.4/src/blocklog/transport/auth.py +18 -0
- blocklog-0.2.4/src/blocklog/transport/httpx_async.py +82 -0
- blocklog-0.2.4/src/blocklog/transport/httpx_sync.py +79 -0
- blocklog-0.2.4/src/blocklog/transport/retry.py +51 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/verify.py +7 -7
- blocklog-0.2.0/README.md → blocklog-0.2.4/src/blocklog.egg-info/PKG-INFO +121 -2
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog.egg-info/SOURCES.txt +9 -0
- blocklog-0.2.4/src/blocklog.egg-info/requires.txt +34 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_client.py +29 -7
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_config.py +11 -9
- blocklog-0.2.4/tests/test_errors_and_health.py +227 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_public_api.py +7 -3
- blocklog-0.2.0/docs/installation.md +0 -36
- blocklog-0.2.0/docs/integrations.md +0 -45
- blocklog-0.2.0/src/blocklog/_init_fn.py +0 -95
- blocklog-0.2.0/src/blocklog/integrations/langchain.py +0 -129
- blocklog-0.2.0/src/blocklog/integrations/langgraph.py +0 -3
- blocklog-0.2.0/src/blocklog/integrations/openai_agents.py +0 -3
- blocklog-0.2.0/src/blocklog/signing/ed25519.py +0 -25
- blocklog-0.2.0/src/blocklog/transport/auth.py +0 -8
- blocklog-0.2.0/src/blocklog/transport/httpx_async.py +0 -39
- blocklog-0.2.0/src/blocklog/transport/httpx_sync.py +0 -36
- blocklog-0.2.0/src/blocklog/transport/retry.py +0 -26
- blocklog-0.2.0/src/blocklog.egg-info/requires.txt +0 -9
- {blocklog-0.2.0 → blocklog-0.2.4}/LICENSE +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/MANIFEST.in +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/async.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/changelog.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/concepts.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/configuration.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/decisions.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/decorators.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/error-handling.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/migration.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/performance.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/production.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/quickstart.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/docs/tracing.md +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/01_quickstart.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/03_multi_agent_workflow.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/advanced/01_human_approval_workflow.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/advanced/02_incident_investigation.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/advanced/03_decision_comparison.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/examples/advanced/langchain_alert_demo.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/setup.cfg +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/_global.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/approval.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/compliance.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/incidents.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/replay.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/api/traces.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/approval.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/batching/buffer.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/compliance.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/context/vars.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/decorators/__init__.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/incident.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/managers/__init__.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/middleware/hooks.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/replay.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog/signing/canonical.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog.egg-info/dependency_links.txt +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/src/blocklog.egg-info/top_level.txt +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_context.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_decorators.py +0 -0
- {blocklog-0.2.0 → blocklog-0.2.4}/tests/test_transport.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blocklog
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.4
|
|
4
4
|
Summary: Infrastructure for AI Decision-Making — record, replay, verify, and govern AI agent decisions
|
|
5
|
-
Author-email: Blocklog <
|
|
6
|
-
Maintainer-email: Blocklog <
|
|
5
|
+
Author-email: Blocklog <founder@blocklogsecurity.com>
|
|
6
|
+
Maintainer-email: Blocklog <founder@blocklogsecurity.com>
|
|
7
7
|
License: MIT
|
|
8
8
|
Project-URL: Homepage, https://blockloghq.com
|
|
9
9
|
Project-URL: Documentation, https://docs.blockloghq.com
|
|
@@ -25,12 +25,31 @@ Description-Content-Type: text/markdown
|
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: httpx<1.0,>=0.27
|
|
27
27
|
Requires-Dist: pydantic<3.0,>=2.8
|
|
28
|
-
|
|
28
|
+
Provides-Extra: requests
|
|
29
|
+
Requires-Dist: requests>=2.32.0; extra == "requests"
|
|
30
|
+
Provides-Extra: langchain
|
|
31
|
+
Requires-Dist: langchain-core>=0.2.0; extra == "langchain"
|
|
32
|
+
Provides-Extra: langgraph
|
|
33
|
+
Requires-Dist: langchain-core>=0.2.0; extra == "langgraph"
|
|
34
|
+
Requires-Dist: langgraph>=0.2.0; extra == "langgraph"
|
|
35
|
+
Provides-Extra: openai
|
|
36
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
37
|
+
Provides-Extra: litellm
|
|
38
|
+
Requires-Dist: litellm>=1.40.0; extra == "litellm"
|
|
39
|
+
Provides-Extra: all
|
|
40
|
+
Requires-Dist: langchain-core>=0.2.0; extra == "all"
|
|
41
|
+
Requires-Dist: langgraph>=0.2.0; extra == "all"
|
|
42
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
43
|
+
Requires-Dist: litellm>=1.40.0; extra == "all"
|
|
29
44
|
Provides-Extra: dev
|
|
30
45
|
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
31
46
|
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
32
47
|
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
33
48
|
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
49
|
+
Requires-Dist: langchain-core>=0.2.0; extra == "dev"
|
|
50
|
+
Requires-Dist: langgraph>=0.2.0; extra == "dev"
|
|
51
|
+
Requires-Dist: openai>=1.0.0; extra == "dev"
|
|
52
|
+
Requires-Dist: litellm>=1.40.0; extra == "dev"
|
|
34
53
|
Dynamic: license-file
|
|
35
54
|
|
|
36
55
|
# Blocklog Python SDK
|
|
@@ -56,7 +75,7 @@ When AI agents execute actions in production, the context behind their decisions
|
|
|
56
75
|
- **Trace tool calls**, capturing inputs and outputs seamlessly.
|
|
57
76
|
- **Record decisions** with detailed metadata, inputs, and outputs.
|
|
58
77
|
- **Request approvals** via non-blocking human-in-the-loop workflows.
|
|
59
|
-
- **Verify records** cryptographically against
|
|
78
|
+
- **Verify records** cryptographically against Ed25519 signatures.
|
|
60
79
|
- **Generate compliance evidence** (e.g., SOC2, GDPR).
|
|
61
80
|
- **Investigate failures with replay** using forensic timelines and root-cause analysis.
|
|
62
81
|
|
|
@@ -128,6 +147,53 @@ if __name__ == "__main__":
|
|
|
128
147
|
run_agent()
|
|
129
148
|
```
|
|
130
149
|
|
|
150
|
+
## Signup And Teams
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from blocklog import (
|
|
154
|
+
AsyncBlocklogClient,
|
|
155
|
+
BlocklogClient,
|
|
156
|
+
can_manage_members,
|
|
157
|
+
can_manage_team,
|
|
158
|
+
get_primary_team,
|
|
159
|
+
is_team_owner,
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
client = BlocklogClient(
|
|
163
|
+
base_url="https://your-blocklog-host/api/v1",
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
signup = client.auth.signup(
|
|
167
|
+
username="jane",
|
|
168
|
+
email="jane@example.com",
|
|
169
|
+
password="ChangeMe123!",
|
|
170
|
+
workspace_name="Acme Security",
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
print(signup.team.name)
|
|
174
|
+
print(is_team_owner(signup.team, signup.user.user_id))
|
|
175
|
+
print(signup.team.owner_user_id)
|
|
176
|
+
|
|
177
|
+
client.set_access_token(signup.token)
|
|
178
|
+
|
|
179
|
+
teams = client.teams.list()
|
|
180
|
+
primary_team = get_primary_team(teams)
|
|
181
|
+
|
|
182
|
+
if primary_team and can_manage_team(primary_team, signup.user.user_id):
|
|
183
|
+
client.teams.update(primary_team.id, default_sla_minutes=30)
|
|
184
|
+
members = client.teams.members.list(primary_team.id)
|
|
185
|
+
if members and can_manage_members(members[0]):
|
|
186
|
+
client.teams.notify_test(primary_team.id)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
async def async_example() -> None:
|
|
190
|
+
async_client = AsyncBlocklogClient(base_url="https://your-blocklog-host/api/v1")
|
|
191
|
+
login = await async_client.auth.login("jane@example.com", "ChangeMe123!")
|
|
192
|
+
async_client.set_access_token(login.token)
|
|
193
|
+
teams = await async_client.teams.list()
|
|
194
|
+
print(teams)
|
|
195
|
+
```
|
|
196
|
+
|
|
131
197
|
---
|
|
132
198
|
|
|
133
199
|
## What Happens Under The Hood?
|
|
@@ -162,6 +228,7 @@ Blocklog seamlessly auto-instruments popular AI frameworks:
|
|
|
162
228
|
- **LangChain**: Trace chains, LLMs, and tools automatically via `client.instrument_langchain()`.
|
|
163
229
|
- **LangGraph**: Hook into graph states via `client.instrument_langgraph()`.
|
|
164
230
|
- **OpenAI Agents**: Track official SDK executions via `client.instrument_openai_agents()`.
|
|
231
|
+
- **LiteLLM**: Instrument any LiteLLM completion call via `client.instrument_litellm()`.
|
|
165
232
|
|
|
166
233
|
Read more in the [Integrations Guide](docs/integrations.md).
|
|
167
234
|
|
|
@@ -173,7 +240,7 @@ Read more in the [Integrations Guide](docs/integrations.md).
|
|
|
173
240
|
|-------|-------|
|
|
174
241
|
| **Getting Started** | [Installation](docs/installation.md) • [Quickstart](docs/quickstart.md) • [Core Concepts](docs/concepts.md) |
|
|
175
242
|
| **Instrumentation** | [Tracing](docs/tracing.md) • [Decisions](docs/decisions.md) • [Decorators](docs/decorators.md) |
|
|
176
|
-
| **Frameworks** | [Integrations](docs/integrations.md) |
|
|
243
|
+
| **Frameworks** | [Integrations](docs/integrations.md) — LangChain, LangGraph, OpenAI Agents, LiteLLM |
|
|
177
244
|
| **Operations** | [Async Usage](docs/async.md) • [Production](docs/production.md) • [Performance](docs/performance.md) |
|
|
178
245
|
| **Reference** | [API Reference](docs/api-reference.md) • [Error Handling](docs/error-handling.md) • [Troubleshooting](docs/troubleshooting.md) |
|
|
179
246
|
| **Misc** | [Examples](docs/examples.md) • [Changelog](docs/changelog.md) |
|
|
@@ -197,6 +264,8 @@ We provide several runnable scripts in the `examples/` directory to help you und
|
|
|
197
264
|
- **Retry Handling**: Built-in exponential backoff for transient network issues.
|
|
198
265
|
- **Signing**: Optional Ed25519 payload signing for tamper-evident, cryptographically verifiable logs.
|
|
199
266
|
- **Middleware Hooks**: Add custom logic to redact PII or inject metadata before payloads leave your server.
|
|
267
|
+
- **Typed Team APIs**: Ownership-aware models for teams, members, and signup responses.
|
|
268
|
+
- **Standardized Exceptions**: Authentication, authorization, validation, conflict, rate-limit, and server error mapping.
|
|
200
269
|
|
|
201
270
|
Read our [Production Best Practices](docs/production.md) for more details.
|
|
202
271
|
|
|
@@ -215,6 +284,7 @@ Blocklog can be configured via environment variables:
|
|
|
215
284
|
| Variable | Description | Default |
|
|
216
285
|
|----------|-------------|---------|
|
|
217
286
|
| `BLOCKLOG_API_KEY` | Your Blocklog API key | `""` |
|
|
287
|
+
| `BLOCKLOG_ACCESS_TOKEN` | User access token for dashboard-style APIs | `""` |
|
|
218
288
|
| `BLOCKLOG_BASE_URL` | API base URL | `http://127.0.0.1:8000/api/v1` |
|
|
219
289
|
| `BLOCKLOG_SDK_SIGNING_KEY` | Optional seed key for hash signing | `""` |
|
|
220
290
|
| `BLOCKLOG_TIMEOUT` | Request timeout in seconds | `10` |
|
|
@@ -257,6 +327,20 @@ If the SDK cannot connect to the Blocklog API:
|
|
|
257
327
|
3. Ensure network connectivity to the API server
|
|
258
328
|
4. Check firewall settings
|
|
259
329
|
|
|
330
|
+
## Teams API
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
from blocklog import BlocklogClient
|
|
334
|
+
|
|
335
|
+
client = BlocklogClient(access_token="user-token")
|
|
336
|
+
|
|
337
|
+
teams = client.teams.list()
|
|
338
|
+
team = client.teams.get(teams[0].id)
|
|
339
|
+
members = client.teams.members.list(team.id)
|
|
340
|
+
result = client.teams.notify_test(team.id)
|
|
341
|
+
print(result.results)
|
|
342
|
+
```
|
|
343
|
+
|
|
260
344
|
## Links
|
|
261
345
|
|
|
262
346
|
- **Homepage**: https://blockloghq.com
|
|
@@ -1,38 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: blocklog
|
|
3
|
-
Version: 0.2.0
|
|
4
|
-
Summary: Infrastructure for AI Decision-Making — record, replay, verify, and govern AI agent decisions
|
|
5
|
-
Author-email: Blocklog <contact@blockloghq.com>
|
|
6
|
-
Maintainer-email: Blocklog <contact@blockloghq.com>
|
|
7
|
-
License: MIT
|
|
8
|
-
Project-URL: Homepage, https://blockloghq.com
|
|
9
|
-
Project-URL: Documentation, https://docs.blockloghq.com
|
|
10
|
-
Project-URL: Repository, https://github.com/blockloghq/blocklog-python
|
|
11
|
-
Project-URL: Issues, https://github.com/blockloghq/blocklog-python/issues
|
|
12
|
-
Keywords: ai,agents,observability,governance,security,audit,replay
|
|
13
|
-
Classifier: Development Status :: 3 - Alpha
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
-
Classifier: Programming Language :: Python :: 3
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
-
Classifier: Topic :: System :: Monitoring
|
|
23
|
-
Requires-Python: >=3.10
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
License-File: LICENSE
|
|
26
|
-
Requires-Dist: httpx<1.0,>=0.27
|
|
27
|
-
Requires-Dist: pydantic<3.0,>=2.8
|
|
28
|
-
Requires-Dist: requests>=2.32.0
|
|
29
|
-
Provides-Extra: dev
|
|
30
|
-
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
31
|
-
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
32
|
-
Requires-Dist: build>=1.0.0; extra == "dev"
|
|
33
|
-
Requires-Dist: twine>=5.0.0; extra == "dev"
|
|
34
|
-
Dynamic: license-file
|
|
35
|
-
|
|
36
1
|
# Blocklog Python SDK
|
|
37
2
|
|
|
38
3
|
**Record, audit, and investigate every decision your AI agents make.**
|
|
@@ -56,7 +21,7 @@ When AI agents execute actions in production, the context behind their decisions
|
|
|
56
21
|
- **Trace tool calls**, capturing inputs and outputs seamlessly.
|
|
57
22
|
- **Record decisions** with detailed metadata, inputs, and outputs.
|
|
58
23
|
- **Request approvals** via non-blocking human-in-the-loop workflows.
|
|
59
|
-
- **Verify records** cryptographically against
|
|
24
|
+
- **Verify records** cryptographically against Ed25519 signatures.
|
|
60
25
|
- **Generate compliance evidence** (e.g., SOC2, GDPR).
|
|
61
26
|
- **Investigate failures with replay** using forensic timelines and root-cause analysis.
|
|
62
27
|
|
|
@@ -128,6 +93,53 @@ if __name__ == "__main__":
|
|
|
128
93
|
run_agent()
|
|
129
94
|
```
|
|
130
95
|
|
|
96
|
+
## Signup And Teams
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from blocklog import (
|
|
100
|
+
AsyncBlocklogClient,
|
|
101
|
+
BlocklogClient,
|
|
102
|
+
can_manage_members,
|
|
103
|
+
can_manage_team,
|
|
104
|
+
get_primary_team,
|
|
105
|
+
is_team_owner,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
client = BlocklogClient(
|
|
109
|
+
base_url="https://your-blocklog-host/api/v1",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
signup = client.auth.signup(
|
|
113
|
+
username="jane",
|
|
114
|
+
email="jane@example.com",
|
|
115
|
+
password="ChangeMe123!",
|
|
116
|
+
workspace_name="Acme Security",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
print(signup.team.name)
|
|
120
|
+
print(is_team_owner(signup.team, signup.user.user_id))
|
|
121
|
+
print(signup.team.owner_user_id)
|
|
122
|
+
|
|
123
|
+
client.set_access_token(signup.token)
|
|
124
|
+
|
|
125
|
+
teams = client.teams.list()
|
|
126
|
+
primary_team = get_primary_team(teams)
|
|
127
|
+
|
|
128
|
+
if primary_team and can_manage_team(primary_team, signup.user.user_id):
|
|
129
|
+
client.teams.update(primary_team.id, default_sla_minutes=30)
|
|
130
|
+
members = client.teams.members.list(primary_team.id)
|
|
131
|
+
if members and can_manage_members(members[0]):
|
|
132
|
+
client.teams.notify_test(primary_team.id)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
async def async_example() -> None:
|
|
136
|
+
async_client = AsyncBlocklogClient(base_url="https://your-blocklog-host/api/v1")
|
|
137
|
+
login = await async_client.auth.login("jane@example.com", "ChangeMe123!")
|
|
138
|
+
async_client.set_access_token(login.token)
|
|
139
|
+
teams = await async_client.teams.list()
|
|
140
|
+
print(teams)
|
|
141
|
+
```
|
|
142
|
+
|
|
131
143
|
---
|
|
132
144
|
|
|
133
145
|
## What Happens Under The Hood?
|
|
@@ -162,6 +174,7 @@ Blocklog seamlessly auto-instruments popular AI frameworks:
|
|
|
162
174
|
- **LangChain**: Trace chains, LLMs, and tools automatically via `client.instrument_langchain()`.
|
|
163
175
|
- **LangGraph**: Hook into graph states via `client.instrument_langgraph()`.
|
|
164
176
|
- **OpenAI Agents**: Track official SDK executions via `client.instrument_openai_agents()`.
|
|
177
|
+
- **LiteLLM**: Instrument any LiteLLM completion call via `client.instrument_litellm()`.
|
|
165
178
|
|
|
166
179
|
Read more in the [Integrations Guide](docs/integrations.md).
|
|
167
180
|
|
|
@@ -173,7 +186,7 @@ Read more in the [Integrations Guide](docs/integrations.md).
|
|
|
173
186
|
|-------|-------|
|
|
174
187
|
| **Getting Started** | [Installation](docs/installation.md) • [Quickstart](docs/quickstart.md) • [Core Concepts](docs/concepts.md) |
|
|
175
188
|
| **Instrumentation** | [Tracing](docs/tracing.md) • [Decisions](docs/decisions.md) • [Decorators](docs/decorators.md) |
|
|
176
|
-
| **Frameworks** | [Integrations](docs/integrations.md) |
|
|
189
|
+
| **Frameworks** | [Integrations](docs/integrations.md) — LangChain, LangGraph, OpenAI Agents, LiteLLM |
|
|
177
190
|
| **Operations** | [Async Usage](docs/async.md) • [Production](docs/production.md) • [Performance](docs/performance.md) |
|
|
178
191
|
| **Reference** | [API Reference](docs/api-reference.md) • [Error Handling](docs/error-handling.md) • [Troubleshooting](docs/troubleshooting.md) |
|
|
179
192
|
| **Misc** | [Examples](docs/examples.md) • [Changelog](docs/changelog.md) |
|
|
@@ -197,6 +210,8 @@ We provide several runnable scripts in the `examples/` directory to help you und
|
|
|
197
210
|
- **Retry Handling**: Built-in exponential backoff for transient network issues.
|
|
198
211
|
- **Signing**: Optional Ed25519 payload signing for tamper-evident, cryptographically verifiable logs.
|
|
199
212
|
- **Middleware Hooks**: Add custom logic to redact PII or inject metadata before payloads leave your server.
|
|
213
|
+
- **Typed Team APIs**: Ownership-aware models for teams, members, and signup responses.
|
|
214
|
+
- **Standardized Exceptions**: Authentication, authorization, validation, conflict, rate-limit, and server error mapping.
|
|
200
215
|
|
|
201
216
|
Read our [Production Best Practices](docs/production.md) for more details.
|
|
202
217
|
|
|
@@ -215,6 +230,7 @@ Blocklog can be configured via environment variables:
|
|
|
215
230
|
| Variable | Description | Default |
|
|
216
231
|
|----------|-------------|---------|
|
|
217
232
|
| `BLOCKLOG_API_KEY` | Your Blocklog API key | `""` |
|
|
233
|
+
| `BLOCKLOG_ACCESS_TOKEN` | User access token for dashboard-style APIs | `""` |
|
|
218
234
|
| `BLOCKLOG_BASE_URL` | API base URL | `http://127.0.0.1:8000/api/v1` |
|
|
219
235
|
| `BLOCKLOG_SDK_SIGNING_KEY` | Optional seed key for hash signing | `""` |
|
|
220
236
|
| `BLOCKLOG_TIMEOUT` | Request timeout in seconds | `10` |
|
|
@@ -257,6 +273,20 @@ If the SDK cannot connect to the Blocklog API:
|
|
|
257
273
|
3. Ensure network connectivity to the API server
|
|
258
274
|
4. Check firewall settings
|
|
259
275
|
|
|
276
|
+
## Teams API
|
|
277
|
+
|
|
278
|
+
```python
|
|
279
|
+
from blocklog import BlocklogClient
|
|
280
|
+
|
|
281
|
+
client = BlocklogClient(access_token="user-token")
|
|
282
|
+
|
|
283
|
+
teams = client.teams.list()
|
|
284
|
+
team = client.teams.get(teams[0].id)
|
|
285
|
+
members = client.teams.members.list(team.id)
|
|
286
|
+
result = client.teams.notify_test(team.id)
|
|
287
|
+
print(result.results)
|
|
288
|
+
```
|
|
289
|
+
|
|
260
290
|
## Links
|
|
261
291
|
|
|
262
292
|
- **Homepage**: https://blockloghq.com
|
|
@@ -269,4 +299,4 @@ If the SDK cannot connect to the Blocklog API:
|
|
|
269
299
|
|
|
270
300
|
## License
|
|
271
301
|
|
|
272
|
-
MIT License. See the LICENSE file for details.
|
|
302
|
+
MIT License. See the LICENSE file for details.
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
```markdown
|
|
1
2
|
# API Reference
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
## Environment Variables
|
|
5
|
+
|
|
6
|
+
| Variable | Required | Default | Description |
|
|
7
|
+
|---|---|---|---|
|
|
8
|
+
| `BLOCKLOG_API_KEY` | Yes | — | Your Blocklog API key |
|
|
9
|
+
| `BLOCKLOG_BASE_URL` | No | `https://blocklogsecurity.com/api/v1` | API endpoint |
|
|
10
|
+
| `BLOCKLOG_SDK_SIGNING_KEY` | No | `""` | HMAC-SHA256 signing key |
|
|
11
|
+
| `BLOCKLOG_TIMEOUT` | No | `10` | Request timeout in seconds |
|
|
12
|
+
| `BLOCKLOG_MAX_RETRIES` | No | `3` | Retry attempts on failure |
|
|
13
|
+
| `BLOCKLOG_BATCH_SIZE` | No | `100` | Events per batch flush |
|
|
14
|
+
| `BLOCKLOG_FLUSH_INTERVAL` | No | `2` | Seconds between auto-flushes |
|
|
15
|
+
|
|
16
|
+
---
|
|
4
17
|
|
|
5
18
|
## Initialization
|
|
6
19
|
|
|
@@ -17,15 +30,17 @@ def init(
|
|
|
17
30
|
) -> "BlocklogClient"
|
|
18
31
|
```
|
|
19
32
|
**Purpose:** Initializes the Blocklog SDK. Call once at application startup.
|
|
33
|
+
|
|
20
34
|
**Parameters:**
|
|
21
35
|
- `api_key` (str, optional): Your Blocklog API key. Falls back to `BLOCKLOG_API_KEY`.
|
|
22
36
|
- `base_url` (str, optional): Override the default API base URL. Falls back to `BLOCKLOG_BASE_URL`.
|
|
23
|
-
- `signing_key` (str, optional):
|
|
37
|
+
- `signing_key` (str, optional): HMAC-SHA256 key for tamper-evident log signatures. Falls back to `BLOCKLOG_SDK_SIGNING_KEY`. Note: this is not asymmetric Ed25519 signing.
|
|
24
38
|
- `timeout` (float, optional): Per-request timeout in seconds (default: 10). Falls back to `BLOCKLOG_TIMEOUT`.
|
|
25
39
|
- `max_retries` (int, optional): Number of automatic retries (default: 3). Falls back to `BLOCKLOG_MAX_RETRIES`.
|
|
26
40
|
- `debug` (bool, optional): If `True`, logs every outbound request to stderr.
|
|
41
|
+
|
|
27
42
|
**Returns:** `BlocklogClient`
|
|
28
|
-
|
|
43
|
+
|
|
29
44
|
**Example:**
|
|
30
45
|
```python
|
|
31
46
|
client = blocklog.init(api_key="blk_live_...")
|
|
@@ -46,13 +61,18 @@ def agent(
|
|
|
46
61
|
metadata: dict[str, Any] | None = None,
|
|
47
62
|
)
|
|
48
63
|
```
|
|
49
|
-
**Purpose:**
|
|
64
|
+
**Purpose:** Traces an AI agent function, linking it to a Blocklog session. Automatically handles sync and async functions.
|
|
65
|
+
|
|
66
|
+
> **Warning:** Class decoration only emits `AGENT_START`. For full lifecycle tracing, decorate the specific method (e.g. `run`, `execute`) rather than the class itself.
|
|
67
|
+
|
|
50
68
|
**Parameters:**
|
|
51
|
-
- `name`: Human-readable agent name.
|
|
69
|
+
- `name`: Human-readable agent name. Defaults to `func.__name__`.
|
|
52
70
|
- `version`: Semver-style version string.
|
|
53
71
|
- `tags`: Optional list of string tags.
|
|
54
72
|
- `metadata`: Arbitrary extra data.
|
|
73
|
+
|
|
55
74
|
**Returns:** Decorated callable or class.
|
|
75
|
+
|
|
56
76
|
**Example:**
|
|
57
77
|
```python
|
|
58
78
|
@blocklog.agent(name="analyst", version="1.0")
|
|
@@ -60,6 +80,8 @@ def run_analyst():
|
|
|
60
80
|
pass
|
|
61
81
|
```
|
|
62
82
|
|
|
83
|
+
---
|
|
84
|
+
|
|
63
85
|
### `@blocklog.tool`
|
|
64
86
|
```python
|
|
65
87
|
def tool(
|
|
@@ -71,17 +93,20 @@ def tool(
|
|
|
71
93
|
metadata: dict[str, Any] | None = None,
|
|
72
94
|
)
|
|
73
95
|
```
|
|
74
|
-
**Purpose:**
|
|
96
|
+
**Purpose:** Records a tool call as a Blocklog event, capturing inputs, outputs, duration, and errors. Inherits trace context from the surrounding `@agent`.
|
|
97
|
+
|
|
75
98
|
**Parameters:**
|
|
76
|
-
- `name`: Human-readable tool name.
|
|
99
|
+
- `name`: Human-readable tool name. Defaults to `func.__name__`.
|
|
77
100
|
- `schema`: Optional dict describing the input schema.
|
|
78
101
|
- `tags`: Optional string tags.
|
|
79
102
|
- `metadata`: Arbitrary extra data.
|
|
103
|
+
|
|
80
104
|
**Returns:** Decorated callable.
|
|
105
|
+
|
|
81
106
|
**Example:**
|
|
82
107
|
```python
|
|
83
108
|
@blocklog.tool(name="fetch-price")
|
|
84
|
-
def get_price(ticker: str):
|
|
109
|
+
def get_price(ticker: str) -> float:
|
|
85
110
|
return 100.0
|
|
86
111
|
```
|
|
87
112
|
|
|
@@ -101,56 +126,63 @@ def decision(
|
|
|
101
126
|
trace_id: str | None = None,
|
|
102
127
|
) -> Generator[DecisionContext, None, None]
|
|
103
128
|
```
|
|
104
|
-
**Purpose:** Context manager for recording an AI decision.
|
|
129
|
+
**Purpose:** Context manager for recording an AI decision.
|
|
130
|
+
|
|
105
131
|
**Parameters:**
|
|
106
|
-
- `type` (str): Decision type identifier (e.g. "BUY").
|
|
132
|
+
- `type` (str): Decision type identifier (e.g. `"BUY"`).
|
|
107
133
|
- `asset` (str, optional): Asset this decision is about.
|
|
108
134
|
- `confidence` (float, optional): Model confidence score (0 to 1).
|
|
109
135
|
- `metadata` (dict, optional): Extra fields.
|
|
136
|
+
|
|
110
137
|
**Returns:** Yields `DecisionContext`.
|
|
138
|
+
|
|
111
139
|
**Example:**
|
|
112
140
|
```python
|
|
113
141
|
with blocklog.decision(type="BUY", asset="TSLA") as d:
|
|
142
|
+
d.record_input(price=412.50)
|
|
114
143
|
d.record_output(status="executed")
|
|
115
144
|
```
|
|
116
145
|
|
|
117
146
|
### `DecisionContext`
|
|
118
147
|
Live handle to a decision being recorded.
|
|
148
|
+
|
|
119
149
|
- **`record_input(**kwargs)`**: Record structured inputs. Returns `self`.
|
|
120
150
|
- **`record_output(**kwargs)`**: Record structured outputs. Returns `self`.
|
|
121
151
|
- **`tag(*tags)`**: Attach string labels. Returns `self`.
|
|
122
|
-
- **`request_approval(reason
|
|
123
|
-
- **`verify() -> dict`**:
|
|
152
|
+
- **`request_approval(reason, reviewer=None)`**: Non-blocking request for human approval. Returns `self`.
|
|
153
|
+
- **`verify() -> dict`**: Verify the decision after the `with` block has exited. Raises `RuntimeError` if called before the decision is committed.
|
|
124
154
|
|
|
125
155
|
---
|
|
126
156
|
|
|
127
157
|
## Clients
|
|
128
158
|
|
|
129
159
|
### `BlocklogClient`
|
|
130
|
-
**Purpose:**
|
|
160
|
+
**Purpose:** Synchronous core client. Usually instantiated via `blocklog.init()`.
|
|
131
161
|
|
|
132
162
|
**Methods:**
|
|
133
|
-
- `from_env() -> BlocklogClient`:
|
|
134
|
-
- `add_hook(hook: Callable) -> BlocklogClient`: Register a middleware hook.
|
|
135
|
-
- `instrument_openai_agents() -> BlocklogClient
|
|
136
|
-
- `instrument_langchain() -> BlocklogClient
|
|
137
|
-
- `instrument_langgraph() -> BlocklogClient
|
|
138
|
-
- `event(event_type
|
|
139
|
-
- `enqueue(event_type
|
|
140
|
-
- `flush(batch=None)`: Flush event buffer.
|
|
163
|
+
- `from_env() -> BlocklogClient`: Create a client from environment variables.
|
|
164
|
+
- `add_hook(hook: Callable) -> BlocklogClient`: Register a middleware hook applied to every outbound event.
|
|
165
|
+
- `instrument_openai_agents() -> BlocklogClient`: Auto-instrument the OpenAI Agents SDK.
|
|
166
|
+
- `instrument_langchain() -> BlocklogClient`: Auto-instrument LangChain.
|
|
167
|
+
- `instrument_langgraph() -> BlocklogClient`: Auto-instrument LangGraph.
|
|
168
|
+
- `event(event_type, payload, **kwargs) -> IngestResponse`: Emit a single event immediately.
|
|
169
|
+
- `enqueue(event_type, payload, **kwargs)`: Enqueue an event for batched delivery.
|
|
170
|
+
- `flush(batch=None)`: Flush the event buffer.
|
|
141
171
|
|
|
142
172
|
### `AsyncBlocklogClient`
|
|
143
|
-
**Purpose:**
|
|
144
|
-
|
|
145
|
-
|
|
173
|
+
**Purpose:** Async client for use in async applications.
|
|
174
|
+
|
|
175
|
+
**Methods:** Same as `BlocklogClient` with async overrides:
|
|
176
|
+
- `async event(event_type, payload, **kwargs) -> IngestResponse`
|
|
146
177
|
- `async flush(batch=None)`
|
|
147
178
|
|
|
148
179
|
### `BlocklogConfig`
|
|
149
180
|
**Purpose:** Configuration Pydantic model.
|
|
181
|
+
|
|
150
182
|
**Fields:**
|
|
151
183
|
- `base_url`: str
|
|
152
184
|
- `api_key`: str
|
|
153
|
-
- `signing_key`: str
|
|
185
|
+
- `signing_key`: str — HMAC-SHA256 key, not Ed25519
|
|
154
186
|
- `timeout`: float
|
|
155
187
|
- `max_retries`: int
|
|
156
188
|
- `batch_size`: int
|
|
@@ -160,47 +192,47 @@ Live handle to a decision being recorded.
|
|
|
160
192
|
|
|
161
193
|
## Layer 2 Sub-modules
|
|
162
194
|
|
|
163
|
-
*
|
|
195
|
+
*Available via `client.module.method()` or imported directly from `blocklog.api.*`.*
|
|
164
196
|
|
|
165
|
-
### `blocklog.api.decisions
|
|
166
|
-
**Purpose:** Manage AI Decision records natively.
|
|
197
|
+
### `blocklog.api.decisions`
|
|
167
198
|
- `create(decision_type, asset, confidence, metadata, trace_id, session_id, agent_id) -> dict`
|
|
168
199
|
- `list() -> list[dict]`
|
|
169
|
-
- `get(decision_id
|
|
170
|
-
- `verify(decision_id
|
|
171
|
-
- `timeline(decision_id
|
|
172
|
-
- `evidence(decision_id
|
|
173
|
-
- `replay(decision_id
|
|
200
|
+
- `get(decision_id) -> dict`
|
|
201
|
+
- `verify(decision_id) -> dict`
|
|
202
|
+
- `timeline(decision_id) -> list[dict]`
|
|
203
|
+
- `evidence(decision_id) -> dict`
|
|
204
|
+
- `replay(decision_id) -> dict`
|
|
174
205
|
|
|
175
206
|
### `blocklog.approval`
|
|
176
|
-
|
|
207
|
+
Human-in-the-loop workflows.
|
|
177
208
|
- `request(decision_id, reason, reviewer, log_id, metadata) -> dict`
|
|
178
209
|
- `reject(reviewer, reason, decision_id) -> dict`
|
|
179
210
|
- `escalate(from_reviewer, to_reviewer, reason) -> dict`
|
|
180
211
|
- `list_overrides() -> list[dict]`
|
|
181
212
|
- `audit_trail() -> list[dict]`
|
|
182
213
|
|
|
183
|
-
### `blocklog.
|
|
184
|
-
|
|
214
|
+
### `blocklog.api.incidents`
|
|
215
|
+
Incident management. Not exported from the top-level `blocklog` namespace — import via `from blocklog.api.incidents import IncidentsClient` or access via `client.incidents`.
|
|
185
216
|
- `create(title, trace_id, severity, description, metadata) -> IncidentHandle`
|
|
186
217
|
- `get(incident_id) -> IncidentHandle`
|
|
187
218
|
- `list_all() -> list[IncidentHandle]`
|
|
188
219
|
|
|
189
220
|
### `blocklog.replay`
|
|
190
|
-
|
|
221
|
+
Forensic replay sessions.
|
|
191
222
|
- `replay(trace_id, token_id, metadata) -> ReplaySession`
|
|
192
223
|
|
|
193
|
-
### `blocklog.verify`
|
|
194
|
-
|
|
195
|
-
- `log(log_id
|
|
196
|
-
- `batch(batch_id
|
|
197
|
-
- `decision(decision_id
|
|
224
|
+
### `blocklog.api.verify`
|
|
225
|
+
Access via `client.verify` to avoid naming conflict with `DecisionContext.verify()`.
|
|
226
|
+
- `log(log_id) -> dict`
|
|
227
|
+
- `batch(batch_id) -> dict`
|
|
228
|
+
- `decision(decision_id) -> dict`
|
|
198
229
|
|
|
199
230
|
### `blocklog.compliance`
|
|
200
|
-
|
|
231
|
+
Compliance report generation.
|
|
201
232
|
- `generate(trace_id, framework, date_from, date_to, metadata) -> dict`
|
|
202
233
|
- `get(report_id) -> dict`
|
|
203
234
|
- `list() -> list[dict]`
|
|
204
235
|
- `dashboard() -> dict`
|
|
205
236
|
- `share(report_id, expires_in, recipient_email) -> dict`
|
|
206
237
|
- `export(report_id, download) -> dict`
|
|
238
|
+
```
|
|
@@ -26,7 +26,6 @@ Done. Check your Blocklog dashboard.
|
|
|
26
26
|
A detailed execution trace printed to the terminal of the `stock-trader` agent checking the market price and placing an order. A decision record is produced and verified:
|
|
27
27
|
```
|
|
28
28
|
✓ Decision recorded: <uuid>
|
|
29
|
-
Verifying decision against blockchain anchor...
|
|
30
29
|
✓ Verification status: verified
|
|
31
30
|
```
|
|
32
31
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
**Infrastructure for AI Decision-Making**
|
|
4
4
|
|
|
5
|
-
Blocklog provides the infrastructure to record, audit, and investigate AI decisions. It allows you to wrap your AI agents, capture their context and tool calls, and record structured decisions that are
|
|
5
|
+
Blocklog provides the infrastructure to record, audit, and investigate AI decisions. It allows you to wrap your AI agents, capture their context and tool calls, and record structured decisions that are cryptographically signed and verifiable.
|
|
6
6
|
|
|
7
7
|
## What problem it solves
|
|
8
8
|
|
|
@@ -11,7 +11,7 @@ When AI agents make decisions in production—like executing a trade, granting a
|
|
|
11
11
|
Blocklog solves this by:
|
|
12
12
|
1. **Tracing AI Agents**: Capturing the exact state, tool inputs/outputs, and prompts.
|
|
13
13
|
2. **Recording Decisions**: Creating a structured, auditable record of AI actions.
|
|
14
|
-
3. **Providing Verifiability**:
|
|
14
|
+
3. **Providing Verifiability**: Signing decisions cryptographically with Ed25519.
|
|
15
15
|
4. **Enabling Human-in-the-Loop (HITL)**: Requesting approvals for high-stakes decisions seamlessly.
|
|
16
16
|
|
|
17
17
|
## Documentation Index
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Requirements
|
|
4
|
+
|
|
5
|
+
Python 3.10 or newer.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install blocklog
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Verify
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
import blocklog
|
|
17
|
+
print(blocklog.__version__) # 0.2.2
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Development
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/Blockloghq/blocklog-python.git
|
|
24
|
+
cd blocklog-python
|
|
25
|
+
pip install -e ".[dev]"
|
|
26
|
+
```
|