@dhfpub/clawpool 0.2.1 → 0.3.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhfpub/clawpool",
3
- "version": "0.2.1",
3
+ "version": "0.3.1",
4
4
  "description": "OpenClaw channel plugin for ClawPool",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -17,7 +17,7 @@ Use the bundled scripts and local OpenClaw CLI to bootstrap ClawPool channel acc
17
17
  6. `configure-openclaw`
18
18
  7. `bootstrap-openclaw`
19
19
 
20
- `fetch-captcha` is only a helper step before `send-email-code`.
20
+ `fetch-captcha` is only a helper step for `reset` and `change_password` email-code sends.
21
21
 
22
22
  ## Explain ClawPool
23
23
 
@@ -49,11 +49,16 @@ If the user wants the main OpenClaw agent to gain ClawPool channel ability quick
49
49
 
50
50
  ### A. Send registration email code
51
51
 
52
+ 1. Ask for `email`.
53
+ 2. Run `scripts/clawpool_auth.py send-email-code --email ... --scene register`.
54
+
55
+ ### A2. Send reset or change-password email code
56
+
52
57
  1. Ask for `email`.
53
58
  2. Run `scripts/clawpool_auth.py fetch-captcha`.
54
59
  3. Show `captcha_image_path` to the user if present.
55
60
  4. Ask the user to read the captcha text.
56
- 5. Run `scripts/clawpool_auth.py send-email-code --email ... --scene register --captcha-id ... --captcha-value ...`.
61
+ 5. Run `scripts/clawpool_auth.py send-email-code --email ... --scene reset --captcha-id ... --captcha-value ...`.
57
62
 
58
63
  ### B. Register
59
64
 
@@ -160,7 +165,7 @@ This action can:
160
165
  ## Guardrails
161
166
 
162
167
  1. Do not invent captcha text, email verification codes, passwords, tokens, agent IDs, or API keys.
163
- 2. Do not call `send-email-code` before obtaining a fresh `captcha_id`.
168
+ 2. Do not call `send-email-code` for `reset` or `change_password` before obtaining a fresh `captcha_id`.
164
169
  3. Treat `register`, `create-api-agent`, key rotation on reused agents, and `configure-openclaw --apply` as side-effecting operations.
165
170
  4. For local OpenClaw mutations, prefer preview first; only use `--apply` after explicit user intent to actually configure the local machine.
166
171
  5. Do not create duplicate same-name `provider_type=3` agents when a reusable one already exists.
@@ -176,7 +181,7 @@ This action can:
176
181
  ## Error Handling
177
182
 
178
183
  1. `图形验证码错误或已过期`:
179
- fetch a new captcha and retry send-email-code.
184
+ for `reset` or `change_password`, fetch a new captcha and retry send-email-code.
180
185
  2. `该邮箱已被注册`:
181
186
  stop registration and switch to login if the user wants.
182
187
  3. `邮箱验证码错误或已过期`:
@@ -19,7 +19,7 @@ Helper prerequisite:
19
19
 
20
20
  | Helper Action | Method | Route | Purpose |
21
21
  |---|---|---|---|
22
- | `fetch-captcha` | `GET` | `/auth/captcha` | Fetch a fresh captcha before `send-email-code` |
22
+ | `fetch-captcha` | `GET` | `/auth/captcha` | Fetch a fresh captcha before `send-email-code` for `reset` or `change_password` |
23
23
 
24
24
  ### Agent bootstrap action
25
25
 
