blocklog 0.2.2__tar.gz → 0.2.5__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 (100) hide show
  1. {blocklog-0.2.2 → blocklog-0.2.5}/PKG-INFO +92 -9
  2. blocklog-0.2.2/src/blocklog.egg-info/PKG-INFO → blocklog-0.2.5/README.md +70 -41
  3. {blocklog-0.2.2 → blocklog-0.2.5}/docs/api-reference.md +75 -43
  4. {blocklog-0.2.2 → blocklog-0.2.5}/docs/examples.md +0 -1
  5. {blocklog-0.2.2 → blocklog-0.2.5}/docs/index.md +2 -2
  6. blocklog-0.2.5/docs/installation.md +26 -0
  7. blocklog-0.2.5/docs/integrations.md +208 -0
  8. {blocklog-0.2.2 → blocklog-0.2.5}/docs/troubleshooting.md +1 -1
  9. {blocklog-0.2.2 → blocklog-0.2.5}/examples/02_stock_trading_agent.py +1 -2
  10. blocklog-0.2.5/examples/04_team_management.py +38 -0
  11. {blocklog-0.2.2 → blocklog-0.2.5}/pyproject.toml +20 -6
  12. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/__init__.py +38 -2
  13. blocklog-0.2.5/src/blocklog/_init_fn.py +185 -0
  14. blocklog-0.2.5/src/blocklog/api/auth.py +143 -0
  15. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/decisions.py +58 -43
  16. blocklog-0.2.5/src/blocklog/api/teams.py +197 -0
  17. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/verify.py +9 -9
  18. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/async_client.py +11 -5
  19. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/client.py +32 -14
  20. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/config.py +3 -1
  21. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/decorators/agent.py +10 -3
  22. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/decorators/tool.py +9 -3
  23. blocklog-0.2.5/src/blocklog/exceptions.py +70 -0
  24. blocklog-0.2.5/src/blocklog/integrations/langchain.py +189 -0
  25. blocklog-0.2.5/src/blocklog/integrations/langgraph.py +560 -0
  26. blocklog-0.2.5/src/blocklog/integrations/litellm.py +361 -0
  27. blocklog-0.2.5/src/blocklog/integrations/openai_agents.py +374 -0
  28. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/managers/decision.py +138 -10
  29. blocklog-0.2.5/src/blocklog/models/auth.py +35 -0
  30. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/models/events.py +2 -2
  31. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/models/responses.py +2 -2
  32. blocklog-0.2.5/src/blocklog/models/teams.py +101 -0
  33. blocklog-0.2.5/src/blocklog/team_utils.py +21 -0
  34. blocklog-0.2.5/src/blocklog/transport/auth.py +18 -0
  35. blocklog-0.2.5/src/blocklog/transport/httpx_async.py +82 -0
  36. blocklog-0.2.5/src/blocklog/transport/httpx_sync.py +79 -0
  37. blocklog-0.2.5/src/blocklog/transport/retry.py +51 -0
  38. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/verify.py +7 -7
  39. blocklog-0.2.2/README.md → blocklog-0.2.5/src/blocklog.egg-info/PKG-INFO +123 -4
  40. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog.egg-info/SOURCES.txt +9 -0
  41. blocklog-0.2.5/src/blocklog.egg-info/requires.txt +34 -0
  42. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_client.py +28 -7
  43. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_config.py +11 -9
  44. blocklog-0.2.5/tests/test_errors_and_health.py +227 -0
  45. blocklog-0.2.2/docs/installation.md +0 -36
  46. blocklog-0.2.2/docs/integrations.md +0 -45
  47. blocklog-0.2.2/src/blocklog/_init_fn.py +0 -95
  48. blocklog-0.2.2/src/blocklog/integrations/langchain.py +0 -129
  49. blocklog-0.2.2/src/blocklog/integrations/langgraph.py +0 -3
  50. blocklog-0.2.2/src/blocklog/integrations/openai_agents.py +0 -3
  51. blocklog-0.2.2/src/blocklog/transport/auth.py +0 -8
  52. blocklog-0.2.2/src/blocklog/transport/httpx_async.py +0 -39
  53. blocklog-0.2.2/src/blocklog/transport/httpx_sync.py +0 -36
  54. blocklog-0.2.2/src/blocklog/transport/retry.py +0 -26
  55. blocklog-0.2.2/src/blocklog.egg-info/requires.txt +0 -11
  56. {blocklog-0.2.2 → blocklog-0.2.5}/LICENSE +0 -0
  57. {blocklog-0.2.2 → blocklog-0.2.5}/MANIFEST.in +0 -0
  58. {blocklog-0.2.2 → blocklog-0.2.5}/docs/async.md +0 -0
  59. {blocklog-0.2.2 → blocklog-0.2.5}/docs/changelog.md +0 -0
  60. {blocklog-0.2.2 → blocklog-0.2.5}/docs/concepts.md +0 -0
  61. {blocklog-0.2.2 → blocklog-0.2.5}/docs/configuration.md +0 -0
  62. {blocklog-0.2.2 → blocklog-0.2.5}/docs/decisions.md +0 -0
  63. {blocklog-0.2.2 → blocklog-0.2.5}/docs/decorators.md +0 -0
  64. {blocklog-0.2.2 → blocklog-0.2.5}/docs/error-handling.md +0 -0
  65. {blocklog-0.2.2 → blocklog-0.2.5}/docs/migration.md +0 -0
  66. {blocklog-0.2.2 → blocklog-0.2.5}/docs/performance.md +0 -0
  67. {blocklog-0.2.2 → blocklog-0.2.5}/docs/production.md +0 -0
  68. {blocklog-0.2.2 → blocklog-0.2.5}/docs/quickstart.md +0 -0
  69. {blocklog-0.2.2 → blocklog-0.2.5}/docs/tracing.md +0 -0
  70. {blocklog-0.2.2 → blocklog-0.2.5}/examples/01_quickstart.py +0 -0
  71. {blocklog-0.2.2 → blocklog-0.2.5}/examples/03_multi_agent_workflow.py +0 -0
  72. {blocklog-0.2.2 → blocklog-0.2.5}/examples/advanced/01_human_approval_workflow.py +0 -0
  73. {blocklog-0.2.2 → blocklog-0.2.5}/examples/advanced/02_incident_investigation.py +0 -0
  74. {blocklog-0.2.2 → blocklog-0.2.5}/examples/advanced/03_decision_comparison.py +0 -0
  75. {blocklog-0.2.2 → blocklog-0.2.5}/examples/advanced/langchain_alert_demo.py +0 -0
  76. {blocklog-0.2.2 → blocklog-0.2.5}/setup.cfg +0 -0
  77. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/_global.py +0 -0
  78. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/approval.py +0 -0
  79. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/compliance.py +0 -0
  80. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/incidents.py +0 -0
  81. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/replay.py +0 -0
  82. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/api/traces.py +0 -0
  83. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/approval.py +0 -0
  84. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/batching/buffer.py +0 -0
  85. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/compliance.py +0 -0
  86. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/context/managers.py +0 -0
  87. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/context/vars.py +0 -0
  88. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/decorators/__init__.py +0 -0
  89. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/incident.py +0 -0
  90. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/managers/__init__.py +0 -0
  91. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/middleware/hooks.py +0 -0
  92. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/replay.py +0 -0
  93. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/signing/canonical.py +0 -0
  94. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog/signing/ed25519.py +0 -0
  95. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog.egg-info/dependency_links.txt +0 -0
  96. {blocklog-0.2.2 → blocklog-0.2.5}/src/blocklog.egg-info/top_level.txt +0 -0
  97. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_context.py +0 -0
  98. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_decorators.py +0 -0
  99. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_public_api.py +0 -0
  100. {blocklog-0.2.2 → blocklog-0.2.5}/tests/test_transport.py +0 -0
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: blocklog
3
- Version: 0.2.2
3
+ Version: 0.2.5
4
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>
5
+ Author-email: Blocklog <founder@blocklogsecurity.com>
6
+ Maintainer-email: Blocklog <founder@blocklogsecurity.com>
7
7
  License: MIT
