oneclaw 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- oneclaw-0.1.0/.github/workflows/ci.yml +54 -0
- oneclaw-0.1.0/.gitignore +17 -0
- oneclaw-0.1.0/LICENSE +21 -0
- oneclaw-0.1.0/PKG-INFO +289 -0
- oneclaw-0.1.0/README.md +255 -0
- oneclaw-0.1.0/pyproject.toml +67 -0
- oneclaw-0.1.0/src/oneclaw/__init__.py +33 -0
- oneclaw-0.1.0/src/oneclaw/client.py +148 -0
- oneclaw-0.1.0/src/oneclaw/errors.py +124 -0
- oneclaw-0.1.0/src/oneclaw/http_client.py +242 -0
- oneclaw-0.1.0/src/oneclaw/py.typed +0 -0
- oneclaw-0.1.0/src/oneclaw/resources/__init__.py +41 -0
- oneclaw-0.1.0/src/oneclaw/resources/agents.py +236 -0
- oneclaw-0.1.0/src/oneclaw/resources/api_keys.py +39 -0
- oneclaw-0.1.0/src/oneclaw/resources/approvals.py +55 -0
- oneclaw-0.1.0/src/oneclaw/resources/audit.py +37 -0
- oneclaw-0.1.0/src/oneclaw/resources/auth.py +199 -0
- oneclaw-0.1.0/src/oneclaw/resources/billing.py +66 -0
- oneclaw-0.1.0/src/oneclaw/resources/chains.py +24 -0
- oneclaw-0.1.0/src/oneclaw/resources/org.py +63 -0
- oneclaw-0.1.0/src/oneclaw/resources/platform.py +170 -0
- oneclaw-0.1.0/src/oneclaw/resources/policies.py +68 -0
- oneclaw-0.1.0/src/oneclaw/resources/risk.py +61 -0
- oneclaw-0.1.0/src/oneclaw/resources/secrets.py +96 -0
- oneclaw-0.1.0/src/oneclaw/resources/sharing.py +77 -0
- oneclaw-0.1.0/src/oneclaw/resources/signing_keys.py +46 -0
- oneclaw-0.1.0/src/oneclaw/resources/treasury.py +143 -0
- oneclaw-0.1.0/src/oneclaw/resources/treasury_wallets.py +99 -0
- oneclaw-0.1.0/src/oneclaw/resources/vaults.py +85 -0
- oneclaw-0.1.0/src/oneclaw/resources/webhooks.py +47 -0
- oneclaw-0.1.0/src/oneclaw/types.py +759 -0
- oneclaw-0.1.0/tests/__init__.py +0 -0
- oneclaw-0.1.0/tests/test_client.py +217 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
tags: ["v*"]
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
- uses: actions/setup-python@v5
|
|
20
|
+
with:
|
|
21
|
+
python-version: ${{ matrix.python-version }}
|
|
22
|
+
|
|
23
|
+
- name: Install dependencies
|
|
24
|
+
run: |
|
|
25
|
+
pip install -e ".[dev]"
|
|
26
|
+
|
|
27
|
+
- name: Lint
|
|
28
|
+
run: ruff check src/ tests/
|
|
29
|
+
|
|
30
|
+
- name: Type check
|
|
31
|
+
run: mypy src/oneclaw/ --ignore-missing-imports
|
|
32
|
+
|
|
33
|
+
- name: Test
|
|
34
|
+
run: pytest -v
|
|
35
|
+
|
|
36
|
+
publish:
|
|
37
|
+
needs: test
|
|
38
|
+
runs-on: ubuntu-latest
|
|
39
|
+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
- uses: actions/setup-python@v5
|
|
45
|
+
with:
|
|
46
|
+
python-version: "3.12"
|
|
47
|
+
|
|
48
|
+
- name: Build
|
|
49
|
+
run: |
|
|
50
|
+
pip install build
|
|
51
|
+
python -m build
|
|
52
|
+
|
|
53
|
+
- name: Publish to PyPI
|
|
54
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
oneclaw-0.1.0/.gitignore
ADDED
oneclaw-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 1Claw
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
oneclaw-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: oneclaw
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Official Python SDK for the 1Claw secrets management platform
|
|
5
|
+
Project-URL: Homepage, https://1claw.xyz
|
|
6
|
+
Project-URL: Documentation, https://docs.1claw.xyz
|
|
7
|
+
Project-URL: Repository, https://github.com/1clawAI/1claw-python-sdk
|
|
8
|
+
Project-URL: Issues, https://github.com/1clawAI/1claw-python-sdk/issues
|
|
9
|
+
Author-email: 1Claw <ops@1claw.xyz>
|
|
10
|
+
License-Expression: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,ai,crypto,secrets,signing,vault
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Security
|
|
23
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: httpx<1,>=0.27
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: mypy>=1.13; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
30
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
31
|
+
Requires-Dist: respx>=0.22; extra == 'dev'
|
|
32
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# 1Claw Python SDK
|
|
36
|
+
|
|
37
|
+
Official Python SDK for the [1Claw](https://1claw.xyz) secrets management platform.
|
|
38
|
+
|
|
39
|
+
[](https://pypi.org/project/oneclaw/)
|
|
40
|
+
[](https://pypi.org/project/oneclaw/)
|
|
41
|
+
[](https://opensource.org/licenses/MIT)
|
|
42
|
+
|
|
43
|
+
## Installation
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install oneclaw
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Quick Start
|
|
50
|
+
|
|
51
|
+
### Agent Authentication (API Key)
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from oneclaw import create_client
|
|
55
|
+
|
|
56
|
+
# Agent keys (ocv_) auto-exchange for JWTs and refresh before expiry
|
|
57
|
+
client = create_client(api_key="ocv_your_agent_key")
|
|
58
|
+
|
|
59
|
+
# Agent ID is auto-discovered from the token exchange
|
|
60
|
+
print(client.resolved_agent_id)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### User Authentication
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from oneclaw import create_client
|
|
67
|
+
|
|
68
|
+
# User API key (1ck_) — auto-exchanges for JWT
|
|
69
|
+
client = create_client(api_key="1ck_your_user_key")
|
|
70
|
+
|
|
71
|
+
# Or login with email/password
|
|
72
|
+
client = create_client()
|
|
73
|
+
client.auth.login("user@example.com", "password")
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Pre-authenticated with JWT
|
|
77
|
+
|
|
78
|
+
```python
|
|
79
|
+
client = create_client(token="eyJ...")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
### Vaults
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
# Create a vault
|
|
88
|
+
resp = client.vaults.create("my-vault", description="Production secrets")
|
|
89
|
+
vault_id = resp.data["id"]
|
|
90
|
+
|
|
91
|
+
# List vaults
|
|
92
|
+
vaults = client.vaults.list()
|
|
93
|
+
for v in vaults.data["vaults"]:
|
|
94
|
+
print(v["name"])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Secrets
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
# Store a secret
|
|
101
|
+
client.secrets.set(vault_id, "api-key", "sk-secret-value")
|
|
102
|
+
|
|
103
|
+
# Retrieve a secret
|
|
104
|
+
secret = client.secrets.get(vault_id, "api-key")
|
|
105
|
+
print(secret.data["value"])
|
|
106
|
+
|
|
107
|
+
# Server-side rotation (vault generates a random value)
|
|
108
|
+
client.secrets.rotate_generate(vault_id, "api-key", length=64, charset="base64")
|
|
109
|
+
|
|
110
|
+
# List versions
|
|
111
|
+
versions = client.secrets.list_versions(vault_id, "api-key")
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Agents
|
|
115
|
+
|
|
116
|
+
```python
|
|
117
|
+
# Register an agent
|
|
118
|
+
resp = client.agents.create("my-agent", description="CI/CD bot")
|
|
119
|
+
agent = resp.data["agent"]
|
|
120
|
+
api_key = resp.data["api_key"] # Save this — shown only once
|
|
121
|
+
|
|
122
|
+
# Self-enroll (no auth required)
|
|
123
|
+
client.agents.enroll("my-agent", "admin@example.com")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Access Policies
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# Grant an agent read access to secrets matching a pattern
|
|
130
|
+
client.policies.create(
|
|
131
|
+
vault_id,
|
|
132
|
+
principal_type="agent",
|
|
133
|
+
principal_id=agent_id,
|
|
134
|
+
secret_path_pattern="production/*",
|
|
135
|
+
permissions=["read"],
|
|
136
|
+
)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Intents API (Transaction Signing)
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
# Submit a transaction
|
|
143
|
+
resp = client.agents.submit_transaction(
|
|
144
|
+
agent_id,
|
|
145
|
+
chain="ethereum",
|
|
146
|
+
to="0x...",
|
|
147
|
+
value="1000000000000000", # wei
|
|
148
|
+
max_fee_per_gas="30000000000",
|
|
149
|
+
max_priority_fee_per_gas="1000000000",
|
|
150
|
+
)
|
|
151
|
+
print(resp.data["tx_hash"])
|
|
152
|
+
|
|
153
|
+
# Unified signing (personal_sign, typed_data, transaction)
|
|
154
|
+
resp = client.agents.sign_intent(
|
|
155
|
+
agent_id,
|
|
156
|
+
intent_type="personal_sign",
|
|
157
|
+
chain="ethereum",
|
|
158
|
+
message="0x48656c6c6f",
|
|
159
|
+
)
|
|
160
|
+
print(resp.data["signature"])
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Signing Keys
|
|
164
|
+
|
|
165
|
+
```python
|
|
166
|
+
# Provision a signing key
|
|
167
|
+
client.signing_keys.create(agent_id, "ethereum")
|
|
168
|
+
|
|
169
|
+
# List keys
|
|
170
|
+
keys = client.signing_keys.list(agent_id)
|
|
171
|
+
|
|
172
|
+
# Check balance
|
|
173
|
+
balance = client.signing_keys.balance(agent_id, "ethereum")
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Treasury
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
# Create a treasury
|
|
180
|
+
client.treasury.create("Team Treasury", safe_address="0x...", chain="ethereum")
|
|
181
|
+
|
|
182
|
+
# Create a multisig proposal
|
|
183
|
+
client.treasury.propose(treasury_id, chain="ethereum", to="0x...", value="1000000000")
|
|
184
|
+
|
|
185
|
+
# Sign a proposal
|
|
186
|
+
client.treasury.sign_proposal(treasury_id, proposal_id, signature="0x...", decision="approve")
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Treasury Wallets
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
# Generate wallets for all supported chains
|
|
193
|
+
client.treasury_wallets.generate()
|
|
194
|
+
|
|
195
|
+
# Check balance
|
|
196
|
+
balance = client.treasury_wallets.balance("ethereum")
|
|
197
|
+
|
|
198
|
+
# Send tokens (requires password re-auth)
|
|
199
|
+
client.treasury_wallets.send(
|
|
200
|
+
"ethereum",
|
|
201
|
+
to="0x...",
|
|
202
|
+
value="1000000000000000",
|
|
203
|
+
password="your-account-password",
|
|
204
|
+
)
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Platform API
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
# Register a platform app
|
|
211
|
+
resp = client.platform.create_app("My App", "my-app")
|
|
212
|
+
plt_key = resp.data["api_key"] # Save this
|
|
213
|
+
|
|
214
|
+
# Provision a user
|
|
215
|
+
conn = client.platform.upsert_user(email="user@example.com")
|
|
216
|
+
|
|
217
|
+
# Bootstrap resources from a template
|
|
218
|
+
bootstrap = client.platform.bootstrap_user(conn.data["connection_id"])
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Webhooks
|
|
222
|
+
|
|
223
|
+
```python
|
|
224
|
+
client.webhooks.create(
|
|
225
|
+
url="https://example.com/webhook",
|
|
226
|
+
events=["agent.transaction.broadcast", "proposal.executed"],
|
|
227
|
+
secret="whsec_...",
|
|
228
|
+
)
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Risk Engine
|
|
232
|
+
|
|
233
|
+
```python
|
|
234
|
+
# List risk events
|
|
235
|
+
events = client.risk.list_events(severity="high")
|
|
236
|
+
|
|
237
|
+
# Register a honeytoken
|
|
238
|
+
client.risk.create_honeytoken(vault_id, "canary/secret-key")
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Error Handling
|
|
242
|
+
|
|
243
|
+
```python
|
|
244
|
+
from oneclaw import create_client, OneclawError, AuthError, NotFoundError
|
|
245
|
+
|
|
246
|
+
client = create_client(api_key="ocv_...")
|
|
247
|
+
|
|
248
|
+
# Envelope-style (no exceptions)
|
|
249
|
+
resp = client.vaults.get("nonexistent-id")
|
|
250
|
+
if resp.error:
|
|
251
|
+
print(f"Error: {resp.error.message}")
|
|
252
|
+
|
|
253
|
+
# Exception-style (use the underlying HTTP client)
|
|
254
|
+
try:
|
|
255
|
+
data = client._http.request_or_throw("GET", "/v1/vaults/bad-id")
|
|
256
|
+
except NotFoundError:
|
|
257
|
+
print("Vault not found")
|
|
258
|
+
except AuthError:
|
|
259
|
+
print("Authentication failed")
|
|
260
|
+
except OneclawError as e:
|
|
261
|
+
print(f"API error: {e} (status={e.status})")
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## Context Manager
|
|
265
|
+
|
|
266
|
+
```python
|
|
267
|
+
with create_client(api_key="ocv_...") as client:
|
|
268
|
+
vaults = client.vaults.list()
|
|
269
|
+
# Connection pool is automatically closed
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Configuration
|
|
273
|
+
|
|
274
|
+
| Parameter | Default | Description |
|
|
275
|
+
|-----------|---------|-------------|
|
|
276
|
+
| `base_url` | `https://api.1claw.xyz` | API base URL |
|
|
277
|
+
| `token` | `None` | Pre-existing JWT |
|
|
278
|
+
| `api_key` | `None` | `ocv_` (agent) or `1ck_` (user) key |
|
|
279
|
+
| `agent_id` | `None` | Agent UUID (optional, auto-discovered) |
|
|
280
|
+
| `timeout` | `30.0` | HTTP timeout in seconds |
|
|
281
|
+
|
|
282
|
+
## Requirements
|
|
283
|
+
|
|
284
|
+
- Python 3.9+
|
|
285
|
+
- [httpx](https://www.python-httpx.org/) (only runtime dependency)
|
|
286
|
+
|
|
287
|
+
## License
|
|
288
|
+
|
|
289
|
+
MIT
|
oneclaw-0.1.0/README.md
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
# 1Claw Python SDK
|
|
2
|
+
|
|
3
|
+
Official Python SDK for the [1Claw](https://1claw.xyz) secrets management platform.
|
|
4
|
+
|
|
5
|
+
[](https://pypi.org/project/oneclaw/)
|
|
6
|
+
[](https://pypi.org/project/oneclaw/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install oneclaw
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
### Agent Authentication (API Key)
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
from oneclaw import create_client
|
|
21
|
+
|
|
22
|
+
# Agent keys (ocv_) auto-exchange for JWTs and refresh before expiry
|
|
23
|
+
client = create_client(api_key="ocv_your_agent_key")
|
|
24
|
+
|
|
25
|
+
# Agent ID is auto-discovered from the token exchange
|
|
26
|
+
print(client.resolved_agent_id)
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### User Authentication
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from oneclaw import create_client
|
|
33
|
+
|
|
34
|
+
# User API key (1ck_) — auto-exchanges for JWT
|
|
35
|
+
client = create_client(api_key="1ck_your_user_key")
|
|
36
|
+
|
|
37
|
+
# Or login with email/password
|
|
38
|
+
client = create_client()
|
|
39
|
+
client.auth.login("user@example.com", "password")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Pre-authenticated with JWT
|
|
43
|
+
|
|
44
|
+
```python
|
|
45
|
+
client = create_client(token="eyJ...")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
### Vaults
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
# Create a vault
|
|
54
|
+
resp = client.vaults.create("my-vault", description="Production secrets")
|
|
55
|
+
vault_id = resp.data["id"]
|
|
56
|
+
|
|
57
|
+
# List vaults
|
|
58
|
+
vaults = client.vaults.list()
|
|
59
|
+
for v in vaults.data["vaults"]:
|
|
60
|
+
print(v["name"])
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Secrets
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
# Store a secret
|
|
67
|
+
client.secrets.set(vault_id, "api-key", "sk-secret-value")
|
|
68
|
+
|
|
69
|
+
# Retrieve a secret
|
|
70
|
+
secret = client.secrets.get(vault_id, "api-key")
|
|
71
|
+
print(secret.data["value"])
|
|
72
|
+
|
|
73
|
+
# Server-side rotation (vault generates a random value)
|
|
74
|
+
client.secrets.rotate_generate(vault_id, "api-key", length=64, charset="base64")
|
|
75
|
+
|
|
76
|
+
# List versions
|
|
77
|
+
versions = client.secrets.list_versions(vault_id, "api-key")
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Agents
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
# Register an agent
|
|
84
|
+
resp = client.agents.create("my-agent", description="CI/CD bot")
|
|
85
|
+
agent = resp.data["agent"]
|
|
86
|
+
api_key = resp.data["api_key"] # Save this — shown only once
|
|
87
|
+
|
|
88
|
+
# Self-enroll (no auth required)
|
|
89
|
+
client.agents.enroll("my-agent", "admin@example.com")
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Access Policies
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
# Grant an agent read access to secrets matching a pattern
|
|
96
|
+
client.policies.create(
|
|
97
|
+
vault_id,
|
|
98
|
+
principal_type="agent",
|
|
99
|
+
principal_id=agent_id,
|
|
100
|
+
secret_path_pattern="production/*",
|
|
101
|
+
permissions=["read"],
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Intents API (Transaction Signing)
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# Submit a transaction
|
|
109
|
+
resp = client.agents.submit_transaction(
|
|
110
|
+
agent_id,
|
|
111
|
+
chain="ethereum",
|
|
112
|
+
to="0x...",
|
|
113
|
+
value="1000000000000000", # wei
|
|
114
|
+
max_fee_per_gas="30000000000",
|
|
115
|
+
max_priority_fee_per_gas="1000000000",
|
|
116
|
+
)
|
|
117
|
+
print(resp.data["tx_hash"])
|
|
118
|
+
|
|
119
|
+
# Unified signing (personal_sign, typed_data, transaction)
|
|
120
|
+
resp = client.agents.sign_intent(
|
|
121
|
+
agent_id,
|
|
122
|
+
intent_type="personal_sign",
|
|
123
|
+
chain="ethereum",
|
|
124
|
+
message="0x48656c6c6f",
|
|
125
|
+
)
|
|
126
|
+
print(resp.data["signature"])
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Signing Keys
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
# Provision a signing key
|
|
133
|
+
client.signing_keys.create(agent_id, "ethereum")
|
|
134
|
+
|
|
135
|
+
# List keys
|
|
136
|
+
keys = client.signing_keys.list(agent_id)
|
|
137
|
+
|
|
138
|
+
# Check balance
|
|
139
|
+
balance = client.signing_keys.balance(agent_id, "ethereum")
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Treasury
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
# Create a treasury
|
|
146
|
+
client.treasury.create("Team Treasury", safe_address="0x...", chain="ethereum")
|
|
147
|
+
|
|
148
|
+
# Create a multisig proposal
|
|
149
|
+
client.treasury.propose(treasury_id, chain="ethereum", to="0x...", value="1000000000")
|
|
150
|
+
|
|
151
|
+
# Sign a proposal
|
|
152
|
+
client.treasury.sign_proposal(treasury_id, proposal_id, signature="0x...", decision="approve")
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Treasury Wallets
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
# Generate wallets for all supported chains
|
|
159
|
+
client.treasury_wallets.generate()
|
|
160
|
+
|
|
161
|
+
# Check balance
|
|
162
|
+
balance = client.treasury_wallets.balance("ethereum")
|
|
163
|
+
|
|
164
|
+
# Send tokens (requires password re-auth)
|
|
165
|
+
client.treasury_wallets.send(
|
|
166
|
+
"ethereum",
|
|
167
|
+
to="0x...",
|
|
168
|
+
value="1000000000000000",
|
|
169
|
+
password="your-account-password",
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Platform API
|
|
174
|
+
|
|
175
|
+
```python
|
|
176
|
+
# Register a platform app
|
|
177
|
+
resp = client.platform.create_app("My App", "my-app")
|
|
178
|
+
plt_key = resp.data["api_key"] # Save this
|
|
179
|
+
|
|
180
|
+
# Provision a user
|
|
181
|
+
conn = client.platform.upsert_user(email="user@example.com")
|
|
182
|
+
|
|
183
|
+
# Bootstrap resources from a template
|
|
184
|
+
bootstrap = client.platform.bootstrap_user(conn.data["connection_id"])
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Webhooks
|
|
188
|
+
|
|
189
|
+
```python
|
|
190
|
+
client.webhooks.create(
|
|
191
|
+
url="https://example.com/webhook",
|
|
192
|
+
events=["agent.transaction.broadcast", "proposal.executed"],
|
|
193
|
+
secret="whsec_...",
|
|
194
|
+
)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Risk Engine
|
|
198
|
+
|
|
199
|
+
```python
|
|
200
|
+
# List risk events
|
|
201
|
+
events = client.risk.list_events(severity="high")
|
|
202
|
+
|
|
203
|
+
# Register a honeytoken
|
|
204
|
+
client.risk.create_honeytoken(vault_id, "canary/secret-key")
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Error Handling
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from oneclaw import create_client, OneclawError, AuthError, NotFoundError
|
|
211
|
+
|
|
212
|
+
client = create_client(api_key="ocv_...")
|
|
213
|
+
|
|
214
|
+
# Envelope-style (no exceptions)
|
|
215
|
+
resp = client.vaults.get("nonexistent-id")
|
|
216
|
+
if resp.error:
|
|
217
|
+
print(f"Error: {resp.error.message}")
|
|
218
|
+
|
|
219
|
+
# Exception-style (use the underlying HTTP client)
|
|
220
|
+
try:
|
|
221
|
+
data = client._http.request_or_throw("GET", "/v1/vaults/bad-id")
|
|
222
|
+
except NotFoundError:
|
|
223
|
+
print("Vault not found")
|
|
224
|
+
except AuthError:
|
|
225
|
+
print("Authentication failed")
|
|
226
|
+
except OneclawError as e:
|
|
227
|
+
print(f"API error: {e} (status={e.status})")
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Context Manager
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
with create_client(api_key="ocv_...") as client:
|
|
234
|
+
vaults = client.vaults.list()
|
|
235
|
+
# Connection pool is automatically closed
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Configuration
|
|
239
|
+
|
|
240
|
+
| Parameter | Default | Description |
|
|
241
|
+
|-----------|---------|-------------|
|
|
242
|
+
| `base_url` | `https://api.1claw.xyz` | API base URL |
|
|
243
|
+
| `token` | `None` | Pre-existing JWT |
|
|
244
|
+
| `api_key` | `None` | `ocv_` (agent) or `1ck_` (user) key |
|
|
245
|
+
| `agent_id` | `None` | Agent UUID (optional, auto-discovered) |
|
|
246
|
+
| `timeout` | `30.0` | HTTP timeout in seconds |
|
|
247
|
+
|
|
248
|
+
## Requirements
|
|
249
|
+
|
|
250
|
+
- Python 3.9+
|
|
251
|
+
- [httpx](https://www.python-httpx.org/) (only runtime dependency)
|
|
252
|
+
|
|
253
|
+
## License
|
|
254
|
+
|
|
255
|
+
MIT
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "oneclaw"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Official Python SDK for the 1Claw secrets management platform"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "1Claw", email = "ops@1claw.xyz" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["secrets", "vault", "ai", "agents", "crypto", "signing"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Intended Audience :: Developers",
|
|
19
|
+
"License :: OSI Approved :: MIT License",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.9",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Typing :: Typed",
|
|
27
|
+
"Topic :: Security",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
]
|
|
30
|
+
dependencies = [
|
|
31
|
+
"httpx>=0.27,<1",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
dev = [
|
|
36
|
+
"pytest>=8",
|
|
37
|
+
"pytest-asyncio>=0.24",
|
|
38
|
+
"respx>=0.22",
|
|
39
|
+
"ruff>=0.8",
|
|
40
|
+
"mypy>=1.13",
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://1claw.xyz"
|
|
45
|
+
Documentation = "https://docs.1claw.xyz"
|
|
46
|
+
Repository = "https://github.com/1clawAI/1claw-python-sdk"
|
|
47
|
+
Issues = "https://github.com/1clawAI/1claw-python-sdk/issues"
|
|
48
|
+
|
|
49
|
+
[tool.hatch.build.targets.wheel]
|
|
50
|
+
packages = ["src/oneclaw"]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
target-version = "py39"
|
|
54
|
+
line-length = 100
|
|
55
|
+
|
|
56
|
+
[tool.ruff.lint]
|
|
57
|
+
select = ["E", "F", "I", "UP", "B", "SIM"]
|
|
58
|
+
|
|
59
|
+
[tool.mypy]
|
|
60
|
+
python_version = "3.10"
|
|
61
|
+
strict = true
|
|
62
|
+
warn_return_any = true
|
|
63
|
+
warn_unused_configs = true
|
|
64
|
+
|
|
65
|
+
[tool.pytest.ini_options]
|
|
66
|
+
asyncio_mode = "auto"
|
|
67
|
+
testpaths = ["tests"]
|