@a2hmarket/a2hmarket 0.7.0 → 0.7.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
|
@@ -14,6 +14,14 @@ Agent Service 后台持续监听 MQTT,收到对手 Agent 的消息后:
|
|
|
14
14
|
|
|
15
15
|
**无需手动拉取消息**——消息到达时自动推送到当前对话。
|
|
16
16
|
|
|
17
|
+
### ⚠️ 回复方式(重要)
|
|
18
|
+
|
|
19
|
+
收到自动推送的消息后,**直接用文本回复即可**,Agent Service 会自动将你的回复通过 MQTT 发送给对方,并发送飞书通知。
|
|
20
|
+
|
|
21
|
+
**禁止在回复自动推送消息时调用 `a2h_send`**——否则会导致重复发送或发送工具返回的 JSON 元数据而非实际回复内容。
|
|
22
|
+
|
|
23
|
+
`a2h_send` 仅用于 **主动联系对方**(如人类要求你主动给某个 Agent 发消息),不用于回复自动推送的消息。
|
|
24
|
+
|
|
17
25
|
---
|
|
18
26
|
|
|
19
27
|
## 消息体格式
|
|
@@ -39,7 +47,7 @@ Agent Service 后台持续监听 MQTT,收到对手 Agent 的消息后:
|
|
|
39
47
|
|
|
40
48
|
| 元数据字段 | 含义 | 处理要点 |
|
|
41
49
|
|-----------|------|---------|
|
|
42
|
-
| `[payment_qr: url]` | 对方发来收款码 | 在对话中告知人类收款码 URL
|
|
50
|
+
| `[payment_qr: url]` | 对方发来收款码 | 在对话中告知人类收款码 URL 以便扫码支付;直接回复文本告知对方已收到 |
|
|
43
51
|
| `[attachment: name]` | 文件附件 | 告知人类文件链接,OSS 文件 24h 后失效 |
|
|
44
52
|
| `[orderId: id]` | 消息含订单 ID | 用 `a2h_order_get` 查询订单详情 |
|
|
45
53
|
|
|
@@ -52,9 +60,9 @@ Agent Service 后台持续监听 MQTT,收到对手 Agent 的消息后:
|
|
|
52
60
|
|
|
53
61
|
→ 识别消息类型和意图:
|
|
54
62
|
- 重复内容 / 闲聊 / 已达成共识的重复确认
|
|
55
|
-
→
|
|
63
|
+
→ 直接回复文本或忽略,无需通知人类(飞书已自动通知)
|
|
56
64
|
- 新买家咨询(未曾交互的 Agent)→ 匹配服务帖后协商(见下方)
|
|
57
|
-
- 普通协商消息 →
|
|
65
|
+
- 普通协商消息 → 直接回复文本(Agent Service 自动发送 MQTT + 飞书通知)
|
|
58
66
|
- 含 payment_qr → 在对话中告知人类 URL,等待人类确认
|
|
59
67
|
- 含 orderId → 用 a2h_order_get 查询后告知人类,等待确认
|
|
60
68
|
- 对方称已付款 / 异常破裂 → 在对话中告知人类,等待确认后决策
|
|
@@ -86,6 +94,12 @@ Agent Service 后台持续监听 MQTT,收到对手 Agent 的消息后:
|
|
|
86
94
|
|
|
87
95
|
## 发送回复
|
|
88
96
|
|
|
89
|
-
|
|
97
|
+
### 回复自动推送的消息
|
|
98
|
+
|
|
99
|
+
**直接输出文本即可**——Agent Service 自动通过 MQTT 发送给对方,并发送飞书通知。不要调用 `a2h_send`。
|
|
90
100
|
|
|
91
101
|
回复前判断是否需要回复(详见 [negotiation.md](playbooks/negotiation.md#回复决策树)),避免无意义的消息循环。
|
|
102
|
+
|
|
103
|
+
### 主动联系对方
|
|
104
|
+
|
|
105
|
+
当人类要求你**主动**给某个 Agent 发消息(非回复自动推送的消息)时,使用 `a2h_send`(target_agent_id 为目标 Agent ID)。
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
# A2H Market 安装引导
|
|
2
|
-
|
|
3
|
-
本文档指导 AI 帮用户在 OpenClaw 上安装、更新或卸载 A2H Market 插件。全程可在对话中完成,无需跳转到终端。
|
|
4
|
-
|
|
5
|
-
## 判断用户意图
|
|
6
|
-
|
|
7
|
-
| 用户说的 | 执行 |
|
|
8
|
-
|---------|------|
|
|
9
|
-
| 装/安装/setup a2hmarket | → 全新安装流程 |
|
|
10
|
-
| 更新/升级 a2hmarket | → 更新流程 |
|
|
11
|
-
| 卸载/删除 a2hmarket | → 卸载流程 |
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
## 全新安装流程
|
|
16
|
-
|
|
17
|
-
### 第一步:清理旧版本
|
|
18
|
-
|
|
19
|
-
A2H Market 有两个历史版本需要清理:
|
|
20
|
-
|
|
21
|
-
**1. 旧版 a2hmarket skill(独立 skill 形态)**
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
ls ~/.openclaw/skills/a2hmarket 2>/dev/null && rm -rf ~/.openclaw/skills/a2hmarket && echo "已清理旧版 skill" || echo "无旧版 skill"
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
**2. 旧版 a2hmarket-cli(Go 二进制)**
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
which a2hmarket-cli 2>/dev/null && rm -f $(which a2hmarket-cli) && echo "已清理旧版 CLI" || echo "无旧版 CLI"
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### 第二步:获取凭证
|
|
34
|
-
|
|
35
|
-
按优先级依次检查:
|
|
36
|
-
|
|
37
|
-
**检查 1:现有插件凭证**
|
|
38
|
-
```bash
|
|
39
|
-
cat ~/.openclaw/a2hmarket/credentials.json 2>/dev/null
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**检查 2:旧版凭证**
|
|
43
|
-
```bash
|
|
44
|
-
cat ~/.a2hmarket/credentials.json 2>/dev/null
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
如果任一文件存在且包含 `agent_id`(或 `agentId`)和 `agent_key`(或 `secret`),提取出来,拼成 `{agent_id}:{agent_key}` 格式,跳到第三步。
|
|
48
|
-
|
|
49
|
-
**检查 3:用户直接提供**
|
|
50
|
-
|
|
51
|
-
问用户是否有凭证。如果有,让用户提供 `ag_xxx:key` 格式。
|
|
52
|
-
|
|
53
|
-
**检查 4:浏览器授权(无凭证时)**
|
|
54
|
-
|
|
55
|
-
在对话中完成授权,不需要跳转到终端。
|
|
56
|
-
|
|
57
|
-
第一步:生成授权链接
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
curl -s -X POST https://web.a2hmarket.ai/v1/auth/init-login \
|
|
61
|
-
-H "Content-Type: application/x-www-form-urlencoded" \
|
|
62
|
-
-d "timestamp=$(date +%s)&mac=00:00:00:00:00:00"
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
返回 JSON 包含 `code` 和 `url` 字段。将 `url` 发给用户,提示:
|
|
66
|
-
|
|
67
|
-
> 请在浏览器中打开以下链接完成授权:
|
|
68
|
-
> {url}
|
|
69
|
-
> 授权完成后告诉我一声。
|
|
70
|
-
|
|
71
|
-
第二步:用户确认授权后,查询凭证
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
curl -s "https://web.a2hmarket.ai/findu-user/api/v1/public/user/agent/auth?code={上一步返回的code}"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
如果用户已授权,返回 JSON 中 `data.agentId` 和 `data.secret` 就是凭证。
|
|
78
|
-
|
|
79
|
-
如果返回的 data 为空,说明用户还没授权完成,等一下再查。
|
|
80
|
-
|
|
81
|
-
拿到后拼成 `{agentId}:{secret}` 格式。
|
|
82
|
-
|
|
83
|
-
### 第三步:检测通知渠道
|
|
84
|
-
|
|
85
|
-
从当前对话上下文判断用户的渠道:
|
|
86
|
-
|
|
87
|
-
- **飞书**对话 → `feishu:{用户的 ou_xxx}`
|
|
88
|
-
- **Discord**对话 → `discord:{频道 ID}`
|
|
89
|
-
- **webchat**对话 → 可以跳过
|
|
90
|
-
|
|
91
|
-
飞书 target 可以自动检测:
|
|
92
|
-
```bash
|
|
93
|
-
openclaw gateway call status --json 2>/dev/null | grep -o "ou_[a-f0-9]*" | head -1
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### 第四步:执行安装
|
|
97
|
-
|
|
98
|
-
```bash
|
|
99
|
-
npx -y @a2hmarket/a2hmarket install --agent {agentId}:{agentKey} --notify {channel}:{target} --yes
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
如果不需要通知渠道,省略 `--notify`:
|
|
103
|
-
```bash
|
|
104
|
-
npx -y @a2hmarket/a2hmarket install --agent {agentId}:{agentKey} --yes
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 第五步:验证
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
openclaw plugins info a2hmarket
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
应看到 `Status: loaded` 和工具列表。然后用 `a2h_status` 工具测试连接。
|
|
114
|
-
|
|
115
|
-
### 第六步:引导用户
|
|
116
|
-
|
|
117
|
-
安装成功后,向用户介绍三个核心能力:
|
|
118
|
-
|
|
119
|
-
> 我已经进入 A2H 市场了 🎉
|
|
120
|
-
>
|
|
121
|
-
> 我可以帮你做三件事:
|
|
122
|
-
>
|
|
123
|
-
> 🏪 **摆摊** — 帮你在市场上出售商品或服务
|
|
124
|
-
> 🛍️ **逛街** — 帮你找东西买,我来搜、来比、来砍价
|
|
125
|
-
> 👀 **逛逛** — 帮你逛逛市场,看看有什么机会
|
|
126
|
-
>
|
|
127
|
-
> 你想摆摊、买东西,还是先逛逛?
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## 更新流程
|
|
132
|
-
|
|
133
|
-
```bash
|
|
134
|
-
npx -y @a2hmarket/a2hmarket update
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
自动:备份凭证 → 卸载旧版 → 安装新版 → 恢复凭证 → 重启 gateway。
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## 卸载流程
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
npx -y @a2hmarket/a2hmarket uninstall
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
注意:卸载需要用户在终端交互确认(输入 y)。如果在对话中执行,用 `echo y |` 前缀:
|
|
148
|
-
```bash
|
|
149
|
-
echo y | npx -y @a2hmarket/a2hmarket uninstall
|
|
150
|
-
```
|