@bountyagents/bountyagents-task 2026.3.100 → 2026.3.102
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 +6 -1
- package/skills/bountyagents.md +80 -0
- package/.env.local +0 -1
- package/bun.lock +0 -1605
- package/index.ts +0 -46
- package/src/escrow.ts +0 -27
- package/src/helper.ts +0 -23
- package/src/index.ts +0 -431
- package/src/publisher.ts +0 -322
- package/src/signers.ts +0 -36
- package/src/signing.ts +0 -112
- package/src/task-db-types.ts +0 -70
- package/src/token.ts +0 -17
- package/src/types.ts +0 -97
- package/src/worker.ts +0 -102
- package/test-dashboard.ts +0 -16
- package/test-publisher.ts +0 -38
- package/test-response.ts +0 -43
- package/test-worker.ts +0 -25
- package/tsconfig.json +0 -16
package/src/worker.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { Type } from "@sinclair/typebox";
|
|
2
|
-
import { PrivateKeySigner } from "./signers.js";
|
|
3
|
-
import { BountyAgentsWorkerPlugin } from "./index.js";
|
|
4
|
-
import { json, getPrivateKey } from "./helper.js";
|
|
5
|
-
|
|
6
|
-
const SERVICE_URL = "http://localhost:3000";
|
|
7
|
-
const CONTRACT_ADDRESS = "0x55D45aFA265d0381C8A81328FfeA408D2Dd45F40";
|
|
8
|
-
|
|
9
|
-
export async function getAvailableTask(params: {
|
|
10
|
-
id?: string;
|
|
11
|
-
keyword?: string;
|
|
12
|
-
pageSize?: number;
|
|
13
|
-
pageNum?: number;
|
|
14
|
-
}) {
|
|
15
|
-
const signer = new PrivateKeySigner(getPrivateKey());
|
|
16
|
-
const plugin = new BountyAgentsWorkerPlugin(signer, {
|
|
17
|
-
serviceUrl: SERVICE_URL,
|
|
18
|
-
contractAddress: CONTRACT_ADDRESS,
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const tasks = (await plugin.executeTool("bountyagents.worker.task.query", {
|
|
22
|
-
filter: {
|
|
23
|
-
status: "active",
|
|
24
|
-
...(params.id ? { id: params.id } : {}),
|
|
25
|
-
},
|
|
26
|
-
pageSize: params.pageSize,
|
|
27
|
-
pageNum: params.pageNum,
|
|
28
|
-
})) as any;
|
|
29
|
-
if (tasks.length === 0) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
return tasks[0];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export async function submitResponse(params: {
|
|
36
|
-
taskId: string;
|
|
37
|
-
payload: string;
|
|
38
|
-
}) {
|
|
39
|
-
const signer = new PrivateKeySigner(getPrivateKey());
|
|
40
|
-
const plugin = new BountyAgentsWorkerPlugin(signer, {
|
|
41
|
-
serviceUrl: SERVICE_URL,
|
|
42
|
-
contractAddress: CONTRACT_ADDRESS,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const response = (await plugin.executeTool(
|
|
46
|
-
"bountyagents.worker.task.respond",
|
|
47
|
-
{
|
|
48
|
-
taskId: params.taskId,
|
|
49
|
-
payload: params.payload,
|
|
50
|
-
}
|
|
51
|
-
)) as any;
|
|
52
|
-
return response;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function registerWorkerTools(api: any) {
|
|
56
|
-
api.registerTool({
|
|
57
|
-
name: "get_available_task",
|
|
58
|
-
description:
|
|
59
|
-
"Get available active bounty task for the worker to work on and respond to, if id is provided, get the task with the given id.",
|
|
60
|
-
parameters: Type.Object({
|
|
61
|
-
keyword: Type.Optional(Type.String()),
|
|
62
|
-
id: Type.Optional(Type.String()),
|
|
63
|
-
}),
|
|
64
|
-
async execute(_id: string, params: any) {
|
|
65
|
-
try {
|
|
66
|
-
const result = await getAvailableTask({
|
|
67
|
-
pageSize: 1,
|
|
68
|
-
pageNum: 0,
|
|
69
|
-
keyword: "",
|
|
70
|
-
id: params.id,
|
|
71
|
-
});
|
|
72
|
-
return json(result);
|
|
73
|
-
} catch (error: any) {
|
|
74
|
-
return json({
|
|
75
|
-
error: error instanceof Error ? error.message : String(error),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
api.registerTool({
|
|
82
|
-
name: "submit_task_response",
|
|
83
|
-
description: "Submit a response for an active bounty task.",
|
|
84
|
-
parameters: Type.Object({
|
|
85
|
-
taskId: Type.String(),
|
|
86
|
-
content: Type.String(),
|
|
87
|
-
}),
|
|
88
|
-
async execute(_id: string, params: any) {
|
|
89
|
-
try {
|
|
90
|
-
const result = await submitResponse({
|
|
91
|
-
taskId: params.taskId,
|
|
92
|
-
payload: params.content,
|
|
93
|
-
});
|
|
94
|
-
return json(result);
|
|
95
|
-
} catch (error: any) {
|
|
96
|
-
return json({
|
|
97
|
-
error: error instanceof Error ? error.message : String(error),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}
|
package/test-dashboard.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { openUpclawDashboard } from "./src/publisher.js";
|
|
2
|
-
|
|
3
|
-
async function testOpenDashboard() {
|
|
4
|
-
console.log(`\n--- Testing openUpclawDashboard ---`);
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const result = await openUpclawDashboard();
|
|
8
|
-
console.log("Open dashboard successful!");
|
|
9
|
-
console.log(JSON.stringify(result, null, 2));
|
|
10
|
-
} catch (error) {
|
|
11
|
-
console.error("Test failed:");
|
|
12
|
-
console.error(error);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
testOpenDashboard();
|
package/test-publisher.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { depositToken, createBountyTask, fundBountyTask } from "./src/publisher.js";
|
|
2
|
-
|
|
3
|
-
async function testCreateAndDeposit() {
|
|
4
|
-
const testId = "test-" + Date.now();
|
|
5
|
-
console.log(`\n--- Testing createBountyTask ---`);
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
const taskResult = await createBountyTask({
|
|
9
|
-
title: `Test Task ${testId}`,
|
|
10
|
-
content: "This is a test task content created via standalone function."
|
|
11
|
-
});
|
|
12
|
-
console.log("Task creation successful!");
|
|
13
|
-
console.log(JSON.stringify(taskResult, null, 2));
|
|
14
|
-
|
|
15
|
-
const createdTaskId = taskResult.id;
|
|
16
|
-
console.log(`\n--- Testing depositToken with taskId: ${createdTaskId} ---`);
|
|
17
|
-
|
|
18
|
-
const depositResult = await depositToken({
|
|
19
|
-
taskId: createdTaskId,
|
|
20
|
-
amount: "100"
|
|
21
|
-
});
|
|
22
|
-
console.log("Deposit successful!");
|
|
23
|
-
console.log(JSON.stringify(depositResult, null, 2));
|
|
24
|
-
|
|
25
|
-
console.log(`\n--- Testing fundBountyTask with taskId: ${createdTaskId} ---`);
|
|
26
|
-
const fundResult = await fundBountyTask({
|
|
27
|
-
taskId: createdTaskId,
|
|
28
|
-
token: "bsc-testnet:0x56DA32693A4e6dDd0eDC932b295cb00372f37f8b"
|
|
29
|
-
});
|
|
30
|
-
console.log("Fund task successful!");
|
|
31
|
-
console.log(JSON.stringify(fundResult, null, 2));
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error("Test failed:");
|
|
34
|
-
console.error(error);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
testCreateAndDeposit();
|
package/test-response.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { submitResponse } from "./src/worker.js";
|
|
2
|
-
import { decideOnResponse } from "./src/publisher.js";
|
|
3
|
-
|
|
4
|
-
async function testResponseFlow() {
|
|
5
|
-
const taskId = "c5fc8fd0-e7db-4ec8-8fb9-86314cb6a5e7";
|
|
6
|
-
console.log(`\n--- Testing Response Flow for taskId: ${taskId} ---`);
|
|
7
|
-
|
|
8
|
-
try {
|
|
9
|
-
// 1. Submit Response
|
|
10
|
-
console.log("\n1. Submitting response as worker...");
|
|
11
|
-
const responseResult = await submitResponse({
|
|
12
|
-
taskId,
|
|
13
|
-
payload: "This is a test response content submitted via standalone function."
|
|
14
|
-
});
|
|
15
|
-
console.log("Response submission successful!");
|
|
16
|
-
console.log(JSON.stringify(responseResult, null, 2));
|
|
17
|
-
|
|
18
|
-
const responseId = responseResult.id;
|
|
19
|
-
const workerAddress = responseResult.worker;
|
|
20
|
-
// Note: In a real scenario, we might need to fetch the task to get the price,
|
|
21
|
-
// but for testing we'll assume a value or use what's in the response if available.
|
|
22
|
-
// Based on the schema, price is on the task, not the response.
|
|
23
|
-
|
|
24
|
-
// 2. Decide on Response (Approve)
|
|
25
|
-
console.log(`\n2. Deciding on response (approving) as publisher...`);
|
|
26
|
-
// We'll use the price from the task. Since the task was funded with 100 tokens,
|
|
27
|
-
// we use the same value.
|
|
28
|
-
const decisionResult = await decideOnResponse({
|
|
29
|
-
responseId,
|
|
30
|
-
workerAddress,
|
|
31
|
-
price: "142500000",
|
|
32
|
-
status: "approved"
|
|
33
|
-
});
|
|
34
|
-
console.log("Decision (approval) successful!");
|
|
35
|
-
console.log(JSON.stringify(decisionResult, null, 2));
|
|
36
|
-
|
|
37
|
-
} catch (error) {
|
|
38
|
-
console.error("Test flow failed:");
|
|
39
|
-
console.error(error);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
testResponseFlow();
|
package/test-worker.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { getAvailableTask } from "./src/worker.js";
|
|
2
|
-
|
|
3
|
-
async function testGetAvailableTasks() {
|
|
4
|
-
console.log(`\n--- Testing getAvailableTasks ---`);
|
|
5
|
-
|
|
6
|
-
try {
|
|
7
|
-
const task = await getAvailableTask({
|
|
8
|
-
pageSize: 5,
|
|
9
|
-
pageNum: 0,
|
|
10
|
-
keyword: "",
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
if (task) {
|
|
14
|
-
console.log("First task sample:");
|
|
15
|
-
console.log(JSON.stringify(task, null, 2));
|
|
16
|
-
} else {
|
|
17
|
-
console.log("No active tasks found.");
|
|
18
|
-
}
|
|
19
|
-
} catch (error) {
|
|
20
|
-
console.error("Test failed:");
|
|
21
|
-
console.error(error);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
testGetAvailableTasks();
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "NodeNext",
|
|
5
|
-
"moduleResolution": "NodeNext",
|
|
6
|
-
"lib": ["ESNext"],
|
|
7
|
-
"strict": true,
|
|
8
|
-
"esModuleInterop": true,
|
|
9
|
-
"skipLibCheck": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"rootDir": ".",
|
|
12
|
-
"outDir": "dist"
|
|
13
|
-
},
|
|
14
|
-
"include": ["index.ts", "src/**/*.ts"],
|
|
15
|
-
"exclude": ["node_modules", "dist"]
|
|
16
|
-
}
|