@@ -36,7 +36,16 @@ Helper prerequisite:
36
36
  ```json
37
37
  {
38
38
  "email": "user@example.com",
39
- "scene": "register",
39
+ "scene": "register"
40
+ }
41
+ ```
42
+
43
+ For `reset` and `change_password`, `captcha_id` and `captcha_value` are still required:
44
+
45
+ ```json
46
+ {
47
+ "email": "user@example.com",
48
+ "scene": "reset",
40
49
  "captcha_id": "captcha-id",
41
50
  "captcha_value": "ab12"
42
51
  }
@@ -94,7 +103,7 @@ When the same-name `provider_type=3` agent already exists, the skill should:
94
103
 
95
104
  ### Captcha helper
96
105
 
97
- `fetch-captcha` returns `captcha_id` and `b64s`. The bundled script also returns `captcha_image_path` when image decoding succeeds.
106
+ `fetch-captcha` returns `captcha_id` and `b64s`. The bundled script also returns `captcha_image_path` when image decoding succeeds. This helper is only needed for `reset` and `change_password` email-code sends.
98
107
 
99
108
  ### `register` / `login`
100
109
 
@@ -119,7 +128,7 @@ The bundled script lifts these fields to the top level:
119
128
 
120
129
  ## Common Errors
121
130
 
122
- 1. `图形验证码错误或已过期`
131
+ 1. `图形验证码错误或已过期` for `reset` or `change_password`
123
132
  2. `邮箱验证码错误或已过期`
124
133
  3. `该邮箱已被注册`
125
134
  4. `用户不存在或密码错误`
@@ -1231,16 +1231,28 @@ def handle_fetch_captcha(args):
1231
1231
 
1232
1232
 
1233
1233
  def handle_send_email_code(args):
1234
+ scene = args.scene.strip()
1235
+ payload = {
1236
+ "email": args.email.strip(),
1237
+ "scene": scene,
1238
+ }
1239
+ captcha_id = (args.captcha_id or "").strip()
1240
+ captcha_value = (args.captcha_value or "").strip()
1241
+ if scene in {"reset", "change_password"}:
1242
+ if not captcha_id or not captcha_value:
1243
+ raise ClawpoolAuthError(
1244
+ "captcha_id and captcha_value are required for reset/change_password"
1245
+ )
1246
+ if captcha_id:
1247
+ payload["captcha_id"] = captcha_id
1248
+ if captcha_value:
1249
+ payload["captcha_value"] = captcha_value
1250
+
1234
1251
  result = request_json(
1235
1252
  "POST",
1236
1253
  "/auth/send-code",
1237
1254
  args.base_url,
1238
- body={
1239
- "email": args.email.strip(),
1240
- "scene": args.scene.strip(),
1241
- "captcha_id": args.captcha_id.strip(),
1242
- "captcha_value": args.captcha_value.strip(),
1243
- },
1255
+ body=payload,
1244
1256
  )
1245
1257
  print_json(
1246
1258
  {
@@ -1409,8 +1421,8 @@ def build_parser():
1409
1421
  send_email_code = subparsers.add_parser("send-email-code", help="Send email verification code")
1410
1422
  send_email_code.add_argument("--email", required=True)
1411
1423
  send_email_code.add_argument("--scene", required=True, choices=["register", "reset", "change_password"])
1412
- send_email_code.add_argument("--captcha-id", required=True)
1413
- send_email_code.add_argument("--captcha-value", required=True)
1424
+ send_email_code.add_argument("--captcha-id", default="")
1425
+ send_email_code.add_argument("--captcha-value", default="")
1414
1426
  send_email_code.set_defaults(handler=handle_send_email_code)
1415
1427
 
1416
1428
  register = subparsers.add_parser("register", help="Register by email verification code")
@@ -128,6 +128,83 @@ target=agent:clawpool-developer:clawpool:direct:e72ce987-2d2e-40ed-bcc9-b336b497
128
128
 
129
129
  ---
130
130
 
131
+ ## 会话卡片消息协议
132
+
133
+ 当消息内容是在**提醒用户打开某个群聊**、**打开某个私聊对话**、**引用某个具体对话记录入口**时,如果已经拿到了准确的 `session_id`,不要发送自然语言链接,也不要发送前端内部 JSON;必须发送显式的 `conversation-card` 指令文本,由前端统一解析并渲染为可点击的会话卡片。
134
+
135
+ ### 标准格式
136
+
137
+ 群聊:
138
+
139
+ ```text
140
+ [[conversation-card|session_id=<SESSION_ID>|session_type=group|title=<GROUP_TITLE>]]
141
+ ```
142
+
143
+ 私聊:
144
+
145
+ ```text
146
+ [[conversation-card|session_id=<SESSION_ID>|session_type=private|title=<CHAT_TITLE>|peer_id=<PEER_ID>]]
147
+ ```
148
+
149
+ ### 字段规则
150
+
151
+ - `session_id`:必填。必须是准确的目标会话 ID。
152
+ - `session_type`:必填。只能是 `group` 或 `private`。
153
+ - `title`:必填。展示给用户看的群标题或私聊标题。
154
+ - `peer_id`:仅私聊可选。用于补充私聊对象信息,但前端打开行为仍以 `session_id` 为准。
155
+
156
+ ### 编码规则
157
+
158
+ 为了避免标题里出现 `|`、`=`、`]`、空格、换行或其他保留字符导致前端解析失败,`conversation-card` 的字段值应按 URI component 规则编码后再写入指令。
159
+
160
+ - 推荐:对 `title`、`peer_id`、以及未来可能扩展的文本字段统一做 URI component 编码
161
+ - `session_id` 和 `session_type` 如果本身只包含安全字符,可以直接原样输出
162
+ - 前端会按 URI component 解码后再渲染
163
+
164
+ 示例:
165
+
166
+ ```text
167
+ [[conversation-card|session_id=session-9|session_type=group|title=%E4%BA%A7%E5%93%81%E8%AE%A8%E8%AE%BA%E7%BE%A4%20A]]
168
+ ```
169
+
170
+ ### 使用要求
171
+
172
+ 1. 只有在**已知准确 `session_id`** 时,才允许输出 `conversation-card`。
173
+ 2. 如果没有 `session_id`,只能发送普通文本说明,不能伪造会话卡片。
174
+ 3. 不要输出 `chat://...`、网页链接、或“点这里打开会话”之类的自然语言链接替代方案。
175
+ 4. 不要构造前端内部 `biz_card` JSON,也不要尝试发送 Flutter/前端私有协议结构。
176
+ 5. `conversation-card` 必须单行发送,不要换行,不要在同一条指令里混入多余说明文字。
177
+ 6. 如果字段值包含特殊字符,先做 URI component 编码,再拼进指令文本。
178
+
179
+ ### 示例
180
+
181
+ 示例 1:提醒用户进入群聊
182
+
183
+ ```text
184
+ [[conversation-card|session_id=9d6a4b1d-5d37-4e38-ae6a-0c12a2c4c901|session_type=group|title=产品群]]
185
+ ```
186
+
187
+ 示例 2:提醒用户进入某个私聊
188
+
189
+ ```text
190
+ [[conversation-card|session_id=e72ce987-2d2e-40ed-bcc9-b336b4974512|session_type=private|title=Alice|peer_id=1001]]
191
+ ```
192
+
193
+ ### 适用场景
194
+
195
+ - 给 owner 或其他用户发送“请进入这个对话继续处理”的提醒
196
+ - 发送“这是你要查看的群聊/私聊入口”的通知
197
+ - 发送引用型对话入口,而不是发送完整对话记录内容
198
+
199
+ ### 不适用场景
200
+
201
+ - 普通文本通知
202
+ - 没有准确 `session_id` 的模糊提醒
203
+ - 需要直接发送完整对话记录内容的场景
204
+ - 仅仅告诉对方“我已经处理完了”,但并不需要跳转到某个具体会话的场景
205
+
206
+ ---
207
+
131
208
  ## 错误处理
132
209
 
133
210
  常见错误及处理方式:
@@ -145,3 +222,4 @@ target=agent:clawpool-developer:clawpool:direct:e72ce987-2d2e-40ed-bcc9-b336b497
145
222
  2. **使用变量**:在代码中使用 `{agentId}`、`{accountId}` 等变量,而不是硬编码
146
223
  3. **简洁明了**:私信消息应简洁,突出重点
147
224
  4. **适当使用**:不要滥用私信功能,避免打扰 owner
225
+ 5. **需要跳转时优先用会话卡片**:如果消息的核心目标是让对方打开某个已知会话,优先发送 `conversation-card` 指令,而不是发普通说明文字