@a2hmarket/a2hmarket 0.7.6 → 0.7.8
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/scripts/install.mjs +46 -18
- package/src/tools/address.ts +3 -3
- package/src/tools/discussion.ts +3 -3
- package/src/tools/file.ts +1 -1
- package/src/tools/order.ts +4 -4
- package/src/tools/payment.ts +2 -2
- package/src/tools/profile.ts +1 -1
- package/src/tools/send.ts +1 -1
- package/src/tools/status.ts +1 -1
- package/src/tools/tempo-payment.ts +1 -1
- package/src/tools/works.ts +5 -5
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/scripts/install.mjs
CHANGED
|
@@ -188,36 +188,63 @@ async function getFeishuToken(appId, appSecret) {
|
|
|
188
188
|
return data.tenant_access_token;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
"
|
|
198
|
-
"
|
|
191
|
+
function isZhLocale() {
|
|
192
|
+
const lang = (process.env.LANG || process.env.LC_ALL || process.env.LANGUAGE || "").toLowerCase();
|
|
193
|
+
return lang.startsWith("zh");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const ONBOARDING_ZH = {
|
|
197
|
+
title: "🎉 A2H Market · 安装成功",
|
|
198
|
+
intro: "我已经进入 A2H 市场了!这边特别热闹,很多人在摆摊出售各种东西,也有很多人在挑选商品和讨价还价。",
|
|
199
|
+
subtitle: "我可以帮你做三件事:",
|
|
200
|
+
items:
|
|
201
|
+
"🏪 **摆摊** — 帮你在市场上出售商品或服务,也可以直接接别人的悬赏任务赚钱\n\n" +
|
|
202
|
+
"🛍️ **逛街** — 帮你在市场上找东西买,我来搜、来比、来砍价,你拍板就行\n\n" +
|
|
203
|
+
"👀 **逛逛** — 还没想好也没关系!我帮你逛逛市场,看看有什么赚钱机会或者值得买的好东西",
|
|
204
|
+
cta: "你是想**摆摊卖东西**、**买点什么**,还是先让我帮你**逛逛**看看有什么机会?",
|
|
205
|
+
agent: (id) => `我的A2H Agent: ${id}`,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
const ONBOARDING_EN = {
|
|
209
|
+
title: "🎉 A2H Market · Setup Complete",
|
|
210
|
+
intro: "I'm now connected to A2H Market! The marketplace is buzzing with activity.",
|
|
211
|
+
subtitle: "I can help you with three things:",
|
|
212
|
+
items:
|
|
213
|
+
"🏪 **Sell** — List your products or services on the marketplace, or take on bounty tasks\n\n" +
|
|
214
|
+
"🛍️ **Shop** — Find and buy what you need — I'll search, compare, and negotiate for you\n\n" +
|
|
215
|
+
"👀 **Explore** — Not sure yet? I'll browse the market and discover opportunities for you",
|
|
216
|
+
cta: "Would you like to **sell something**, **buy something**, or just **explore** the market?",
|
|
217
|
+
agent: (id) => `My A2H Agent: ${id}`,
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
function getOnboardingLocale() {
|
|
221
|
+
return isZhLocale() ? ONBOARDING_ZH : ONBOARDING_EN;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function getOnboardingText() {
|
|
225
|
+
const t = getOnboardingLocale();
|
|
226
|
+
return `${t.title}\n\n${t.intro}\n\n${t.subtitle}\n\n${t.items}\n\n${t.cta}`;
|
|
227
|
+
}
|
|
199
228
|
|
|
200
229
|
async function sendOnboardingFeishu(appId, appSecret, target, agentId) {
|
|
201
230
|
const token = await getFeishuToken(appId, appSecret);
|
|
202
231
|
const receiveIdType = target.startsWith("oc_") ? "chat_id" : "open_id";
|
|
232
|
+
const t = getOnboardingLocale();
|
|
203
233
|
|
|
204
234
|
const card = {
|
|
205
235
|
schema: "2.0",
|
|
206
236
|
config: { wide_screen_mode: true },
|
|
207
237
|
header: {
|
|
208
|
-
title: { tag: "plain_text", content:
|
|
238
|
+
title: { tag: "plain_text", content: t.title },
|
|
209
239
|
template: "green",
|
|
210
240
|
},
|
|
211
241
|
body: {
|
|
212
242
|
elements: [
|
|
213
|
-
{ tag: "markdown", content:
|
|
214
|
-
{ tag: "markdown", content:
|
|
215
|
-
{ tag: "markdown", content:
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"👀 **Explore** — Not sure yet? I'll browse the market and discover opportunities for you" },
|
|
219
|
-
{ tag: "markdown", content: "Would you like to **sell something**, **buy something**, or just **explore** the market?" },
|
|
220
|
-
{ tag: "markdown", content: `---\n*My A2H Agent: ${agentId}*` },
|
|
243
|
+
{ tag: "markdown", content: t.intro },
|
|
244
|
+
{ tag: "markdown", content: t.subtitle },
|
|
245
|
+
{ tag: "markdown", content: t.items },
|
|
246
|
+
{ tag: "markdown", content: t.cta },
|
|
247
|
+
{ tag: "markdown", content: `---\n*${t.agent(agentId)}*` },
|
|
221
248
|
],
|
|
222
249
|
},
|
|
223
250
|
};
|
|
@@ -232,7 +259,8 @@ async function sendOnboardingFeishu(appId, appSecret, target, agentId) {
|
|
|
232
259
|
}
|
|
233
260
|
|
|
234
261
|
async function sendOnboardingDiscord(botToken, channelId, agentId) {
|
|
235
|
-
const
|
|
262
|
+
const t = getOnboardingLocale();
|
|
263
|
+
const text = getOnboardingText() + `\n\n---\n_${t.agent(agentId)}_`;
|
|
236
264
|
const resp = await fetch(`https://discord.com/api/v10/channels/${channelId}/messages`, {
|
|
237
265
|
method: "POST",
|
|
238
266
|
headers: { "Content-Type": "application/json", Authorization: `Bot ${botToken}` },
|
package/src/tools/address.ts
CHANGED
|
@@ -34,7 +34,7 @@ export function registerAddressTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
34
34
|
},
|
|
35
35
|
required: ["receiverName", "phoneNumber", "province", "city", "district", "detailAddress"],
|
|
36
36
|
},
|
|
37
|
-
execute: async (params: Record<string, unknown>) => {
|
|
37
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
38
38
|
const body: Record<string, unknown> = {
|
|
39
39
|
receiverName: params.receiverName,
|
|
40
40
|
phoneNumber: params.phoneNumber,
|
|
@@ -61,7 +61,7 @@ export function registerAddressTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
61
61
|
},
|
|
62
62
|
required: ["address_id"],
|
|
63
63
|
},
|
|
64
|
-
execute: async (params: Record<string, unknown>) => {
|
|
64
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
65
65
|
const apiPath = `${ADDRESS_API}/${params.address_id}`;
|
|
66
66
|
const data = await client.deleteJSON(apiPath);
|
|
67
67
|
return { result: JSON.stringify(data ?? { ok: true }, null, 2) };
|
|
@@ -78,7 +78,7 @@ export function registerAddressTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
78
78
|
},
|
|
79
79
|
required: ["address_id"],
|
|
80
80
|
},
|
|
81
|
-
execute: async (params: Record<string, unknown>) => {
|
|
81
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
82
82
|
const apiPath = `${ADDRESS_API}/${params.address_id}/default`;
|
|
83
83
|
const data = await client.putJSON(apiPath);
|
|
84
84
|
return { result: JSON.stringify(data ?? { ok: true }, null, 2) };
|
package/src/tools/discussion.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function registerDiscussionTools(api: OpenClawPluginApi, client: A2HApiCl
|
|
|
22
22
|
},
|
|
23
23
|
required: ["title", "content"],
|
|
24
24
|
},
|
|
25
|
-
execute: async (params: Record<string, unknown>) => {
|
|
25
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
26
26
|
const body: Record<string, unknown> = {
|
|
27
27
|
type: 4,
|
|
28
28
|
title: params.title,
|
|
@@ -48,7 +48,7 @@ export function registerDiscussionTools(api: OpenClawPluginApi, client: A2HApiCl
|
|
|
48
48
|
},
|
|
49
49
|
required: ["parent_works_id", "title", "content"],
|
|
50
50
|
},
|
|
51
|
-
execute: async (params: Record<string, unknown>) => {
|
|
51
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
52
52
|
const body = {
|
|
53
53
|
type: 4,
|
|
54
54
|
title: params.title,
|
|
@@ -71,7 +71,7 @@ export function registerDiscussionTools(api: OpenClawPluginApi, client: A2HApiCl
|
|
|
71
71
|
page_size: { type: "number", description: "Page size (default 20)" },
|
|
72
72
|
},
|
|
73
73
|
},
|
|
74
|
-
execute: async (params: Record<string, unknown>) => {
|
|
74
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
75
75
|
const page = (params.page as number) || 1;
|
|
76
76
|
const pageSize = (params.page_size as number) || 20;
|
|
77
77
|
const qs = `?type=4&page=${page}&pageSize=${pageSize}`;
|
package/src/tools/file.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function registerFileTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
18
18
|
},
|
|
19
19
|
required: ["file"],
|
|
20
20
|
},
|
|
21
|
-
execute: async (params: Record<string, unknown>) => {
|
|
21
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
22
22
|
const uploadType = (params.upload_type as string) || "chatfile";
|
|
23
23
|
const fileInfo = await ossUpload(client, params.file as string, uploadType);
|
|
24
24
|
return { result: JSON.stringify(fileInfo, null, 2) };
|
package/src/tools/order.ts
CHANGED
|
@@ -18,7 +18,7 @@ export function registerOrderTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
18
18
|
},
|
|
19
19
|
required: ["customer_id", "title", "content", "price_cent", "product_id", "order_type"],
|
|
20
20
|
},
|
|
21
|
-
execute: async (params: Record<string, unknown>) => {
|
|
21
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
22
22
|
const body = {
|
|
23
23
|
providerId: client.agentId,
|
|
24
24
|
customerId: params.customer_id,
|
|
@@ -48,7 +48,7 @@ export function registerOrderTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
48
48
|
},
|
|
49
49
|
required: ["order_id", "action"],
|
|
50
50
|
},
|
|
51
|
-
execute: async (params: Record<string, unknown>) => {
|
|
51
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
52
52
|
const validActions = ["confirm", "reject", "cancel", "confirm-received", "confirm-service-completed"];
|
|
53
53
|
const action = params.action as string;
|
|
54
54
|
if (!validActions.includes(action)) {
|
|
@@ -70,7 +70,7 @@ export function registerOrderTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
70
70
|
},
|
|
71
71
|
required: ["order_id"],
|
|
72
72
|
},
|
|
73
|
-
execute: async (params: Record<string, unknown>) => {
|
|
73
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
74
74
|
const orderId = (params.order_id ?? params.orderId) as string;
|
|
75
75
|
if (!orderId) throw new Error("order_id is required");
|
|
76
76
|
const apiPath = `/findu-trade/api/v1/orders/${orderId}/detail`;
|
|
@@ -95,7 +95,7 @@ export function registerOrderTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
95
95
|
},
|
|
96
96
|
required: ["role"],
|
|
97
97
|
},
|
|
98
|
-
execute: async (params: Record<string, unknown>) => {
|
|
98
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
99
99
|
const role = params.role === "purchase" ? "purchase-orders" : "sales-orders";
|
|
100
100
|
const page = (params.page as number) || 1;
|
|
101
101
|
const pageSize = (params.page_size as number) || 20;
|
package/src/tools/payment.ts
CHANGED
|
@@ -66,7 +66,7 @@ export function registerPaymentTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
66
66
|
},
|
|
67
67
|
required: ["order_id"],
|
|
68
68
|
},
|
|
69
|
-
execute: async (params: Record<string, unknown>) => {
|
|
69
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
70
70
|
const orderId = (params.order_id ?? params.orderId) as string;
|
|
71
71
|
if (!orderId) throw new Error("order_id is required");
|
|
72
72
|
const body: Record<string, unknown> = {
|
|
@@ -91,7 +91,7 @@ export function registerPaymentTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
91
91
|
},
|
|
92
92
|
required: ["order_id"],
|
|
93
93
|
},
|
|
94
|
-
execute: async (params: Record<string, unknown>) => {
|
|
94
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
95
95
|
const orderId = (params.order_id ?? params.orderId) as string;
|
|
96
96
|
if (!orderId) throw new Error("order_id is required");
|
|
97
97
|
const apiPath = `${PAYMENT_STATUS_API}/${orderId}`;
|
package/src/tools/profile.ts
CHANGED
|
@@ -30,7 +30,7 @@ export function registerProfileTools(api: OpenClawPluginApi, client: A2HApiClien
|
|
|
30
30
|
},
|
|
31
31
|
required: ["file"],
|
|
32
32
|
},
|
|
33
|
-
execute: async (params: Record<string, unknown>) => {
|
|
33
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
34
34
|
const fileInfo = await ossUpload(client, params.file as string, "profile", PROFILE_QR_MIME);
|
|
35
35
|
|
|
36
36
|
const changeData = await client.postJSON<Record<string, unknown>>(CHANGE_REQUEST_API, {
|
package/src/tools/send.ts
CHANGED
|
@@ -43,7 +43,7 @@ export function registerSendTool(api: OpenClawPluginApi, creds: A2HCredentials)
|
|
|
43
43
|
},
|
|
44
44
|
required: ["target_agent_id"],
|
|
45
45
|
},
|
|
46
|
-
execute: async (params: Record<string, unknown>) => {
|
|
46
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
47
47
|
const targetAgentId = params.target_agent_id as string;
|
|
48
48
|
if (!targetAgentId || targetAgentId === "undefined") {
|
|
49
49
|
throw new Error("target_agent_id is required and cannot be empty. If you are replying to an inbound message, reply with plain text instead of calling a2h_send.");
|
package/src/tools/status.ts
CHANGED
|
@@ -48,7 +48,7 @@ export function registerInboxHistoryTool(api: OpenClawPluginApi, client: A2HApiC
|
|
|
48
48
|
},
|
|
49
49
|
required: ["peer_id"],
|
|
50
50
|
},
|
|
51
|
-
execute: async (params: Record<string, unknown>) => {
|
|
51
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
52
52
|
const peerId = params.peer_id as string;
|
|
53
53
|
const page = (params.page as number) || 1;
|
|
54
54
|
const limit = Math.min((params.limit as number) || 20, 100);
|
|
@@ -40,7 +40,7 @@ export function registerTempoPaymentTools(api: OpenClawPluginApi, client: A2HApi
|
|
|
40
40
|
},
|
|
41
41
|
required: ["order_id"],
|
|
42
42
|
},
|
|
43
|
-
execute: async (params: Record<string, unknown>) => {
|
|
43
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
44
44
|
const orderId = (params.order_id ?? params.orderId) as string;
|
|
45
45
|
if (!orderId) throw new Error("order_id is required");
|
|
46
46
|
|
package/src/tools/works.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function registerWorksTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
22
22
|
},
|
|
23
23
|
required: ["keyword"],
|
|
24
24
|
},
|
|
25
|
-
execute: async (params: Record<string, unknown>) => {
|
|
25
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
26
26
|
const page = (params.page as number) || 1;
|
|
27
27
|
const body: Record<string, unknown> = {
|
|
28
28
|
serviceInfo: params.keyword,
|
|
@@ -48,7 +48,7 @@ export function registerWorksTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
48
48
|
page_size: { type: "number", description: "Page size (default 20)" },
|
|
49
49
|
},
|
|
50
50
|
},
|
|
51
|
-
execute: async (params: Record<string, unknown>) => {
|
|
51
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
52
52
|
const page = (params.page as number) || 1;
|
|
53
53
|
const pageSize = (params.page_size as number) || 20;
|
|
54
54
|
let qs = `?pageNum=${page}&pageSize=${pageSize}`;
|
|
@@ -76,7 +76,7 @@ export function registerWorksTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
76
76
|
},
|
|
77
77
|
required: ["type", "title", "content"],
|
|
78
78
|
},
|
|
79
|
-
execute: async (params: Record<string, unknown>) => {
|
|
79
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
80
80
|
const extendInfo: Record<string, unknown> = { pois: [] };
|
|
81
81
|
if (params.expected_price) extendInfo.expectedPrice = params.expected_price;
|
|
82
82
|
if (params.service_method) extendInfo.serviceMethod = params.service_method;
|
|
@@ -112,7 +112,7 @@ export function registerWorksTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
112
112
|
},
|
|
113
113
|
required: ["works_id", "type", "title"],
|
|
114
114
|
},
|
|
115
|
-
execute: async (params: Record<string, unknown>) => {
|
|
115
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
116
116
|
const extendInfo: Record<string, unknown> = { pois: [] };
|
|
117
117
|
if (params.expected_price) extendInfo.expectedPrice = params.expected_price;
|
|
118
118
|
if (params.service_method) extendInfo.serviceMethod = params.service_method;
|
|
@@ -142,7 +142,7 @@ export function registerWorksTools(api: OpenClawPluginApi, client: A2HApiClient)
|
|
|
142
142
|
},
|
|
143
143
|
required: ["works_id"],
|
|
144
144
|
},
|
|
145
|
-
execute: async (params: Record<string, unknown>) => {
|
|
145
|
+
execute: async (_toolCallId: string, params: Record<string, unknown>) => {
|
|
146
146
|
const data = await client.deleteJSON(`${WORKS_DELETE_API}/${params.works_id}`);
|
|
147
147
|
return { result: JSON.stringify(data ?? { ok: true }, null, 2) };
|
|
148
148
|
},
|