8
- Project-URL: Homepage, https://blockloghq.com
9
- Project-URL: Documentation, https://docs.blockloghq.com
8
+ Project-URL: Homepage, https://blocklogsecurity.com
9
+ Project-URL: Documentation, https://blocklogsecurity.com/docs
10
10
  Project-URL: Repository, https://github.com/blockloghq/blocklog-python
11
11
  Project-URL: Issues, https://github.com/blockloghq/blocklog-python/issues
12
12
  Keywords: ai,agents,observability,governance,security,audit,replay
@@ -27,11 +27,29 @@ Requires-Dist: httpx<1.0,>=0.27
27
27
  Requires-Dist: pydantic<3.0,>=2.8
28
28
  Provides-Extra: requests
29
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"
30
44
  Provides-Extra: dev
31
45
  Requires-Dist: pytest>=8.0.0; extra == "dev"
32
46
  Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
33
47
  Requires-Dist: build>=1.0.0; extra == "dev"
34
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"
35
53
  Dynamic: license-file
36
54
 
37
55
  # Blocklog Python SDK
@@ -57,7 +75,7 @@ When AI agents execute actions in production, the context behind their decisions
57
75
  - **Trace tool calls**, capturing inputs and outputs seamlessly.
58
76
  - **Record decisions** with detailed metadata, inputs, and outputs.
