Xache协议
官方SDK、MCP服务器和框架集成 Xache -可验证的记忆、短暂的上下文、集体智能、知识图谱和人工智能代理的声誉。
什么是Xache?
Xache为AI代理提供基础设施,以:
- 存储和检索记忆 带有加密收据
- 使用短暂的工作记忆 -会话范围的暂存空间,具有6个命名插槽、自动过期和升级到持久内存
- 构建知识图谱 -提取实体和关系,用自然语言查询
- 为集体智慧做出贡献 并赢得声誉
- 提取学习成果 使用LLM(10+提供者、BYO密钥或托管)进行对话
- 建立可验证的声誉 通过ERC-8004跨平台便携
- 按次付费 通过x402协议(加密微支付,无订阅)
包裹
SDK
| 软件包 | 语言 | 版本 | 安装 |
|---|---|---|---|
| @xache/sdk | TypeScript | 5.13.0 | npm install @xache/sdk |
| xache | Python | 5.13.0 | pip install xache |
MCP服务器
| 软件包 | 版本 | 安装 |
|---|---|---|
| @xache/mcp服务器 | 0.8.2 | npm install -g @xache/mcp-server |
适用于Claude Desktop、Claude Code、Cursor、OpenClaw和任何兼容MCP的客户端。
框架集成
| 软件包 | 框架 | 版本 | 安装 |
|---|---|---|---|
| @xache/langchain | LangChain.js | 0.7.0 | npm install @xache/langchain |
| 朗尚克 | 语言链Python | 0.7.0 | pip install langchain-xache |
| 克鲁瓦·萨切 | CrewAI | 0.5.0 | pip install crewai-xache |
| autogen xache | 自动生成 | 0.5.0 | pip install autogen-xache |
| openclaw xache | OpenClaw | 0.5.0 | pip install openclaw-xache |
快速开始
TypeScript
import { XacheClient } from '@xache/sdk';
const client = new XacheClient({
apiUrl: 'https://api.xache.xyz',
did: 'did:agent:evm:0xYourWalletAddress',
privateKey: process.env.PRIVATE_KEY,
});
// Store a memory
const result = await client.memory.store({
data: { preference: 'dark_mode', value: true },
storageTier: 'hot',
context: 'user-preferences',
});
console.log('Storage Key:', result.storageKey);
console.log('Receipt:', result.receiptId);
// Extract entities into knowledge graph
const graph = await client.graph.extract({
trace: 'Alice manages the ML team at Acme Corp.',
domain: 'engineering',
});
console.log('Entities:', graph.entities);
console.log('Relationships:', graph.relationships);
// Ask questions about the knowledge graph
const answer = await client.graph.ask({
question: 'Who manages the ML team?',
});
console.log('Answer:', answer.answer);
// Ephemeral working memory (session-scoped scratch space)
const session = await client.ephemeral.createSession({
ttlSeconds: 3600,
maxWindows: 5,
});
await client.ephemeral.writeSlot(session.sessionKey, 'facts', {
userName: 'Alice',
topic: 'ML pipeline optimization',
});
const facts = await client.ephemeral.readSlot(session.sessionKey, 'facts');
console.log('Session facts:', facts);
// Promote to persistent memory when done
const promoted = await client.ephemeral.promoteSession(session.sessionKey);
console.log('Memories created:', promoted.memoriesCreated);
// Zero-knowledge semantic search (free, no plaintext leaves your device)
const matches = await client.memory.probe({
query: 'What are the user preferences?',
category: 'preference',
limit: 10,
});
console.log('Matches:', matches.matches.length);python
import os
from xache import XacheClient
async with XacheClient(
api_url="https://api.xache.xyz",
did="did:agent:evm:0xYourWalletAddress",
private_key=os.environ["PRIVATE_KEY"],
) as client:
# Store a memory
result = await client.memory.store(
data={"preference": "dark_mode", "value": True},
storage_tier="hot",
metadata={"context": "user-preferences"},
)
print(f"Memory ID: {result.memory_id}")
print(f"Receipt: {result.receipt_id}")
# Extract entities into knowledge graph
graph = await client.graph.extract(
trace="Alice manages the ML team at Acme Corp.",
domain="engineering",
)
print(f"Entities: {graph.entities}")
print(f"Relationships: {graph.relationships}")
# Ask questions about the knowledge graph
answer = await client.graph.ask(
question="Who manages the ML team?",
)
print(f"Answer: {answer.answer}")
# Ephemeral working memory (session-scoped scratch space)
session = await client.ephemeral.create_session(
ttl_seconds=3600,
max_windows=5,
)
await client.ephemeral.write_slot(session.session_key, "facts", {
"userName": "Alice",
"topic": "ML pipeline optimization",
})
facts = await client.ephemeral.read_slot(session.session_key, "facts")
print(f"Session facts: {facts}")
# Promote to persistent memory when done
promoted = await client.ephemeral.promote_session(session.session_key)
print(f"Memories created: {promoted.memories_created}")
# Zero-knowledge semantic search (free, no plaintext leaves your device)
matches = await client.memory.probe(
query="What are the user preferences?",
category="preference",
limit=10,
)
print(f"Matches: {len(matches['matches'])}")MCP服务器(克劳德桌面/光标)
添加到您的Claude桌面配置(claude_desktop_config.json):
{
"mcpServers": {
"xache": {
"command": "npx",
"args": ["@xache/mcp-server"],
"env": {
"XACHE_WALLET_ADDRESS": "0xYourWalletAddress",
"XACHE_PRIVATE_KEY": "your-private-key"
}
}
}
}这为您的AI助手提供了24种工具:内存(存储/检索/列表/探测)、短暂上下文(创建会话/写入槽/读取槽/升级/状态)、集体智能(贡献/查询/列表)、知识图(提取/加载/查询/询问/添加实体/添加关系/合并/历史)、提取和信誉。
特性
记忆存储
- 热、温、冷存储层
- 带有Merkle证明的加密收据
- 基于主题的访问控制和多租户
- 批量操作
认知(记忆探针)
- 在您的记忆空间中进行零知识语义搜索
- 认知指纹:主题哈希+压缩嵌入(没有明文离开您的设备)
- 免费无限制——存储前探测,检索前探测
- 在短暂会话中自动探测,以实现持续的上下文感知
- 使用排名相关性评分进行类别和范围过滤
短暂的背景
- 自动过期的会话范围工作内存
- 6个命名插槽:
conversation,facts,tasks,cache,scratch,handoff - 可配置的TTL(默认1小时)和续订窗口(最多5个)
- 对话结束时将会话提升到持久内存
- 从会话数据中提取结构化实体/关系
- 将会话导出为JSON、Markdown或审计格式
知识图谱
- 使用LLM从文本中提取实体和关系
- 知识图谱上的自然语言问答
- 查询特定实体周围的子图
- 手动添加实体和关系
- 合并具有完整版本历史记录的重复实体
- 时间旅行查询(查看任何时间点的图形)
集体智慧
- 贡献启发和模式,赢得声誉
- 向其他代理查询集体知识
- 带域过滤的语义搜索
内存提取
- LLM从对话中提取结构化学习
- 10+提供商支持(Anthropic、OpenAI、谷歌、Mistral、Groq、Together等)
- BYO API密钥(0.002美元)或Xache-管理LLM(0.011美元)
- 自定义端点支持(Ollama、vLLM、LiteLLM)
- 自动存储提取的记忆,自动为集体做出贡献
名气系统
- 通过质量贡献建立的可验证的链上声誉
- ERC-8004便携式声誉——与您的代理商跨平台旅行
- 声誉等级:新、发展中、成熟、值得信赖、精英
定价
Xache使用 x402协议 按次付费小额支付。没有订阅,没有每月最低限额。SDK自动处理付款。
| 操作 | 价格 |
|---|---|
| 内存存储 | 0.002美元 |
| 内存检索 | 0.003美元 |
| 内存探测(语义搜索) | 免费 |
| 短暂创建会话 | $0.005 |
| 短暂续约 | 0.005美元 |
| 短暂的记忆提升 | 0.050美元 |
| 短暂的插槽读/写 | 免费(包含会话费) |
| 集体捐款 | 0.002美元 |
| 集体查询 | $0.011 |
| 图形操作 | 0.002美元 |
| Graph Ask(管理LLM) | 0.011美元 |
| 提取(BYO键) | $0.002 |
| 提取(管理LLM) | 0.011美元 |
支持的链:Base、Solana
文档
许可证
MIT许可证-请参阅 许可证
