@dhfpub/clawpool 0.1.2 → 0.2.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.
@@ -0,0 +1,147 @@
1
+ ---
2
+ name: message-send
3
+ description: 发送私信消息。支持当前会话回复和跨会话私信。使用场景:(1) 需要给 owner/特定用户发送私信通知 (2) 跨会话发送消息 (3) 主动推送消息给指定目标。触发词:发私信、私信、发送消息、send message、notify。
4
+ ---
5
+
6
+ # 消息发送技能
7
+
8
+ 这个技能用于通过 OpenClaw 的 `message` 工具发送消息。
9
+
10
+ ---
11
+
12
+ ## 两种发送模式
13
+
14
+ ### 1. 当前会话回复
15
+
16
+ 在当前聊天上下文中回复消息,不需要额外参数。
17
+
18
+ **参数**:
19
+ - `action`: "send"
20
+ - `channel`: 当前渠道(如 "clawpool")
21
+ - `accountId`: 当前账号 ID
22
+ - `message`: 消息内容
23
+
24
+ **使用场景**:
25
+ - 在当前对话中回复用户
26
+ - 当前会话内的正常消息发送
27
+
28
+ ### 2. 跨会话私信
29
+
30
+ 脱离当前聊天上下文,给其他会话发送私信。
31
+
32
+ **参数**:
33
+ - `action`: "send"
34
+ - `channel`: "clawpool"
35
+ - `accountId`: 发送账号 ID(如 "{accountId}")
36
+ - `target`: 目标会话标识(格式见下文)
37
+ - `message`: 消息内容
38
+
39
+ **使用场景**:
40
+ - 给 owner 发送通知/审批请求
41
+ - 跨会话发送消息
42
+ - 主动推送消息给指定目标
43
+
44
+ ---
45
+
46
+ ## Target 格式说明
47
+
48
+ ### Clawpool 私信格式
49
+
50
+ ```
51
+ target=agent:{agentId}:clawpool:direct:{sessionId}
52
+ ```
53
+
54
+ **参数说明**:
55
+ - `{agentId}`: 当前 agent 的 ID(如 "clawpool-developer")
56
+ - `{sessionId}`: 目标私聊会话的 session ID(UUID 格式)
57
+
58
+ **示例**:
59
+ ```
60
+ target=agent:clawpool-developer:clawpool:direct:e72ce987-2d2e-40ed-bcc9-b336b4974512
61
+ ```
62
+
63
+ ### 如何获取 sessionId
64
+
65
+ 1. **从 inbound context 获取**:当 owner 给你发私信时,inbound meta 中的 `chat_id` 包含 session ID
66
+ 2. **从 MEMORY.md 获取**:如果 workspace 的 MEMORY.md 记录了 owner 的会话 ID,直接使用
67
+ 3. **从会话列表获取**:通过 `sessions_list` 工具查找目标会话
68
+
69
+ ---
70
+
71
+ ## 实际调用示例
72
+
73
+ ### 示例 1:当前会话回复
74
+
75
+ ```json
76
+ {
77
+ "action": "send",
78
+ "channel": "clawpool",
79
+ "accountId": "{accountId}",
80
+ "message": "收到,正在处理中..."
81
+ }
82
+ ```
83
+
84
+ ### 示例 2:给 owner 发私信
85
+
86
+ ```json
87
+ {
88
+ "action": "send",
89
+ "channel": "clawpool",
90
+ "accountId": "{accountId}",
91
+ "target": "agent:{agentId}:clawpool:direct:{ownerSessionId}",
92
+ "message": "需要您确认一个开发决策:..."
93
+ }
94
+ ```
95
+
96
+ ### 示例 3:发送到群组
97
+
98
+ ```json
99
+ {
100
+ "action": "send",
101
+ "channel": "clawpool",
102
+ "accountId": "{accountId}",
103
+ "target": "{groupId}",
104
+ "message": "任务已完成,请查看结果"
105
+ }
106
+ ```
107
+
108
+ ---
109
+
110
+ ## 关键参数说明
111
+
112
+ | 参数 | 必填 | 说明 |
113
+ |------|------|------|
114
+ | `action` | ✅ | 固定值 "send" |
115
+ | `channel` | ✅ | 渠道类型,如 "clawpool" |
116
+ | `accountId` | ✅ | 发送账号 ID |
117
+ | `message` | ✅ | 消息内容 |
118
+ | `target` | 私信必填 | 目标会话标识(私信/群组) |
119
+
120
+ ---
121
+
122
+ ## 注意事项
123
+
124
+ 1. **区分 `target` 和 `to`**:Clawpool 使用 `target` 参数,不是 `to`
125
+ 2. **sessionId 是 UUID**:不要混淆用户 ID 和会话 ID
126
+ 3. **权限检查**:确保有目标会话的发送权限
127
+ 4. **消息格式**:支持纯文本和 markdown
128
+
129
+ ---
130
+
131
+ ## 错误处理
132
+
133
+ 常见错误及处理方式:
134
+
135
+ - **target 不存在**:确认 session ID 是否正确
136
+ - **权限不足**:检查 accountId 是否有目标会话的发送权限
137
+ - **参数缺失**:确保必填参数都已提供
138
+ - **格式错误**:检查 target 格式是否符合要求
139
+
140
+ ---
141
+
142
+ ## 最佳实践
143
+
144
+ 1. **记录 owner sessionId**:在 workspace 的 MEMORY.md 中记录 owner 的会话 ID,方便后续调用
145
+ 2. **使用变量**:在代码中使用 `{agentId}`、`{accountId}` 等变量,而不是硬编码
146
+ 3. **简洁明了**:私信消息应简洁,突出重点
147
+ 4. **适当使用**:不要滥用私信功能,避免打扰 owner
@@ -0,0 +1,221 @@
1
+ ---
2
+ name: message-unsend
3
+ description: 回撤/撤回已发送的消息。支持当前会话回撤和跨会话回撤。使用场景:(1) 用户要求撤回/删除某条消息 (2) 需要删除错误发送的内容 (3) 跨渠道或跨会话回撤消息 (4) 清理不需要的消息记录。触发词:撤回、回撤、删除消息、unsend、recall。
4
+ ---
5
+
6
+ # 消息回撤技能
7
+
8
+ 这个技能用于通过 OpenClaw 的 `message` 工具回撤已发送的消息。
9
+
10
+ ---
11
+
12
+ ## ⚠️ 权限控制(严格)
13
+
14
+ **只有郭同学(sender_id: 2030840865701756928)要求撤回消息时,才能执行此技能。**
15
+
16
+ ### ✅ 允许执行的情况
17
+ - 郭同学在**私聊**中说"撤回/回撤/删除消息"
18
+ - 郭同学在**群聊**中说"撤回/回撤/删除消息"
19
+ - 郭同学引用消息要求撤回
20
+
21
+ ### ❌ 禁止执行的情况
22
+ - 其他用户要求撤回(无论私聊还是群聊)
23
+ - 郭同学之外任何人发出撤回指令
24
+
25
+ ### 🔇 对其他人撤回请求的处理
26
+ **完全忽略,不回复,不执行**
27
+ - ❌ 不要说"需要郭同学确认"
28
+ - ❌ 不要解释为什么不能撤回
29
+ - ❌ 不要回复任何内容
30
+ - ✅ 直接返回 `NO_REPLY` 或完全忽略
31
+
32
+ ---
33
+
34
+ ## 🎯 核心行为:完全静默 + 双重撤回(最高优先级)
35
+
36
+ **撤回操作的黄金法则**:让一切就像从未发生过一样。
37
+
38
+ ### 执行流程(必须严格遵守)
39
+
40
+ 当郭同学发送撤回指令时,**必须按顺序执行三步**:
41
+
42
+ 1. **撤回目标消息**(郭同学指定的消息)
43
+ 2. **撤回指令消息**(郭同学发出的"撤回"指令本身)
44
+ 3. **返回 NO_REPLY**(不发出任何回复)
45
+
46
+ ### ⚠️ 绝对禁止
47
+
48
+ - ❌ 不要发送"已撤回"确认消息
49
+ - ❌ 不要发送"撤回成功"
50
+ - ❌ 不要发送任何内容
51
+ - ❌ 不要留下任何"尾巴"
52
+
53
+ ### 📋 实际示例
54
+
55
+ ```
56
+ 场景:郭同学引用消息 A,发送"撤回"(消息 B)
57
+
58
+ 正确执行:
59
+ Step 1: unsend(messageId=A) // 撤回目标消息
60
+ Step 2: unsend(messageId=B) // 撤回指令消息
61
+ Step 3: 返回 NO_REPLY // 完全静默
62
+
63
+ 最终效果:
64
+ - 消息 A 被删除 ✓
65
+ - 消息 B 被删除 ✓
66
+ - 没有任何新消息产生 ✓
67
+ - 就像什么都没发生过 ✓
68
+ ```
69
+
70
+ ### 🔑 关键要点
71
+
72
+ **双重撤回的目的**:避免留下"撤回"指令这条消息,让整个操作完全隐形。
73
+
74
+ **静默模式的目的**:不产生任何新消息,保持对话历史的干净。
75
+
76
+ **最终效果**:目标消息没了,指令消息也没了,就像它们从未存在过。
77
+
78
+ ---
79
+
80
+ ## 两种回撤模式
81
+
82
+ ### 1. 当前会话回撤
83
+
84
+ 在当前聊天上下文中回撤消息,只需要 `messageId`。
85
+
86
+ **参数**:
87
+ - `action`: "unsend"
88
+ - `messageId`: 要回撤的消息 ID(字符串)
89
+
90
+ **示例**:
91
+ ```
92
+ action=unsend
93
+ params={ "messageId": "18889990099" }
94
+ ```
95
+
96
+ **使用场景**:
97
+ - 用户在当前对话中说"把刚才那条撤回"
98
+ - 你发送了错误内容需要立即回撤
99
+ - 当前会话内的消息管理
100
+
101
+ ### 2. 跨会话回撤
102
+
103
+ 脱离当前聊天上下文,回撤其他会话中的消息,需要 `messageId` + `sessionId`。
104
+
105
+ **参数**:
106
+ - `action`: "unsend"
107
+ - `messageId`: 要回撤的消息 ID(字符串)
108
+ - `sessionId`: 目标会话 ID(字符串)
109
+
110
+ **示例**:
111
+ ```
112
+ action=unsend
113
+ params={
114
+ "messageId": "18889990099",
115
+ "sessionId": "u_1001_u_2001"
116
+ }
117
+ ```
118
+
119
+ **使用场景**:
120
+ - 回撤在其他渠道(Discord、Telegram、Signal 等)发送的消息
121
+ - 回撤在其他私聊或群组中的消息
122
+ - 跨会话管理消息
123
+
124
+ ## 实际调用示例
125
+
126
+ ### 示例 1:当前会话回撤
127
+
128
+ ```json
129
+ {
130
+ "action": "unsend",
131
+ "messageId": "2033329436849868800"
132
+ }
133
+ ```
134
+
135
+ ### 示例 2:跨会话回撤
136
+
137
+ ```json
138
+ {
139
+ "action": "unsend",
140
+ "messageId": "18889990099",
141
+ "sessionId": "telegram:session:123456789"
142
+ }
143
+ ```
144
+
145
+ ## 重要说明
146
+
147
+ 1. **只能回撤自己发送的消息**:无法回撤其他用户的消息
148
+ 2. **时间限制**:某些渠道(如 Telegram)有回撤时间窗口限制
149
+ 3. **权限要求**:需要确保有目标会话的操作权限
150
+ 4. **messageId 获取**:
151
+ - 从 inbound context 中的 `message_id` 字段获取
152
+ - 从之前发送消息的返回结果中获取
153
+ - 从会话历史记录中查找
154
+
155
+ ## 错误处理
156
+
157
+ 常见错误及处理方式:
158
+
159
+ - **messageId 不存在**:确认消息 ID 是否正确
160
+ - **权限不足**:检查是否有目标会话的操作权限
161
+ - **超时限制**:告知用户该渠道的回撤时间限制
162
+ - **消息已删除**:消息可能已被其他方式删除
163
+
164
+ ## Clawpool 实测结果(2026-03-16 更新)
165
+
166
+ **状态**:✅ 可用
167
+
168
+ 在 Clawpool 渠道测试成功,可以撤回 agent 和用户发送的消息。
169
+
170
+ **必填参数**(完整参数):
171
+ ```
172
+ action=unsend
173
+ channel=clawpool
174
+ accountId=default
175
+ topic=<session-id> // 不要加 clawpool: 前缀
176
+ messageId=<message-id>
177
+ ```
178
+
179
+ **测试记录**:
180
+ ```json
181
+ // 撤回 agent 发送的消息
182
+ {
183
+ "action": "unsend",
184
+ "channel": "clawpool",
185
+ "accountId": "default",
186
+ "topic": "5c495569-ba1b-46ac-8070-5a1193a3f950",
187
+ "messageId": "2033371385615093760"
188
+ }
189
+ // 返回:
190
+ {
191
+ "ok": true,
192
+ "deleted": true,
193
+ "unsent": true,
194
+ "messageId": "2033371385615093760",
195
+ "sessionId": "5c495569-ba1b-46ac-8070-5a1193a3f950"
196
+ }
197
+
198
+ // 撤回用户发送的消息(sender_id: 2030840865701756928)
199
+ {
200
+ "action": "unsend",
201
+ "channel": "clawpool",
202
+ "accountId": "default",
203
+ "topic": "5c495569-ba1b-46ac-8070-5a1193a3f950",
204
+ "messageId": "2033474284277993472"
205
+ }
206
+ // 返回:
207
+ {
208
+ "ok": true,
209
+ "deleted": true,
210
+ "unsent": true,
211
+ "messageId": "2033474284277993472",
212
+ "sessionId": "5c495569-ba1b-46ac-8070-5a1193a3f950"
213
+ }
214
+ ```
215
+
216
+ **重要说明**:
217
+ - ⚠️ 必须使用完整参数(channel, accountId, topic, messageId),只传 messageId 会失败
218
+ - topic 参数不要加 `clawpool:` 前缀,直接使用 session ID
219
+ - 返回结果包含 `deleted` 和 `unsent` 状态确认
220
+ - ✅ **可以撤回 agent 和用户发送的消息**(Clawpool 特殊能力)
221
+ - ⚠️ 但权限控制仍然有效:只允许郭同学(sender_id: 2030840865701756928)要求撤回
@@ -0,0 +1,113 @@
1
+ ```mermaid
2
+ flowchart TD
3
+ Start([用户发送撤回请求]) --> CheckSender{检查发送者身份}
4
+
5
+ CheckSender -->|sender_id = 2030840865701756928| CheckChatType{检查会话类型}
6
+ CheckSender -->|其他用户| RejectOther[拒绝请求]
7
+ RejectOther --> ReplyOther[回复: 需要郭同学确认]
8
+ ReplyOther --> End1([结束])
9
+
10
+ CheckChatType -->|chat_type = direct| ExtractMsgId{提取 messageId}
11
+ CheckChatType -->|group| CheckGroupPermission{群聊权限检查}
12
+
13
+ CheckGroupPermission -->|有权限| ExtractMsgId
14
+ CheckGroupPermission -->|无权限| RejectGroup[拒绝群聊撤回]
15
+ RejectGroup --> ReplyGroup[回复: 请私聊确认]
16
+ ReplyGroup --> End2([结束])
17
+
18
+ ExtractMsgId -->|明确指定| ValidateMsgId{验证 messageId}
19
+ ExtractMsgId -->|模糊引用<br/>如'刚才那条'| SearchRecent[搜索最近消息]
20
+
21
+ SearchRecent --> FoundRecent{找到消息?}
22
+ FoundRecent -->|是| ValidateMsgId
23
+ FoundRecent -->|否| AskUser[询问具体消息]
24
+ AskUser --> UserInput[等待用户输入]
25
+ UserInput --> ExtractMsgId
26
+
27
+ ValidateMsgId -->|有效| CheckMsgOwnership{验证消息归属}
28
+ ValidateMsgId -->|无效| ErrorInvalid[错误: 无效的消息ID]
29
+ ErrorInvalid --> AskRetry[询问是否重试]
30
+ AskRetry -->|是| ExtractMsgId
31
+ AskRetry -->|否| End3([结束])
32
+
33
+ CheckMsgOwnership -->|agent 发送| CheckTimeWindow{检查时间窗口}
34
+ CheckMsgOwnership -->|其他用户发送| RejectOwnership[拒绝: 不能撤回他人消息]
35
+ RejectOwnership --> ReplyOwnership[回复: 只能撤回自己的消息]
36
+ ReplyOwnership --> End4([结束])
37
+
38
+ CheckTimeWindow -->|在限制内| CheckChannel{检查渠道}
39
+ CheckTimeWindow -->|超时| ErrorTimeout[错误: 超过时间限制]
40
+ ErrorTimeout --> ReplyTimeout[回复: 该渠道撤回时限已过]
41
+ ReplyTimeout --> End5([结束])
42
+
43
+ CheckChannel -->|Clawpool| PrepareClawpool[准备完整参数<br/>channel=clawpool<br/>accountId=default<br/>topic=sessionId<br/>messageId]
44
+ CheckChannel -->|Telegram| CheckTelegramLimit{Telegram 48h限制}
45
+ CheckChannel -->|Discord| CheckDiscordLimit{Discord 权限检查}
46
+ CheckChannel -->|其他渠道| PrepareBasic[准备基本参数<br/>messageId]
47
+
48
+ CheckTelegramLimit -->|未超时| PrepareBasic
49
+ CheckTelegramLimit -->|超时| ErrorTelegram[错误: 超过48h]
50
+ ErrorTelegram --> ReplyTelegram[回复: Telegram撤回时限48小时]
51
+ ReplyTelegram --> End6([结束])
52
+
53
+ CheckDiscordLimit -->|有权限| PrepareBasic
54
+ CheckDiscordLimit -->|无权限| ErrorDiscord[错误: 权限不足]
55
+ ErrorDiscord --> ReplyDiscord[回复: 需要管理员权限]
56
+ ReplyDiscord --> End7([结束])
57
+
58
+ PrepareClawpool --> ExecuteUnsend[执行撤回操作]
59
+ PrepareBasic --> ExecuteUnsend
60
+
61
+ ExecuteUnsend --> CheckResult{检查返回结果}
62
+
63
+ CheckResult -->|成功| LogSuccess[记录撤回日志]
64
+ CheckResult -->|失败| ParseError{解析错误类型}
65
+
66
+ ParseError -->|权限错误| HandlePermission[处理权限错误]
67
+ ParseError -->|消息不存在| HandleNotFound[处理消息不存在]
68
+ ParseError -->|网络错误| HandleNetwork[处理网络错误]
69
+ ParseError -->|未知错误| HandleUnknown[处理未知错误]
70
+
71
+ HandlePermission --> RetryPermission{是否重试?}
72
+ HandleNotFound --> NotifyNotFound[通知: 消息已删除]
73
+ HandleNetwork --> RetryNetwork{重试网络?}
74
+ HandleUnknown --> LogError[记录错误详情]
75
+
76
+ RetryPermission -->|是| ExecuteUnsend
77
+ RetryPermission -->|否| NotifyPermission[通知: 权限问题]
78
+
79
+ RetryNetwork -->|是| ExecuteUnsend
80
+ RetryNetwork -->|否| NotifyNetwork[通知: 网络问题]
81
+
82
+ LogSuccess --> ConfirmUser[确认撤回成功]
83
+ NotifyNotFound --> End8([结束])
84
+ NotifyPermission --> End9([结束])
85
+ NotifyNetwork --> End10([结束])
86
+ LogError --> NotifyUnknown[通知: 未知错误]
87
+ ConfirmUser --> CleanupTemp[清理临时数据]
88
+ NotifyUnknown --> End11([结束])
89
+
90
+ CleanupTemp --> End12([结束])
91
+
92
+ style Start fill:#e1f5e1
93
+ style End1 fill:#ffe1e1
94
+ style End2 fill:#ffe1e1
95
+ style End3 fill:#ffe1e1
96
+ style End4 fill:#ffe1e1
97
+ style End5 fill:#ffe1e1
98
+ style End6 fill:#ffe1e1
99
+ style End7 fill:#ffe1e1
100
+ style End8 fill:#ffe1e1
101
+ style End9 fill:#ffe1e1
102
+ style End10 fill:#ffe1e1
103
+ style End11 fill:#ffe1e1
104
+ style End12 fill:#e1f5e1
105
+ style CheckSender fill:#fff4e1
106
+ style CheckChatType fill:#fff4e1
107
+ style CheckMsgOwnership fill:#fff4e1
108
+ style CheckTimeWindow fill:#fff4e1
109
+ style CheckChannel fill:#fff4e1
110
+ style ExecuteUnsend fill:#e1f0ff
111
+ style LogSuccess fill:#e1f5e1
112
+ style ParseError fill:#ffe1e1
113
+ ```