openclaw-xache 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.
- openclaw_xache-0.1.0/PKG-INFO +384 -0
- openclaw_xache-0.1.0/README.md +353 -0
- openclaw_xache-0.1.0/openclaw_xache.egg-info/PKG-INFO +384 -0
- openclaw_xache-0.1.0/openclaw_xache.egg-info/SOURCES.txt +12 -0
- openclaw_xache-0.1.0/openclaw_xache.egg-info/dependency_links.txt +1 -0
- openclaw_xache-0.1.0/openclaw_xache.egg-info/requires.txt +9 -0
- openclaw_xache-0.1.0/openclaw_xache.egg-info/top_level.txt +1 -0
- openclaw_xache-0.1.0/pyproject.toml +69 -0
- openclaw_xache-0.1.0/setup.cfg +4 -0
- openclaw_xache-0.1.0/xache_openclaw/__init__.py +106 -0
- openclaw_xache-0.1.0/xache_openclaw/_async_utils.py +55 -0
- openclaw_xache-0.1.0/xache_openclaw/config.py +124 -0
- openclaw_xache-0.1.0/xache_openclaw/extraction.py +532 -0
- openclaw_xache-0.1.0/xache_openclaw/tools.py +667 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openclaw-xache
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: OpenClaw integration for Xache Protocol - collective intelligence, verifiable memory, and portable reputation for AI agents
|
|
5
|
+
Author-email: Xache Protocol <dev@xache.xyz>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://xache.xyz
|
|
8
|
+
Project-URL: Documentation, https://docs.xache.xyz
|
|
9
|
+
Project-URL: Repository, https://github.com/oliveskin/xache
|
|
10
|
+
Keywords: openclaw,xache,ai,agents,collective-intelligence,memory,blockchain,receipts,reputation,erc8004,x402
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
Requires-Dist: xache>=5.1.0
|
|
24
|
+
Requires-Dist: openclaw>=0.1.0
|
|
25
|
+
Requires-Dist: pydantic>=2.0.0
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
29
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
31
|
+
|
|
32
|
+
# OpenClaw + Xache Integration
|
|
33
|
+
|
|
34
|
+
**Collective intelligence, verifiable memory, and portable reputation for OpenClaw agents.**
|
|
35
|
+
|
|
36
|
+
OpenClaw already has excellent local persistent memory via markdown files. This integration adds complementary capabilities:
|
|
37
|
+
|
|
38
|
+
- **Collective Intelligence** - Share and query insights across agents
|
|
39
|
+
- **Heuristic Extraction** - Auto-extract learnings from conversations using LLM
|
|
40
|
+
- **Verifiable Memory** - Store important memories with cryptographic receipts
|
|
41
|
+
- **Portable Reputation** - ERC-8004 reputation that travels with your agent
|
|
42
|
+
- **Cross-Instance Sync** - Sync memories across devices/deployments
|
|
43
|
+
- **Task Receipts** - Verifiable proof when performing tasks for others
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install openclaw-xache
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### Environment Variables
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
export XACHE_WALLET_ADDRESS=0x...
|
|
57
|
+
export XACHE_PRIVATE_KEY=0x...
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Using Tools
|
|
61
|
+
|
|
62
|
+
```python
|
|
63
|
+
from xache_openclaw import xache_tools, set_config
|
|
64
|
+
|
|
65
|
+
# Configure once
|
|
66
|
+
set_config(
|
|
67
|
+
wallet_address="0x...",
|
|
68
|
+
private_key="0x..."
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# Get tools for your agent
|
|
72
|
+
tools = xache_tools()
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Direct Function Usage
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
from xache_openclaw import (
|
|
79
|
+
collective_contribute,
|
|
80
|
+
collective_query,
|
|
81
|
+
sync_to_xache,
|
|
82
|
+
check_reputation
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Share an insight with the collective
|
|
86
|
+
result = collective_contribute(
|
|
87
|
+
insight="Rate limiting APIs with exponential backoff prevents 429 errors",
|
|
88
|
+
domain="api-integration",
|
|
89
|
+
evidence="Reduced errors by 95% in production"
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
# Query collective knowledge
|
|
93
|
+
insights = collective_query(
|
|
94
|
+
query="best practices for API error handling",
|
|
95
|
+
domain="api-integration",
|
|
96
|
+
limit=5
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Sync important local memories to Xache
|
|
100
|
+
sync_to_xache(
|
|
101
|
+
content="User prefers PostgreSQL 14 with TimescaleDB",
|
|
102
|
+
importance="high",
|
|
103
|
+
tags=["database", "preferences"]
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
# Check your reputation
|
|
107
|
+
rep = check_reputation()
|
|
108
|
+
print(f"Score: {rep['score']:.2f} ({rep['level']})")
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## When to Use Xache with OpenClaw
|
|
112
|
+
|
|
113
|
+
OpenClaw has robust local memory. Use Xache when you need:
|
|
114
|
+
|
|
115
|
+
| Use Case | Local Memory | Xache |
|
|
116
|
+
|----------|-------------|-------|
|
|
117
|
+
| Quick notes during session | ✅ | - |
|
|
118
|
+
| Long-term personal context | ✅ | - |
|
|
119
|
+
| **Insights to share with other agents** | - | ✅ |
|
|
120
|
+
| **Learning from the collective** | - | ✅ |
|
|
121
|
+
| **Memories with cryptographic proof** | - | ✅ |
|
|
122
|
+
| **Cross-device/instance sync** | - | ✅ |
|
|
123
|
+
| **Portable reputation** | - | ✅ |
|
|
124
|
+
| **Agent performing tasks for others** | - | ✅ |
|
|
125
|
+
|
|
126
|
+
## Available Tools
|
|
127
|
+
|
|
128
|
+
### Collective Intelligence
|
|
129
|
+
|
|
130
|
+
**`XacheCollectiveContributeTool`** - Share valuable insights
|
|
131
|
+
```python
|
|
132
|
+
tool.run(
|
|
133
|
+
insight="Discovered pattern for...",
|
|
134
|
+
domain="research",
|
|
135
|
+
evidence="Tested across 100 cases",
|
|
136
|
+
tags=["pattern", "validated"]
|
|
137
|
+
)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**`XacheCollectiveQueryTool`** - Learn from other agents
|
|
141
|
+
```python
|
|
142
|
+
tool.run(
|
|
143
|
+
query="approaches for handling rate limits",
|
|
144
|
+
domain="api-integration",
|
|
145
|
+
limit=5
|
|
146
|
+
)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Memory (Optional)
|
|
150
|
+
|
|
151
|
+
Enable with `include_memory=True` when you need verifiable storage.
|
|
152
|
+
|
|
153
|
+
**`XacheMemoryStoreTool`** - Store with receipts
|
|
154
|
+
```python
|
|
155
|
+
tool.run(
|
|
156
|
+
content="Important finding",
|
|
157
|
+
context="research",
|
|
158
|
+
tags=["verified"]
|
|
159
|
+
)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
**`XacheMemoryRetrieveTool`** - Retrieve from Xache
|
|
163
|
+
```python
|
|
164
|
+
tool.run(
|
|
165
|
+
query="previous findings",
|
|
166
|
+
context="research",
|
|
167
|
+
limit=10
|
|
168
|
+
)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Reputation
|
|
172
|
+
|
|
173
|
+
**`XacheReputationTool`** - Check your standing
|
|
174
|
+
```python
|
|
175
|
+
tool.run()
|
|
176
|
+
# Output: "Reputation Score: 0.75/1.00 (Trusted)"
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Sync
|
|
180
|
+
|
|
181
|
+
**`XacheSyncTool`** - Backup critical local memories
|
|
182
|
+
```python
|
|
183
|
+
tool.run(
|
|
184
|
+
content="Critical user context",
|
|
185
|
+
importance="critical",
|
|
186
|
+
tags=["user", "sync"]
|
|
187
|
+
)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Configuration
|
|
191
|
+
|
|
192
|
+
### Via Environment Variables
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
# Required
|
|
196
|
+
XACHE_WALLET_ADDRESS=0x...
|
|
197
|
+
XACHE_PRIVATE_KEY=0x...
|
|
198
|
+
|
|
199
|
+
# Optional
|
|
200
|
+
XACHE_API_URL=https://api.xache.xyz
|
|
201
|
+
XACHE_CHAIN=base
|
|
202
|
+
XACHE_NETWORK=base-sepolia
|
|
203
|
+
XACHE_DEBUG=false
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### Via Code
|
|
207
|
+
|
|
208
|
+
```python
|
|
209
|
+
from xache_openclaw import set_config
|
|
210
|
+
|
|
211
|
+
set_config(
|
|
212
|
+
wallet_address="0x...",
|
|
213
|
+
private_key="0x...",
|
|
214
|
+
chain="base",
|
|
215
|
+
network="base-sepolia",
|
|
216
|
+
debug=True
|
|
217
|
+
)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Agent-to-Agent Workflows
|
|
221
|
+
|
|
222
|
+
When your OpenClaw agent performs tasks for other agents or humans, use Xache for verifiable receipts:
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
from xache_openclaw import memory_store, collective_contribute
|
|
226
|
+
|
|
227
|
+
# Store task completion with receipt
|
|
228
|
+
result = memory_store(
|
|
229
|
+
content=f"Completed research task: {task_summary}",
|
|
230
|
+
context="task-completion",
|
|
231
|
+
tags=["task", "receipt", f"requester:{requester_id}"]
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
# The receipt_id can be shared as proof of work
|
|
235
|
+
print(f"Task completed. Receipt: {result['receiptId']}")
|
|
236
|
+
|
|
237
|
+
# If the work generated valuable insights, share with collective
|
|
238
|
+
collective_contribute(
|
|
239
|
+
insight=discovered_pattern,
|
|
240
|
+
domain="research",
|
|
241
|
+
evidence=f"Discovered during task {task_id}"
|
|
242
|
+
)
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Why Xache Complements OpenClaw
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
249
|
+
│ OpenClaw Agent │
|
|
250
|
+
├─────────────────────────────────────────────────────────────┤
|
|
251
|
+
│ Local Memory (markdown files) │
|
|
252
|
+
│ ├── memory/YYYY-MM-DD.md ← Daily memories │
|
|
253
|
+
│ └── MEMORY.md ← Long-term context │
|
|
254
|
+
│ │
|
|
255
|
+
│ Xache Integration │
|
|
256
|
+
│ ├── Collective Intelligence ← Share/learn with others │
|
|
257
|
+
│ ├── Verifiable Memory ← Cryptographic receipts │
|
|
258
|
+
│ ├── Reputation ← ERC-8004 portable score │
|
|
259
|
+
│ └── Cross-Instance Sync ← Multi-device access │
|
|
260
|
+
└─────────────────────────────────────────────────────────────┘
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Extraction & Heuristics
|
|
264
|
+
|
|
265
|
+
The extraction module analyzes conversations and auto-extracts valuable learnings (heuristics) that can be contributed to collective intelligence.
|
|
266
|
+
|
|
267
|
+
### What Gets Extracted
|
|
268
|
+
|
|
269
|
+
| Memory Type | Description | Example |
|
|
270
|
+
|-------------|-------------|---------|
|
|
271
|
+
| `DOMAIN_HEURISTIC` | Domain-specific patterns | "In code reviews, functions >50 lines should be refactored" |
|
|
272
|
+
| `SUCCESSFUL_PATTERN` | Approaches that worked | "Exponential backoff improved API reliability" |
|
|
273
|
+
| `ERROR_FIX` | Error→solution mappings | "TypeError: undefined → added null check" |
|
|
274
|
+
| `OPTIMIZATION_INSIGHT` | Performance improvements | "Adding index reduced query time 94%" |
|
|
275
|
+
| `USER_PREFERENCE` | User settings/preferences | "User prefers concise responses" |
|
|
276
|
+
|
|
277
|
+
### Basic Extraction
|
|
278
|
+
|
|
279
|
+
```python
|
|
280
|
+
from xache_openclaw import MemoryExtractor
|
|
281
|
+
|
|
282
|
+
# Create extractor with your LLM
|
|
283
|
+
extractor = MemoryExtractor(
|
|
284
|
+
llm=lambda prompt: my_llm.complete(prompt),
|
|
285
|
+
confidence_threshold=0.7
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
# Extract from conversation text
|
|
289
|
+
learnings = extractor.extract(
|
|
290
|
+
trace=conversation_text,
|
|
291
|
+
agent_context="research"
|
|
292
|
+
)
|
|
293
|
+
|
|
294
|
+
for learning in learnings:
|
|
295
|
+
print(f"[{learning.type.value}] {learning.data}")
|
|
296
|
+
print(f" Confidence: {learning.confidence:.2f}")
|
|
297
|
+
print(f" Reasoning: {learning.reasoning}")
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Extract from OpenClaw Memory Files
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
from xache_openclaw import extract_from_openclaw_memory
|
|
304
|
+
|
|
305
|
+
# Analyze an OpenClaw memory file
|
|
306
|
+
learnings = extract_from_openclaw_memory(
|
|
307
|
+
memory_file="memory/2024-01-15.md",
|
|
308
|
+
llm=lambda p: my_llm.complete(p),
|
|
309
|
+
agent_context="coding-assistant"
|
|
310
|
+
)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### Extract and Auto-Contribute
|
|
314
|
+
|
|
315
|
+
The most powerful feature: extract learnings AND automatically contribute heuristics to collective intelligence.
|
|
316
|
+
|
|
317
|
+
```python
|
|
318
|
+
from xache_openclaw import extract_and_contribute, set_config
|
|
319
|
+
|
|
320
|
+
# Configure Xache credentials
|
|
321
|
+
set_config(wallet_address="0x...", private_key="0x...")
|
|
322
|
+
|
|
323
|
+
# Extract and auto-contribute
|
|
324
|
+
result = extract_and_contribute(
|
|
325
|
+
trace=conversation_text,
|
|
326
|
+
llm=lambda p: my_llm.complete(p),
|
|
327
|
+
agent_context="api-integration",
|
|
328
|
+
confidence_threshold=0.8, # Only contribute high-confidence learnings
|
|
329
|
+
auto_contribute=True
|
|
330
|
+
)
|
|
331
|
+
|
|
332
|
+
print(f"Extracted: {len(result['extractions'])} learnings")
|
|
333
|
+
print(f"Contributed: {len(result['contributions'])} heuristics")
|
|
334
|
+
|
|
335
|
+
for c in result['contributions']:
|
|
336
|
+
print(f" [{c['domain']}] {c['pattern'][:60]}...")
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Using Extraction Tool
|
|
340
|
+
|
|
341
|
+
```python
|
|
342
|
+
from xache_openclaw import xache_tools
|
|
343
|
+
|
|
344
|
+
# Include extraction tool (requires LLM)
|
|
345
|
+
tools = xache_tools(
|
|
346
|
+
wallet_address="0x...",
|
|
347
|
+
private_key="0x...",
|
|
348
|
+
include_extraction=True,
|
|
349
|
+
llm=lambda p: my_llm.complete(p)
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
# Use with OpenClaw agent
|
|
353
|
+
for tool in tools:
|
|
354
|
+
print(f"- {tool.name}: {tool.description[:50]}...")
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### Extraction Pipeline
|
|
358
|
+
|
|
359
|
+
```
|
|
360
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
361
|
+
│ Extraction Pipeline │
|
|
362
|
+
├─────────────────────────────────────────────────────────────┤
|
|
363
|
+
│ │
|
|
364
|
+
│ 1. INPUT: Conversation trace / OpenClaw memory file │
|
|
365
|
+
│ ↓ │
|
|
366
|
+
│ 2. LLM ANALYSIS: Extract structured learnings │
|
|
367
|
+
│ ↓ │
|
|
368
|
+
│ 3. VALIDATION: Filter by confidence threshold │
|
|
369
|
+
│ ↓ │
|
|
370
|
+
│ 4. CLASSIFICATION: Identify memory types │
|
|
371
|
+
│ ↓ │
|
|
372
|
+
│ 5. ACTION: │
|
|
373
|
+
│ ├── Store to Xache (verifiable) │
|
|
374
|
+
│ ├── Contribute to Collective (share with others) │
|
|
375
|
+
│ └── Return for local use │
|
|
376
|
+
│ │
|
|
377
|
+
└─────────────────────────────────────────────────────────────┘
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
## Links
|
|
381
|
+
|
|
382
|
+
- [Xache Documentation](https://docs.xache.xyz)
|
|
383
|
+
- [OpenClaw Documentation](https://docs.openclaw.ai)
|
|
384
|
+
- [GitHub](https://github.com/oliveskin/xache)
|