59
77
  - **Request approvals** via non-blocking human-in-the-loop workflows.
60
- - **Verify records** cryptographically against a blockchain anchor.
78
+ - **Verify records** cryptographically against Ed25519 signatures.
61
79
  - **Generate compliance evidence** (e.g., SOC2, GDPR).
62
80
  - **Investigate failures with replay** using forensic timelines and root-cause analysis.
63
81
 
@@ -129,6 +147,53 @@ if __name__ == "__main__":
129
147
  run_agent()
130
148
  ```
131
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
+
132
197
  ---
133
198
 
134
199
  ## What Happens Under The Hood?
@@ -163,6 +228,7 @@ Blocklog seamlessly auto-instruments popular AI frameworks:
163
228
  - **LangChain**: Trace chains, LLMs, and tools automatically via `client.instrument_langchain()`.
164
229
  - **LangGraph**: Hook into graph states via `client.instrument_langgraph()`.
165
230
  - **OpenAI Agents**: Track official SDK executions via `client.instrument_openai_agents()`.
231
+ - **LiteLLM**: Instrument any LiteLLM completion call via `client.instrument_litellm()`.
166
232
 
167
233
  Read more in the [Integrations Guide](docs/integrations.md).
168
234
 
@@ -174,7 +240,7 @@ Read more in the [Integrations Guide](docs/integrations.md).
174
240
  |-------|-------|
175
241
  | **Getting Started** | [Installation](docs/installation.md) • [Quickstart](docs/quickstart.md) • [Core Concepts](docs/concepts.md) |
176
242
  | **Instrumentation** | [Tracing](docs/tracing.md) • [Decisions](docs/decisions.md) • [Decorators](docs/decorators.md) |
177
- | **Frameworks** | [Integrations](docs/integrations.md) |
243
+ | **Frameworks** | [Integrations](docs/integrations.md) — LangChain, LangGraph, OpenAI Agents, LiteLLM |
178
244
  | **Operations** | [Async Usage](docs/async.md) • [Production](docs/production.md) • [Performance](docs/performance.md) |
179
245
  | **Reference** | [API Reference](docs/api-reference.md) • [Error Handling](docs/error-handling.md) • [Troubleshooting](docs/troubleshooting.md) |
180
246
  | **Misc** | [Examples](docs/examples.md) • [Changelog](docs/changelog.md) |
@@ -198,6 +264,8 @@ We provide several runnable scripts in the `examples/` directory to help you und
198
264
  - **Retry Handling**: Built-in exponential backoff for transient network issues.
199
265
  - **Signing**: Optional Ed25519 payload signing for tamper-evident, cryptographically verifiable logs.
200
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.
201
269
 
202
270
  Read our [Production Best Practices](docs/production.md) for more details.
203
271
 
@@ -216,6 +284,7 @@ Blocklog can be configured via environment variables:
216
284
  | Variable | Description | Default |
217
285
  |----------|-------------|---------|
218
286
  | `BLOCKLOG_API_KEY` | Your Blocklog API key | `""` |
287
+ | `BLOCKLOG_ACCESS_TOKEN` | User access token for dashboard-style APIs | `""` |
219
288
  | `BLOCKLOG_BASE_URL` | API base URL | `http://127.0.0.1:8000/api/v1` |
220
289
  | `BLOCKLOG_SDK_SIGNING_KEY` | Optional seed key for hash signing | `""` |
221
290
  | `BLOCKLOG_TIMEOUT` | Request timeout in seconds | `10` |
@@ -258,10 +327,24 @@ If the SDK cannot connect to the Blocklog API:
258
327
  3. Ensure network connectivity to the API server
259
328
  4. Check firewall settings
260
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
+
261
344
  ## Links
262
345
 
