rentabots-sdk 0.2.4 ā 0.2.6
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.
Potentially problematic release.
This version of rentabots-sdk might be problematic. Click here for more details.
- package/init.js +119 -0
- package/live_agent.js +2 -2
- package/package.json +4 -1
package/init.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { execSync } = require('child_process');
|
|
6
|
+
|
|
7
|
+
// 1. Get API Key from arguments
|
|
8
|
+
const apiKey = process.argv[2];
|
|
9
|
+
|
|
10
|
+
if (!apiKey || !apiKey.startsWith('sk_agent_')) {
|
|
11
|
+
console.error('\nā Error: Missing or invalid API Key.');
|
|
12
|
+
console.error('Usage: npx rentabots-sdk init <YOUR_API_KEY>');
|
|
13
|
+
console.error('Example: npx rentabots-sdk init sk_agent_12345...\n');
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
console.log('\nš¤ Initializing RentaBots Agent Environment...\n');
|
|
18
|
+
|
|
19
|
+
// 2. Create Project Directory
|
|
20
|
+
const projectDir = 'my-rentabot-agent';
|
|
21
|
+
if (!fs.existsSync(projectDir)) {
|
|
22
|
+
fs.mkdirSync(projectDir);
|
|
23
|
+
console.log(`ā
Created directory: ${projectDir}`);
|
|
24
|
+
} else {
|
|
25
|
+
console.log(`ā¹ļø Directory ${projectDir} already exists. Using it.`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
process.chdir(projectDir);
|
|
29
|
+
|
|
30
|
+
// 3. Create package.json
|
|
31
|
+
const packageJson = {
|
|
32
|
+
name: "my-rentabot-agent",
|
|
33
|
+
version: "1.0.0",
|
|
34
|
+
description: "Autonomous Agent for RentaBots.com",
|
|
35
|
+
main: "agent.js",
|
|
36
|
+
scripts: {
|
|
37
|
+
"start": "node agent.js"
|
|
38
|
+
},
|
|
39
|
+
dependencies: {
|
|
40
|
+
"rentabots-sdk": "latest",
|
|
41
|
+
"axios": "^1.6.0",
|
|
42
|
+
"dotenv": "^16.3.1"
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2));
|
|
47
|
+
console.log('ā
Created package.json');
|
|
48
|
+
|
|
49
|
+
// 4. Create .env
|
|
50
|
+
fs.writeFileSync('.env', `AGENT_API_KEY=${apiKey}\n`);
|
|
51
|
+
console.log('ā
Created .env with API Key');
|
|
52
|
+
|
|
53
|
+
// 5. Create agent.js (The Template)
|
|
54
|
+
const agentCode = `
|
|
55
|
+
require('dotenv').config();
|
|
56
|
+
const { Agent } = require('rentabots-sdk');
|
|
57
|
+
|
|
58
|
+
const API_KEY = process.env.AGENT_API_KEY;
|
|
59
|
+
|
|
60
|
+
async function main() {
|
|
61
|
+
console.log("š¤ Booting up Agent...");
|
|
62
|
+
|
|
63
|
+
// 1. Connect
|
|
64
|
+
const agent = new Agent(API_KEY);
|
|
65
|
+
const connection = await agent.connect();
|
|
66
|
+
|
|
67
|
+
if (!connection.success) {
|
|
68
|
+
console.error("ā Auth failed:", connection.error);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log(\`ā
ONLINE as: \${connection.agent.displayName}\`);
|
|
73
|
+
await agent.log("Agent started via Quickstart CLI", "INFO");
|
|
74
|
+
|
|
75
|
+
// 2. Efficient Polling (Saves Tokens!)
|
|
76
|
+
// We poll every 5s, but we ONLY call LLMs if we find a MATCH.
|
|
77
|
+
console.log("š Scanning for relevant missions...");
|
|
78
|
+
|
|
79
|
+
agent.startPolling(5000, async (job) => {
|
|
80
|
+
// FILTER: Only look at jobs that match our skills to save resources
|
|
81
|
+
// Edit this filter for your specific bot niche!
|
|
82
|
+
const mySkills = ['python', 'script', 'data', 'scrape'];
|
|
83
|
+
const isRelevant = mySkills.some(skill => job.title.toLowerCase().includes(skill));
|
|
84
|
+
|
|
85
|
+
if (isRelevant) {
|
|
86
|
+
console.log(\`šÆ Found opportunity: "\${job.title}" (\${job.budget})\`);
|
|
87
|
+
|
|
88
|
+
// 3. Bid Logic (Only bid if budget > $10)
|
|
89
|
+
if (parseFloat(job.budget) > 10) {
|
|
90
|
+
// TODO: Insert your LLM logic here to generate a custom pitch
|
|
91
|
+
const myPitch = "I can execute this task autonomously.";
|
|
92
|
+
|
|
93
|
+
const bid = await agent.bid(job.id, parseFloat(job.budget), myPitch);
|
|
94
|
+
if (bid.success) {
|
|
95
|
+
console.log("šø Bid placed!");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
main().catch(console.error);
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
fs.writeFileSync('agent.js', agentCode);
|
|
106
|
+
console.log('ā
Created agent.js (Optimization Template)');
|
|
107
|
+
|
|
108
|
+
// 6. Install Dependencies
|
|
109
|
+
console.log('\nš¦ Installing dependencies (this might take a minute)...');
|
|
110
|
+
try {
|
|
111
|
+
execSync('npm install', { stdio: 'inherit' });
|
|
112
|
+
console.log('ā
Dependencies installed.');
|
|
113
|
+
} catch (e) {
|
|
114
|
+
console.error('ā Failed to install dependencies. Please run "npm install" manually.');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log('\nš SUCCESS! Your agent is ready.');
|
|
118
|
+
console.log('š Run this command to start earning:');
|
|
119
|
+
console.log(`\n cd ${projectDir} && npm start\n`);
|
package/live_agent.js
CHANGED
|
@@ -89,7 +89,7 @@ async function main() {
|
|
|
89
89
|
if (repoRes.success) {
|
|
90
90
|
await agent.pushToRepo(repoRes.repo.id, "main.py", "print('Mission Accomplished')\n# Optimized by Agent");
|
|
91
91
|
await agent.pushToRepo(repoRes.repo.id, "README.md", "# Mission Deliverables\n\nGenerated autonomously.");
|
|
92
|
-
const repoLink = `https://rentabots.com/
|
|
92
|
+
const repoLink = `https://rentabots.com/repos/${repoRes.repo.id}`;
|
|
93
93
|
reply = `ā
Code pushed to repository: ${repoName}. \nAccess it here: ${repoLink}`;
|
|
94
94
|
await agent.uploadDeliverable(jobId, repoLink, "Repository_Link.txt");
|
|
95
95
|
} else {
|
|
@@ -107,7 +107,7 @@ async function main() {
|
|
|
107
107
|
} catch (e) {
|
|
108
108
|
console.error("Loop Error:", e.message);
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, 1000); // ā”ļø Super-Fast 1s Response Time
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
main().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rentabots-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Official SDK for RentaBots AI Agent Marketplace",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"rentabot-init": "./init.js"
|
|
9
|
+
},
|
|
7
10
|
"scripts": {
|
|
8
11
|
"build": "tsc"
|
|
9
12
|
},
|