@linkmind_claw/openclaw-faq-kb 2.0.3 → 3.1.0

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.
@@ -1,69 +1,173 @@
1
1
  ---
2
2
  name: faq-knowledge-base
3
- description: LinkMind 智能知识库管理员绑定、文档训练、智能问答、权限控制
3
+ description: FAQ 知识库社媒用户注册、权限管理、文档训练、智能问答
4
4
  ---
5
5
 
6
- # LinkMind Knowledge Base Skill
6
+ # FAQ Knowledge Base Skill
7
7
 
8
- ## 核心概念:管理员机制
8
+ You have access to a FAQ Knowledge Base system with **user identity & permission management** that lets you:
9
9
 
10
- 一个 OpenClaw 实例 = 一个管理员(Owner)。
10
+ 1. **Register / login** social-media channel users (Telegram, Discord, etc.)
11
+ 2. **Manage permissions** — grant roles and knowledge base access
12
+ 3. **Create & train** a knowledge base from a document (PDF/DOCX/TXT/MD)
13
+ 4. **Ask questions** against a trained knowledge base
14
+ 5. **Browse knowledge bases** — list accessible KBs
11
15
 
12
- - 无论连接了多少个 bot,它们共享同一个管理员
13
- - 管理员通过 Telegram user ID 绑定
14
- - 管理员拥有全部权限:创建/训练/删除知识库、管理用户权限
15
- - 其他用户只能查询管理员开放给他的知识库 + 公开知识库
16
+ ## Permission Model
16
17
 
17
- ### 绑定管理员流程
18
+ ```
19
+ Role │ Capabilities
20
+ ────────────┼──────────────────────────────────
21
+ viewer │ Query knowledge bases, list KBs
22
+ editor │ + Create KB, train, manage FAQ
23
+ reviewer │ + Delete FAQ, view audit logs
24
+ admin │ + Delete KB, manage users, grant roles
25
+ ```
26
+
27
+ - New users from social-media channels default to **viewer** (query-only).
28
+ - The Bot Owner (first admin) can promote users via `faq_account_manage`.
29
+ - `kb_scope` controls which KBs a user can access (null = all).
30
+
31
+ ## Available Tools
32
+
33
+ ### `faq_account_register`
34
+
35
+ Auto-register or login a social-media channel user.
36
+
37
+ **When to use:**
38
+ - A new user interacts with the bot for the first time
39
+ - You need to establish the user's identity before other operations
40
+ - The user explicitly asks to register or log in
41
+
42
+ **Parameters:**
43
+ - `channel_type` (required): telegram / discord / slack / web / whatsapp / line
44
+ - `channel_user_id` (required): The user's unique ID on that platform
45
+ - `channel_bot_id` (optional): Bot identifier (default "default")
46
+ - `display_name` (optional): User display name
47
+ - `role` (optional): Initial role for new users (default "viewer")
48
+
49
+ **Notes:**
50
+ - Returns `is_new: true` for first-time users with a freshly generated `api_key`
51
+ - The API Key is automatically cached; all subsequent requests use this user's identity
52
+ - Existing users just get their current identity info (no new key)
53
+
54
+ ### `faq_account_manage`
55
+
56
+ Admin-level account management.
57
+
58
+ **When to use:**
59
+ - Bot Owner wants to promote a user: "让用户 X 也能建库"
60
+ - Admin wants to see who's registered: "看看都有谁在用"
61
+ - User wants to check their own permissions: "我能做什么"
62
+
63
+ **Parameters:**
64
+ - `action` (required): `grant_role` / `list_users` / `my_info`
65
+ - `target_channel_user_id`: Required for `grant_role`
66
+ - `target_channel_type`: Channel type of the target (default "telegram")
67
+ - `role`: The role to grant (required for `grant_role`)
68
+ - `kb_scope`: Array of KB IDs the user can access (null = all)
69
+
70
+ **Notes:**
71
+ - `grant_role` and `list_users` require **admin** permission
72
+ - `my_info` works for any authenticated user
73
+
74
+ ### `faq_kb_create_and_train`
75
+
76
+ One-click knowledge base creation + full training pipeline.
18
77
 
19
- 1. 服务器首次启动时生成一次性密钥
20
- 2. 第一个与 bot 对话的用户会自动收到密钥
21
- 3. 用户发送 `/linkmind_claim <密钥>` 完成绑定,成为管理员
78
+ **When to use:**
79
+ - User says "create a knowledge base from this document"
80
+ - User provides a file URL and wants to set up a Q&A system
22
81
 
23
- ## Slash Commands
82
+ **Parameters:**
83
+ - `kb_name` (required): Name for the knowledge base
84
+ - `file_url` (required): URL to the document (PDF/DOCX/DOC/TXT/MD)
85
+ - `description` (optional): Description
86
+ - `tag_name` (optional): Tag for categorization
24
87
 
