Skip to content

Commit 70c26bf

Browse files
committed
feat: update earn skill and tool discovery
1 parent de4e1b4 commit 70c26bf

14 files changed

Lines changed: 1065 additions & 533 deletions

index.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,20 @@ describe("AiToEarn OpenClaw Plugin", () => {
195195
expect(result.content[0].text).toContain("Base URL: https://aitoearn.ai/api");
196196
});
197197

198+
it("should append minor-unit notes to money-related tools", async () => {
199+
setDiscoveredTools(["listTaskMarket", "getAffiliateSettlement", "test_tool"]);
200+
201+
await pluginEntry.register(mockApi as any);
202+
203+
expect(getRegisteredTool("listTaskMarket").description).toBe(
204+
"Tool listTaskMarket\n\nMoney amounts are returned in minor units (such as cents). Use the response currency field when interpreting them. Points and other non-money counters stay in raw values."
205+
);
206+
expect(getRegisteredTool("getAffiliateSettlement").description).toBe(
207+
"Tool getAffiliateSettlement\n\nMoney amounts are returned in minor units (such as cents). Use the response currency field when interpreting them. Points and other non-money counters stay in raw values."
208+
);
209+
expect(getRegisteredTool("test_tool").description).toBe("Tool test_tool");
210+
});
211+
198212
it("should resolve SecretRef API keys during synced tool execution", async () => {
199213
mockApi.pluginConfig.apiKey = {
200214
source: "env",

index.ts

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@ import {
2222
} from "./src/tool-discovery.js";
2323
import type { ToolDefinition } from "./src/tools.js";
2424

25+
const MONEY_RELATED_TOOL_NAMES = new Set([
26+
"acceptTask",
27+
"getAffiliateOverview",
28+
"getAffiliateSettlement",
29+
"getMySampleOrderDetail",
30+
"getTaskDetail",
31+
"listAffiliateCommissions",
32+
"listMySampleOrders",
33+
"listTaskMarket",
34+
]);
35+
36+
const MONEY_UNITS_NOTE =
37+
"Money amounts are returned in minor units (such as cents). Use the response currency field when interpreting them. Points and other non-money counters stay in raw values.";
38+
2539
export default definePluginEntry({
2640
id: PLUGIN_ID,
2741
name: PLUGIN_NAME,
@@ -122,7 +136,7 @@ export default definePluginEntry({
122136
api.registerTool({
123137
name: tool.name,
124138
label: tool.name,
125-
description: describeTool(tool.description, environment, publishPlatform),
139+
description: describeTool(tool, environment, publishPlatform),
126140
parameters: tool.inputSchema,
127141
async execute(_toolCallId, params) {
128142
const config = await resolvePluginConfig(api);
@@ -234,16 +248,29 @@ function shouldRegisterTool(
234248
}
235249

236250
function describeTool(
237-
description: string,
251+
tool: ToolDefinition,
238252
environment: ReturnType<typeof resolveAiToEarnEnvironment>,
239253
publishPlatform: string | null
240254
): string {
255+
let description = tool.description;
256+
241257
if (!publishPlatform || environment === "self_hosted") {
242-
return description;
258+
return appendMoneyUnitsNote(tool.name, description);
243259
}
244260

245261
const envLabel = environment === "china" ? "China" : "Global";
246-
return `AiToEarn ${envLabel} publish tool. ${description}`;
262+
description = `AiToEarn ${envLabel} publish tool. ${description}`;
263+
return appendMoneyUnitsNote(tool.name, description);
264+
}
265+
266+
function appendMoneyUnitsNote(toolName: string, description: string): string {
267+
if (!MONEY_RELATED_TOOL_NAMES.has(toolName)) {
268+
return description;
269+
}
270+
271+
return description.trim()
272+
? `${description}\n\n${MONEY_UNITS_NOTE}`
273+
: MONEY_UNITS_NOTE;
247274
}
248275

249276
function formatEnvironmentSummary(params: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@aitoearn/openclaw-plugin",
3-
"version": "1.0.7",
3+
"version": "1.0.8",
44
"type": "module",
55
"main": "./dist/index.js",
66
"types": "./dist/index.d.ts",

0 commit comments

Comments
 (0)