263
- - **Homepage**: https://blockloghq.com
264
- - **Documentation**: https://docs.blockloghq.com
346
+ - **Homepage**: https://blocklogsecurity.com
347
+ - **Documentation**: https://blocklogsecurity.com/docs
265
348
  - **Repository**: https://github.com/blockloghq/blocklog-python
266
349
  - **Issues**: https://github.com/blockloghq/blocklog-python/issues
267
350
  - **PyPI**: https://pypi.org/project/blocklog/
@@ -1,39 +1,3 @@
1
- Metadata-Version: 2.4
2
- Name: blocklog
3
- Version: 0.2.2
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
- Provides-Extra: requests
29
- Requires-Dist: requests>=2.32.0; extra == "requests"
30
- Provides-Extra: dev
31
- Requires-Dist: pytest>=8.0.0; extra == "dev"
32
- Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
33
- Requires-Dist: build>=1.0.0; extra == "dev"
34
- Requires-Dist: twine>=5.0.0; extra == "dev"
35
- Dynamic: license-file
36
-
37
1
  # Blocklog Python SDK
38
2
 
39
3
  **Record, audit, and investigate every decision your AI agents make.**
@@ -57,7 +21,7 @@ When AI agents execute actions in production, the context behind their decisions
57
21
  - **Trace tool calls**, capturing inputs and outputs seamlessly.
58
22
  - **Record decisions** with detailed metadata, inputs, and outputs.
59
23
  - **Request approvals** via non-blocking human-in-the-loop workflows.
60
- - **Verify records** cryptographically against a blockchain anchor.
24
+ - **Verify records** cryptographically against Ed25519 signatures.
61
25
  - **Generate compliance evidence** (e.g., SOC2, GDPR).
62
26
  - **Investigate failures with replay** using forensic timelines and root-cause analysis.
63
27
 
@@ -129,6 +93,53 @@ if __name__ == "__main__":
129
93
  run_agent()
130
94
  ```
131
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
+
132
143
  ---
133
144
 
134
145
  ## What Happens Under The Hood?
@@ -163,6 +174,7 @@ Blocklog seamlessly auto-instruments popular AI frameworks:
163
174
  - **LangChain**: Trace chains, LLMs, and tools automatically via `client.instrument_langchain()`.
164
175
  - **LangGraph**: Hook into graph states via `client.instrument_langgraph()`.
165
176
  - **OpenAI Agents**: Track official SDK executions via `client.instrument_openai_agents()`.
177
+ - **LiteLLM**: Instrument any LiteLLM completion call via `client.instrument_litellm()`.
166
178
 
167
179
  Read more in the [Integrations Guide](docs/integrations.md).
168
180
 
@@ -174,7 +186,7 @@ Read more in the [Integrations Guide](docs/integrations.md).
174
186
  |-------|-------|
175
187
  | **Getting Started** | [Installation](docs/installation.md) • [Quickstart](docs/quickstart.md) • [Core Concepts](docs/concepts.md) |
176
188
  | **Instrumentation** | [Tracing](docs/tracing.md) • [Decisions](docs/decisions.md) • [Decorators](docs/decorators.md) |
177
- | **Frameworks** | [Integrations](docs/integrations.md) |
189
+ | **Frameworks** | [Integrations](docs/integrations.md) — LangChain, LangGraph, OpenAI Agents, LiteLLM |
178
190
  | **Operations** | [Async Usage](docs/async.md) • [Production](docs/production.md) • [Performance](docs/performance.md) |
179
191
  | **Reference** | [API Reference](docs/api-reference.md) • [Error Handling](docs/error-handling.md) • [Troubleshooting](docs/troubleshooting.md) |
180
192
  | **Misc** | [Examples](docs/examples.md) • [Changelog](docs/changelog.md) |
@@ -198,6 +210,8 @@ We provide several runnable scripts in the `examples/` directory to help you und
198
210
  - **Retry Handling**: Built-in exponential backoff for transient network issues.
199
211
  - **Signing**: Optional Ed25519 payload signing for tamper-evident, cryptographically verifiable logs.
200
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.
201
215
 
202
216
  Read our [Production Best Practices](docs/production.md) for more details.
203
217
 
@@ -216,6 +230,7 @@ Blocklog can be configured via environment variables:
216
230
  | Variable | Description | Default |
217
231
  |----------|-------------|---------|
218
232
  | `BLOCKLOG_API_KEY` | Your Blocklog API key | `""` |
233
+ | `BLOCKLOG_ACCESS_TOKEN` | User access token for dashboard-style APIs | `""` |
219
234
  | `BLOCKLOG_BASE_URL` | API base URL | `http://127.0.0.1:8000/api/v1` |
