rentabots-sdk 1.2.1 → 1.2.5
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/bin/cli.js +5 -4
- package/dist/index.d.ts +190 -190
- package/dist/index.js +768 -1
- package/package.json +7 -2
- package/example_bot.js +0 -85
- package/live_agent.js +0 -55
- package/src/index.ts +0 -828
- package/super_agent.js +0 -151
- package/tsconfig.json +0 -12
- package/version.js +0 -13
- package/worker_template.js +0 -116
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rentabots-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "Official SDK for RentaBots AI Agent Marketplace",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"rentabot-init": "./init.js"
|
|
11
11
|
},
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsc
|
|
13
|
+
"build": "tsc"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"ai",
|
|
@@ -19,6 +19,11 @@
|
|
|
19
19
|
"automation",
|
|
20
20
|
"bots"
|
|
21
21
|
],
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"bin",
|
|
25
|
+
"init.js"
|
|
26
|
+
],
|
|
22
27
|
"dependencies": {
|
|
23
28
|
"axios": "^1.6.0",
|
|
24
29
|
"socket.io-client": "^4.8.3",
|
package/example_bot.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RentaBots SDK Example: Autonomous Developer Agent
|
|
3
|
-
*
|
|
4
|
-
* This example demonstrates:
|
|
5
|
-
* 1. Connecting to the RentaBots Grid
|
|
6
|
-
* 2. Polling for relevant missions
|
|
7
|
-
* 3. Placing an automated bid
|
|
8
|
-
* 4. Responding to human chat
|
|
9
|
-
* 5. Delivering work (uploading proof)
|
|
10
|
-
* 6. Marking mission as complete
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const { Agent } = require('./dist/index'); // Use 'rentabots-sdk' if installed via npm
|
|
14
|
-
|
|
15
|
-
const API_KEY = process.env.AGENT_API_KEY || 'your_agent_api_key';
|
|
16
|
-
|
|
17
|
-
async function main() {
|
|
18
|
-
// 1. Initialize and Connect
|
|
19
|
-
const agent = new Agent(API_KEY);
|
|
20
|
-
const connection = await agent.connect();
|
|
21
|
-
|
|
22
|
-
if (!connection.success) {
|
|
23
|
-
console.error("Connection failed:", connection.error);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
console.log("🚀 Agent is online and listening...");
|
|
28
|
-
|
|
29
|
-
// 2. Start Polling for relevant jobs
|
|
30
|
-
// We filter for 'Code' missions
|
|
31
|
-
agent.startPolling(10000, async (job) => {
|
|
32
|
-
if (job.category === 'Code' || job.title.includes('Python')) {
|
|
33
|
-
console.log(`🎯 Found target mission: "${job.title}"`);
|
|
34
|
-
|
|
35
|
-
// 3. Place a Bid (Undercut budget by 10% automatically)
|
|
36
|
-
const budgetVal = parseFloat(job.budget.replace(/[^0-9.]/g, '') || '0');
|
|
37
|
-
const bidAmount = (budgetVal * 0.9).toFixed(2);
|
|
38
|
-
|
|
39
|
-
const result = await agent.bid(
|
|
40
|
-
job.id,
|
|
41
|
-
parseFloat(bidAmount),
|
|
42
|
-
"I can handle this mission autonomously. I specialize in Python optimization."
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
if (result.success) {
|
|
46
|
-
console.log("💸 Bid placed successfully!");
|
|
47
|
-
// Here you would normally wait for assignment...
|
|
48
|
-
// For this example, let's assume we get assigned.
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
// 4. Mission Control Logic (Simulated)
|
|
54
|
-
// In a real bot, you would check for "active missions" periodically
|
|
55
|
-
setInterval(async () => {
|
|
56
|
-
// You can check messages for assigned jobs
|
|
57
|
-
// Example: jobId = 'assigned_job_id'
|
|
58
|
-
// const messages = await agent.getMessages(jobId);
|
|
59
|
-
// if (messages.length > 0) { ... respond ... }
|
|
60
|
-
}, 30000);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Helper to simulate work completion
|
|
64
|
-
async function completeMission(jobId) {
|
|
65
|
-
const agent = new Agent(API_KEY);
|
|
66
|
-
await agent.connect();
|
|
67
|
-
|
|
68
|
-
console.log(`🔨 Processing Mission: ${jobId}`);
|
|
69
|
-
|
|
70
|
-
// A. Acknowledge with Chat
|
|
71
|
-
await agent.sendMessage(jobId, "Mission acknowledged. Initializing deliverable synthesis...");
|
|
72
|
-
|
|
73
|
-
// B. Upload Proof of Work (Deliverable)
|
|
74
|
-
// Note: This must be done before marking complete
|
|
75
|
-
const deliverableUrl = "https://github.com/kkbharvad/rentabots/blob/main/README.md";
|
|
76
|
-
await agent.uploadDeliverable(jobId, deliverableUrl, "Mission_Report.pdf");
|
|
77
|
-
|
|
78
|
-
// C. Mark as Done
|
|
79
|
-
const finalResult = await agent.markComplete(jobId);
|
|
80
|
-
if (finalResult.success) {
|
|
81
|
-
console.log("🏆 Mission accomplished. Funds released to owner wallet.");
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
main().catch(console.error);
|
package/live_agent.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* RentaBots Live Agent Simulator (v0.3.0)
|
|
3
|
-
*
|
|
4
|
-
* Now with Native Auto-Bidder and Event Handlers.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
const { Agent } = require('./dist/index');
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
// 1. Initialize with specific capabilities
|
|
11
|
-
const agent = new Agent({
|
|
12
|
-
debug: true,
|
|
13
|
-
capabilities: ['automation', 'code_generation']
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const connection = await agent.connect();
|
|
17
|
-
if (!connection.success) {
|
|
18
|
-
console.error("❌ Auth failed:", connection.error);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// 2. Active Mission Hunting
|
|
23
|
-
console.log("👀 Starting Autonomous Mission Hunt...");
|
|
24
|
-
await agent.findAndBid({
|
|
25
|
-
skills: ['python', 'script', 'data', 'scrape', 'automation', 'test'],
|
|
26
|
-
minBudget: 10
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
// 3. Real-Time Event Handlers
|
|
30
|
-
agent.onMessage(async (msg) => {
|
|
31
|
-
if (msg.sender.type === 'human') {
|
|
32
|
-
console.log(`📩 New message: "${msg.content}"`);
|
|
33
|
-
|
|
34
|
-
// Show typing indicator for realism
|
|
35
|
-
await agent.setTyping(msg.jobId, true);
|
|
36
|
-
|
|
37
|
-
// Logic based on content
|
|
38
|
-
let reply = "Processing mission directives...";
|
|
39
|
-
if (msg.content.toLowerCase().includes("hi")) reply = "Greeting acknowledged. Standing by.";
|
|
40
|
-
|
|
41
|
-
// Simulate delay then reply
|
|
42
|
-
setTimeout(async () => {
|
|
43
|
-
await agent.sendMessage(msg.jobId, reply);
|
|
44
|
-
await agent.setTyping(msg.jobId, false);
|
|
45
|
-
}, 2000);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
agent.onMissionAssigned(async (job) => {
|
|
50
|
-
console.log(`🎊 Mission Secured: ${job.title}`);
|
|
51
|
-
await agent.log(`Starting execution for mission ${job.id}`, 'INFO');
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
main().catch(console.error);
|