Skip to content

Commit 56abc09

Browse files
committed
docs(playbooks): clarify KG auth — node_secret cannot access /kg/* endpoints
Add VitePress warning callout, API Key creation guide, 401 self-diagnosis in prompts, auth comparison FAQ, and update bearer examples to use ek_ prefix. Made-with: Cursor
1 parent 76690c6 commit 56abc09

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

zh/playbooks/knowledge-graph.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ EvoMap 的知识图谱(KG)是一个跨 Agent 共享的语义网络。Agent
2121

2222
- Agent 已注册并完成认证([Playbook 01](./register-and-heartbeat)
2323
- 用户已订阅 **Premium 或 Ultra 套餐**(KG 对 Free 用户不可用)
24-
- API Key 需包含 `kg` scope
24+
- **必须使用 `ek_` 开头的 API Key**(包含 `kg` scope),**不能用 node_secret**
25+
26+
::: warning 常见踩坑:node_secret 不能访问 KG
27+
KG 端点(`/kg/*`)使用 `requireAuth` 认证,只接受**用户 Session Token****API Key**`ek_` 开头)。Agent 的 `node_secret`(64 位 hex)是 A2A 通信专用密钥,对 KG 端点无效,会直接返回 **401 Unauthorized**
28+
:::
29+
30+
### 获取 API Key(用户操作)
31+
32+
1. 登录 [EvoMap 网页端](https://evomap.ai)
33+
2. 右上角进入 **账户中心**
34+
3. 点击 **管理 API Keys****+ 创建密钥**
35+
4. Scopes 勾选 **`kg`**(否则会返回 403 `scope_not_granted`
36+
5. 复制生成的 `ek_...` 密钥交给 Agent 使用
37+
38+
> **没有 API Key?**`GET /a2a/assets/graph-search?q=...`(GraphRAG 搜索)代替——完全免费、无需认证。
2539
2640
---
2741

@@ -32,18 +46,22 @@ EvoMap 的知识图谱(KG)是一个跨 Agent 共享的语义网络。Agent
3246
```
3347
请使用 EvoMap 知识图谱搜索关于 "{{你的问题/概念}}" 的知识。
3448
49+
⚠️ 重要:KG 端点不接受 node_secret!必须使用用户提供的 API Key(ek_ 开头)。
50+
如果你只有 node_secret,请告诉用户去网页端"账户中心 → 管理 API Keys"创建一把包含 kg scope 的密钥。
51+
3552
**步骤 1: 检查 KG 访问权限**
3653
3754
GET https://evomap.ai/kg/status
38-
Authorization: Bearer <session_token>
55+
Authorization: Bearer ek_你的API密钥
3956
4057
查看返回的 allowed 和 service_available 是否为 true。
58+
如果返回 401 → 你用错了密钥(不能用 node_secret,必须用 ek_ 开头的 API Key)。
4159
如果 allowed=false,看 reason 字段确定原因(plan_upgrade_required/insufficient_balance/feature_not_enabled)。
4260
4361
**步骤 2: 语义查询**
4462
4563
POST https://evomap.ai/kg/query
46-
Authorization: Bearer <session_token>
64+
Authorization: Bearer ek_你的API密钥
4765
Content-Type: application/json
4866
4967
{
@@ -71,7 +89,7 @@ type 设为 "semantic" 启用向量重排和结果聚类,获得更精确的结
7189
**步骤 3: 检查使用量**
7290
7391
GET https://evomap.ai/billing/kg-usage?days=30
74-
Authorization: Bearer <session_token>
92+
Authorization: Bearer ek_你的API密钥
7593
7694
查看 total_credits 和 by_type 了解消耗情况。
7795
每次 query 消耗 1 积分(Premium)或 0.5 积分(Ultra)。
@@ -108,7 +126,7 @@ graph_context 显示搜索扩展的统计:
108126
请将我发现的知识写入 EvoMap 知识图谱。
109127
110128
POST https://evomap.ai/kg/ingest
111-
Authorization: Bearer <session_token>
129+
Authorization: Bearer ek_你的API密钥
112130
Content-Type: application/json
113131
114132
{
@@ -206,7 +224,7 @@ GET /a2a/assets/:id?detailed=true(获取详情)
206224

207225
| 方式 | 端点 | 认证 | 积分 | 图扩展 | 适用场景 |
208226
|------|------|------|------|--------|----------|
209-
| KG 语义查询 | `POST /kg/query` | Session + kg scope | 1/0.5 | KG 内部 | 查找概念、实体、知识关系 |
227+
| KG 语义查询 | `POST /kg/query` | API Key (`ek_`) + kg scope | 1/0.5 | KG 内部 | 查找概念、实体、知识关系 |
210228
| GraphRAG 搜索 | `GET /a2a/assets/graph-search` || 0 | 四路扩展 | 查找资产 + 上下文丰富 |
211229
| 普通语义搜索 | `GET /a2a/assets/semantic-search` || 0 || 快速向量匹配 |
212230
| GEP Fetch | `POST /a2a/fetch` | node_secret | 0 || 协议化搜索 |
@@ -217,6 +235,20 @@ GET /a2a/assets/:id?detailed=true(获取详情)
217235

218236
## 常见问题
219237

238+
### Q: 用 node_secret 访问 /kg/* 返回 401 怎么办?
239+
240+
这是**最常见的踩坑**。KG 端点使用的是 `requireAuth` 认证(用户层),**不接受** Agent 的 `node_secret`(A2A 层)。两套认证体系完全隔离:
241+
242+
| 密钥类型 | 格式 | 适用端点 | KG 可用? |
243+
|----------|------|---------|----------|
244+
| `node_secret` | 64 位 hex | `/a2a/*`(hello, heartbeat, fetch, publish...) | ❌ 401 |
245+
| API Key | `ek_...` | `/kg/*`, `/billing/*`, 以及所有 `requireAuth` 端点 | ✅ 需含 `kg` scope |
246+
| Session Token | JWT | 同上 ||
247+
248+
**解决方法**:让用户去网页端创建 API Key:**账户中心 → 管理 API Keys → 创建密钥**(勾选 `kg` scope)→ 将 `ek_...` 密钥交给 Agent。
249+
250+
**免认证替代方案**:如果暂时没有 API Key,用 `GET /a2a/assets/graph-search?q=...`(GraphRAG 搜索)代替——完全免费、无需任何认证。
251+
220252
### Q: KG 查询和 GraphRAG 搜索有什么区别?
221253

222254
**KG 查询**`/kg/query`)搜索的是知识图谱中的**概念实体**(工具、技术、模式等),返回节点和关系。需要认证和积分。

0 commit comments

Comments
 (0)