@a2hmarket/a2hmarket 0.5.1 → 0.5.3
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 +1 -1
- package/skills/a2hmarket/SKILL.md +2 -0
- package/src/agent-service.ts +15 -1
- package/src/tools/order.ts +3 -1
- package/src/tools/payment.ts +6 -2
package/package.json
CHANGED
|
@@ -66,6 +66,8 @@ A2H Market 是一个人类和 AI Agent 都可以使用的 AI 交易市场。你
|
|
|
66
66
|
1. **直接调用工具** — 使用 `a2h_*` 工具完成任务,不要用 web search
|
|
67
67
|
2. **用中文回复** — 除非用户用其他语言
|
|
68
68
|
3. **搜索要灵活** — 精确关键词没结果时,尝试更宽泛的词
|
|
69
|
+
4. **消息元数据** — 收到的消息末尾可能附带 `[orderId: xxx]` 等元数据,用于关联订单
|
|
70
|
+
5. **查询支付** — 用 `a2h_payment_status`(传 order_id)查询支付状态;用 `a2h_order_get`(传 order_id)查询订单详情
|
|
69
71
|
4. **按需读取 Playbook** — 进入具体场景时再读对应的操作剧本
|
|
70
72
|
|
|
71
73
|
## 场景路由:读哪个 Playbook
|
package/src/agent-service.ts
CHANGED
|
@@ -138,6 +138,20 @@ export async function startAgentService(ctx: AgentServiceContext): Promise<void>
|
|
|
138
138
|
// ② Dispatch to OpenClaw Agent via Channel Plugin SDK
|
|
139
139
|
// Agent has full access to a2h_* tools
|
|
140
140
|
// Session is per-peer: agent:main:a2hmarket:direct:{senderId}
|
|
141
|
+
|
|
142
|
+
// Build enriched body with structured context from payload
|
|
143
|
+
let enrichedBody = event.text;
|
|
144
|
+
const meta: string[] = [];
|
|
145
|
+
if (event.payload.orderId) meta.push(`[orderId: ${event.payload.orderId}]`);
|
|
146
|
+
if (event.payload.payment_qr) meta.push(`[payment_qr: ${event.payload.payment_qr}]`);
|
|
147
|
+
if (event.payload.attachment) {
|
|
148
|
+
const att = event.payload.attachment as Record<string, unknown>;
|
|
149
|
+
meta.push(`[attachment: ${att.name ?? att.url ?? "file"}]`);
|
|
150
|
+
}
|
|
151
|
+
if (meta.length > 0) {
|
|
152
|
+
enrichedBody = `${event.text}\n\n--- 消息元数据 ---\n${meta.join("\n")}`;
|
|
153
|
+
}
|
|
154
|
+
|
|
141
155
|
try {
|
|
142
156
|
await dispatchInboundDirectDmWithRuntime({
|
|
143
157
|
cfg: ctx.cfg,
|
|
@@ -150,7 +164,7 @@ export async function startAgentService(ctx: AgentServiceContext): Promise<void>
|
|
|
150
164
|
senderAddress: `a2hmarket:${event.senderId}`,
|
|
151
165
|
recipientAddress: `a2hmarket:${creds.agentId}`,
|
|
152
166
|
conversationLabel: event.senderId,
|
|
153
|
-
rawBody:
|
|
167
|
+
rawBody: enrichedBody,
|
|
154
168
|
messageId: event.messageId,
|
|
155
169
|
timestamp: Date.now(),
|
|
156
170
|
commandAuthorized: true,
|
package/src/tools/order.ts
CHANGED
|
@@ -71,7 +71,9 @@ export function registerOrderTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
71
71
|
required: ["order_id"],
|
|
72
72
|
},
|
|
73
73
|
execute: async (params: Record<string, unknown>) => {
|
|
74
|
-
const
|
|
74
|
+
const orderId = (params.order_id ?? params.orderId) as string;
|
|
75
|
+
if (!orderId) throw new Error("order_id is required");
|
|
76
|
+
const apiPath = `/findu-trade/api/v1/orders/${orderId}/detail`;
|
|
75
77
|
const data = await client.getJSON<Record<string, unknown>>(apiPath);
|
|
76
78
|
return { result: JSON.stringify(data, null, 2) };
|
|
77
79
|
},
|
package/src/tools/payment.ts
CHANGED
|
@@ -67,8 +67,10 @@ export function registerPaymentTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
67
67
|
required: ["order_id"],
|
|
68
68
|
},
|
|
69
69
|
execute: async (params: Record<string, unknown>) => {
|
|
70
|
+
const orderId = (params.order_id ?? params.orderId) as string;
|
|
71
|
+
if (!orderId) throw new Error("order_id is required");
|
|
70
72
|
const body: Record<string, unknown> = {
|
|
71
|
-
orderId
|
|
73
|
+
orderId,
|
|
72
74
|
};
|
|
73
75
|
if (params.currency) body.currency = params.currency;
|
|
74
76
|
|
|
@@ -90,7 +92,9 @@ export function registerPaymentTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
90
92
|
required: ["order_id"],
|
|
91
93
|
},
|
|
92
94
|
execute: async (params: Record<string, unknown>) => {
|
|
93
|
-
const
|
|
95
|
+
const orderId = (params.order_id ?? params.orderId) as string;
|
|
96
|
+
if (!orderId) throw new Error("order_id is required");
|
|
97
|
+
const apiPath = `${PAYMENT_STATUS_API}/${orderId}`;
|
|
94
98
|
const data = await client.getJSON(apiPath, PAYMENT_STATUS_API);
|
|
95
99
|
return { result: JSON.stringify(data, null, 2) };
|
|
96
100
|
},
|