220
235
  | `BLOCKLOG_SDK_SIGNING_KEY` | Optional seed key for hash signing | `""` |
221
236
  | `BLOCKLOG_TIMEOUT` | Request timeout in seconds | `10` |
@@ -258,10 +273,24 @@ If the SDK cannot connect to the Blocklog API:
258
273
  3. Ensure network connectivity to the API server
259
274
  4. Check firewall settings
260
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
+
261
290
  ## Links
262
291
 
263
- - **Homepage**: https://blockloghq.com
264
- - **Documentation**: https://docs.blockloghq.com
292
+ - **Homepage**: https://blocklogsecurity.com
293
+ - **Documentation**: https://blocklogsecurity.com/docs
265
294
  - **Repository**: https://github.com/blockloghq/blocklog-python
266
295
  - **Issues**: https://github.com/blockloghq/blocklog-python/issues
267
296
  - **PyPI**: https://pypi.org/project/blocklog/
@@ -270,4 +299,4 @@ If the SDK cannot connect to the Blocklog API:
270
299
 
271
300
  ## License
272
301
 
273
- 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
- This document provides a comprehensive API reference derived from the Blocklog SDK source code. It covers all public modules, method signatures, parameters, return types, exceptions, and usage examples.
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): Optional seed key for deterministic hash signing of log payloads. Falls back to `BLOCKLOG_SDK_SIGNING_KEY`. Note: This is NOT cryptographic Ed25519 signing - it generates a deterministic SHA256 hash for tamper-evidence purposes.
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
- **Exceptions:** None directly, though misconfigurations may cause failures later.
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:** Decorator that traces an AI agent function or class, linking it to a Blocklog session. Automatically handles async functions.
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:** Decorator that records a tool call as a Blocklog event, tracking inputs, outputs, and duration. Inherits the trace from `@agent`. Handles async functions automatically.
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. Yields a `DecisionContext`.
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: str, reviewer: str | None = None)`**: Non-blocking request for human approval. Returns `self`.
123
- - **`verify() -> dict`**: Immediately verify the decision. Raises `RuntimeError` if called before the decision is committed (i.e. before the `with` block begins).
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:** The synchronous core client. Usually instantiated via `blocklog.init()`.
160
+ **Purpose:** Synchronous core client. Usually instantiated via `blocklog.init()`.
131
161
 
132
162
  **Methods:**
133
- - `from_env() -> BlocklogClient`: Class method to create a client solely from env vars.
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: str, payload: dict, **kwargs) -> IngestResponse`: Emit synchronous event.
139
- - `enqueue(event_type: str, payload: dict, **kwargs)`: Enqueue batched event.
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:** The asynchronous client for manual async flushing and event dispatch.
144
- **Methods:** Inherits from `BlocklogClient` but overrides network calls to be async:
145
- - `async event(event_type: str, payload: dict, **kwargs) -> IngestResponse`
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 (seed key for hash-based signing, NOT Ed25519)
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
- *(Available via `blocklog.module.*` or `client.module.*`)*
195
+ *Available via `client.module.method()` or imported directly from `blocklog.api.*`.*
164
196
 
165
- ### `blocklog.api.decisions.DecisionsClient`
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: str) -> dict`
170
- - `verify(decision_id: str) -> dict`
171
- - `timeline(decision_id: str) -> list[dict]`
172
- - `evidence(decision_id: str) -> dict`
173
- - `replay(decision_id: str) -> dict`
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
- **Purpose:** Human-in-the-loop (HITL) workflows.
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.incident`
184
- **Purpose:** Incident management API.
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
- **Purpose:** Forensic replays.
221
+ Forensic replay sessions.
191
222
  - `replay(trace_id, token_id, metadata) -> ReplaySession`
192
223
 
193
- ### `blocklog.verify`
194
- **Purpose:** Cryptographic verification against blockchain anchors.
195
- - `log(log_id: str) -> dict`
196
- - `batch(batch_id: str) -> dict`
197
- - `decision(decision_id: str) -> dict`
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
- **Purpose:** Compliance report generation.
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 securely anchored and verifiable.
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**: Anchoring decisions cryptographically.
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
+ ```