25
- | 命令 | 功能 | 权限 |
26
- |------|------|------|
27
- | `/linkmind_help` | 使用帮助(根据身份显示不同内容) | 任何人 |
28
- | `/linkmind_claim <密钥>` | 绑定管理员身份 | 未绑定时任何人 |
29
- | `/linkmind_me` | 查看身份信息 | 任何人 |
30
- | `/linkmind_create <名称> <URL>` | 创建知识库并训练 | 仅管理员 |
31
- | `/linkmind_query <名称> <问题>` | 知识库问答 | 任何人 |
32
- | `/linkmind_share <KB名> <用户ID> <角色>` | 管理 KB 权限 | 仅管理员 |
33
- | `/linkmind_list` | 列出可访问的知识库 | 任何人 |
88
+ **Notes:**
89
+ - Requires **editor** or above permission
90
+ - Runs 2-10 minutes; polls progress internally
91
+ - Returns `kb_id` for subsequent queries
34
92
 
35
- ### `/linkmind_share` 用法
93
+ ### `faq_kb_query`
94
+
95
+ Ask a question against a trained knowledge base.
96
+
97
+ **When to use:**
98
+ - User asks a question and you know which KB to query
99
+ - User says "search the knowledge base for..."
100
+
101
+ **Parameters:**
102
+ - `kb_id` (required): Knowledge base ID
103
+ - `question` (required): The question
104
+ - `enable_polish` (optional): LLM-polished multi-FAQ answer
105
+ - `user_id`, `session_id` (optional): For tracking
106
+
107
+ **Notes:**
108
+ - Requires **viewer** or above permission
109
+ - KB must be trained (is_active=true)
110
+
111
+ ### `faq_kb_list`
112
+
113
+ List accessible knowledge bases.
114
+
115
+ **When to use:**
116
+ - User asks "what knowledge bases do I have?"
117
+ - You need to find a kb_id before querying
118
+
119
+ **Parameters:**
120
+ - `keyword` (optional): Search by name
121
+ - `tag_name` (optional): Filter by tag
122
+ - `page`, `page_size` (optional): Pagination
123
+
124
+ ## Typical Workflows
125
+
126
+ ### Workflow 1: First-time user (social media)
36
127
 
37
128
  ```
38
- /linkmind_share 客服知识库 123456789 viewer — 分享(只读)
39
- /linkmind_share 客服知识库 123456789 editor — 授予编辑权限
40
- /linkmind_share 客服知识库 123456789 revoke — 撤销权限
129
+ 1. faq_account_register(channel_type="telegram", channel_user_id="12345")
130
+ registers as viewer, API Key cached
131
+ 2. faq_kb_list()
132
+ → shows available knowledge bases
133
+ 3. faq_kb_query(kb_id="...", question="...")
134
+ → gets answer
41
135
  ```
42
136
 
43
- ## Typical Workflows
137
+ ### Workflow 2: Bot Owner sets up a new KB
138
+
139
+ ```
140
+ 1. faq_account_register(channel_type="telegram", channel_user_id="owner_id", role="admin")
141
+ → registers as admin
142
+ 2. faq_kb_create_and_train(kb_name="客服FAQ", file_url="https://...")
143
+ → creates and trains KB, returns kb_id
144
+ 3. faq_kb_query(kb_id="...", question="退款政策是什么?")
145
+ → verifies the KB works
146
+ ```
44
147
 
45
- ### 首次部署
148
+ ### Workflow 3: Owner grants access to a friend
46
149
 
47
150
  ```
48
- 1. 服务器启动,安装 Plugin,连接 Bot
49
- 2. 用户首次发送任意命令 自动展示密钥和绑定指引
50
- 3. /linkmind_claim <密钥> → 绑定成功,成为管理员
51
- 4. /linkmind_create 客服知识库 https://example.com/doc.pdf → 训练
52
- 5. /linkmind_query 客服知识库 如何退款? 查询
151
+ 1. (Friend) faq_account_register(channel_type="telegram", channel_user_id="friend_id")
152
+ friend registers as viewer
153
+ 2. (Owner) faq_account_manage(action="grant_role",
154
+ target_channel_user_id="friend_id", role="editor", kb_scope=["kb_abc"])
155
+ friend can now create/edit in kb_abc
53
156
  ```
54
157
 
55
- ### 普通用户使用
158
+ ### Workflow 4: Check permissions when denied
56
159
 
57
160
  ```
58
- 1. /linkmind_help查看可用功能
59
- 2. /linkmind_list → 查看可访问的知识库
60
- 3. /linkmind_query 客服知识库 问题 查询
161
+ 1. User tries faq_kb_create_and_train gets permission error
162
+ 2. faq_account_manage(action="my_info")
163
+ shows role=viewer, can only read
164
+ 3. Tell user: "你当前是 viewer 角色,只能查询。请联系管理员提升权限。"
61
165
  ```
62
166
 
63
167
  ## Important Notes
64
168
 
65
- - 首次使用发 `/linkmind_help` 即可了解所有功能
66
- - 服务器未绑定管理员时,所有命令会提示先完成绑定
67
- - 密钥会自动展示给第一个与 bot 对话的用户
68
- - 管理员创建的知识库默认私有,需通过 /linkmind_share 开放
69
- - 普通用户无法创建/删除知识库
169
+ - **Always register first**: Before any KB operation, ensure the user has an identity via `faq_account_register`.
170
+ - **Permission errors**: When a 403 error occurs, guide the user to check their role or contact the admin.
171
+ - **KB IDs are UUIDs**: e.g., `a1b2c3d4-e5f6-...`
172
+ - **API server**: `67.212.146.21:8999` by default.
173
+ - The `faq_kb_create_and_train` tool is long-running (minutes). Be patient.