rentabots-sdk 1.5.6 → 1.5.7

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/cli.js CHANGED
@@ -1,8 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  /**
4
- * šŸ¦€ RENTABOTS MASTER CONTROLLER (v1.5.6)
4
+ * šŸ¦€ RENTABOTS MASTER CONTROLLER (v1.5.7)
5
5
  * The all-in-one CLI for managing autonomous agents.
6
+ * Cross-Platform Support: Windows, Linux, Mac
6
7
  */
7
8
 
8
9
  const { execSync, spawn } = require('child_process');
@@ -29,7 +30,7 @@ async function handleDeploy() {
29
30
 
30
31
  if (!API_KEY) {
31
32
  console.error("āŒ Error: API Key required for one-line deployment.");
32
- console.log("Usage: rentabots deploy --key YOUR_API_KEY");
33
+ console.log("Usage: npx rentabots-sdk deploy --key YOUR_API_KEY");
33
34
  process.exit(1);
34
35
  }
35
36
 
@@ -38,32 +39,37 @@ async function handleDeploy() {
38
39
  // 1. Create project if missing
39
40
  if (!fs.existsSync(projectDir)) {
40
41
  console.log(`\nšŸ“‚ Project folder '${projectDir}' not found. Initializing...`);
41
- // We call the internal init logic here without interaction
42
42
  fs.mkdirSync(projectDir);
43
43
  process.chdir(projectDir);
44
44
 
45
- // Generate necessary files (Minimal v1.5.0 templates)
45
+ // Generate necessary files (Minimal v1.5.7 templates)
46
46
  const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8'));
47
47
  const ver = pkg.version;
48
48
 
49
49
  fs.writeFileSync('.env', `RENTABOTS_API_KEY=${API_KEY}\nRENTABOTS_API_URL=https://rentabots.com/api\n`);
50
50
 
51
+ // Universal Scripts: Use 'node' or 'npx' instead of OS-specific commands
51
52
  const pkgJson = {
52
53
  name: "my-rentabot-agent",
53
54
  version: "1.0.0",
54
55
  main: "agent.js",
55
56
  scripts: {
56
57
  "start": "node agent.js",
57
- "deploy": "pm2 start agent.js --name my-rentabot-agent",
58
- "status": "cat RENTABOT_STATUS.md",
59
- "logs": "pm2 logs my-rentabot-agent"
58
+ "deploy": "npx pm2 start agent.js --name my-rentabot-agent --update-env",
59
+ "stop": "npx pm2 stop my-rentabot-agent",
60
+ "logs": "npx pm2 logs my-rentabot-agent",
61
+ "status": "node -e \"console.log(require('fs').readFileSync('RENTABOT_STATUS.md', 'utf8'))\""
60
62
  },
61
- dependencies: { "rentabots-sdk": `^${ver}`, "dotenv": "^16.3.1" }
63
+ dependencies: {
64
+ "rentabots-sdk": `^${ver}`,
65
+ "dotenv": "^16.3.1",
66
+ "pm2": "^5.3.0"
67
+ }
62
68
  };
63
69
  fs.writeFileSync('package.json', JSON.stringify(pkgJson, null, 2));
64
70
 
65
71
  // Generate Queen & Worker
66
- const initScript = require('./init_templates'); // We'll move templates to a separate file
72
+ const initScript = require('./init_templates');
67
73
  fs.writeFileSync('agent.js', initScript.queenTemplate);
68
74
  fs.writeFileSync('worker.js', initScript.workerTemplate);
69
75
 
@@ -72,10 +78,10 @@ async function handleDeploy() {
72
78
  process.chdir(projectDir);
73
79
  }
74
80
 
75
- // 2. Deploy with PM2
81
+ // 2. Deploy with PM2 (Cross-Platform via NPX)
76
82
  run('npm run deploy', 'Deploying agent to RentaBots Grid (24/7 Mode)');
77
83
  console.log("\n✨ DEPLOYMENT SUCCESSFUL!");
78
- console.log("šŸ“Š Run 'rentabots status' to see your live dashboard.");
84
+ console.log("šŸ“Š Run 'npx rentabots-sdk status' to see your live dashboard.");
79
85
  }
80
86
 
81
87
  async function main() {
@@ -95,34 +101,37 @@ async function main() {
95
101
  break;
96
102
 
97
103
  case 'status':
104
+ // Try to find status file in current or subdirectory
98
105
  const statusPath = path.join(process.cwd(), 'my-rentabot-agent', 'RENTABOT_STATUS.md');
106
+ const localStatusPath = path.join(process.cwd(), 'RENTABOT_STATUS.md');
107
+
99
108
  if (fs.existsSync(statusPath)) {
100
109
  console.log(fs.readFileSync(statusPath, 'utf8'));
101
- } else if (fs.existsSync('RENTABOT_STATUS.md')) {
102
- console.log(fs.readFileSync('RENTABOT_STATUS.md', 'utf8'));
110
+ } else if (fs.existsSync(localStatusPath)) {
111
+ console.log(fs.readFileSync(localStatusPath, 'utf8'));
103
112
  } else {
104
- console.log("āŒ No active agent found in this directory.");
113
+ console.log("āŒ No active agent status found. Is the agent running?");
105
114
  }
106
115
  break;
107
116
 
108
117
  case 'logs':
109
- run('pm2 logs my-rentabot-agent', 'Opening live telemetry');
118
+ run('npx pm2 logs my-rentabot-agent', 'Opening live telemetry');
110
119
  break;
111
120
 
112
121
  case 'stop':
113
- run('pm2 stop my-rentabot-agent', 'Deactivating agent');
122
+ run('npx pm2 stop my-rentabot-agent', 'Deactivating agent');
114
123
  break;
115
124
 
116
125
  default:
117
126
  console.log(`
118
- šŸ¦€ RENTABOTS MASTER CLI v1.5.4
127
+ šŸ¦€ RENTABOTS MASTER CLI v1.5.7 (Universal)
119
128
  ------------------------------
120
129
  Usage:
121
- rentabots init - Interactive setup for a new agent.
122
- rentabots deploy --key - One-line command to initialize and launch an agent.
123
- rentabots status - See your live agent dashboard.
124
- rentabots logs - Stream real-time telemetry.
125
- rentabots stop - Shutdown your agent.
130
+ npx rentabots-sdk init - Interactive setup for a new agent.
131
+ npx rentabots-sdk deploy --key - One-line command to launch (Win/Linux/Mac).
132
+ npx rentabots-sdk status - See your live agent dashboard.
133
+ npx rentabots-sdk logs - Stream real-time telemetry.
134
+ npx rentabots-sdk stop - Shutdown your agent.
126
135
  `);
127
136
  }
128
137
  }
package/dist/index.d.ts CHANGED
@@ -61,8 +61,11 @@ export interface AutopilotOptions {
61
61
  bidTemplate?: string;
62
62
  }
63
63
  /**
64
- * šŸ¦€ RENTABOTS MASTER SDK (v1.5.0)
64
+ * šŸ¦€ RENTABOTS MASTER SDK (v1.5.1)
65
65
  * Robust, production-grade autonomous agent runtime.
66
+ * UPDATES:
67
+ * - Optimized scouting interval defaults (5m).
68
+ * - Hardened token usage prevention.
66
69
  */
67
70
  export declare class Agent extends EventEmitter {
68
71
  static readonly VERSION: string;
@@ -97,7 +100,9 @@ export declare class Agent extends EventEmitter {
97
100
  private handleStatusRequest;
98
101
  startAutopilot(options?: AutopilotOptions): void;
99
102
  spawnWorker(job: Job): Promise<ChildProcess>;
100
- execute(jobId: string, command: string): Promise<{
103
+ execute(jobId: string, command: string, opts?: {
104
+ timeout?: number;
105
+ }): Promise<{
101
106
  exitCode: number | null;
102
107
  output: string;
103
108
  }>;
package/dist/index.js CHANGED
@@ -69,15 +69,18 @@ exports.MessageSchema = zod_1.z.object({
69
69
  })
70
70
  });
71
71
  // --- CORE SDK ENGINE ---
72
- let SDK_VERSION = '1.5.0';
72
+ let SDK_VERSION = '1.5.1'; // BUMP
73
73
  try {
74
74
  const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
75
75
  SDK_VERSION = pkg.version;
76
76
  }
77
77
  catch (e) { }
78
78
  /**
79
- * šŸ¦€ RENTABOTS MASTER SDK (v1.5.0)
79
+ * šŸ¦€ RENTABOTS MASTER SDK (v1.5.1)
80
80
  * Robust, production-grade autonomous agent runtime.
81
+ * UPDATES:
82
+ * - Optimized scouting interval defaults (5m).
83
+ * - Hardened token usage prevention.
81
84
  */
82
85
  class Agent extends events_1.EventEmitter {
83
86
  constructor(options = {}) {
@@ -174,7 +177,9 @@ class Agent extends events_1.EventEmitter {
174
177
  }
175
178
  });
176
179
  this.socket.on('new_message', (data) => {
177
- this.logInternal(`New telemetry packet received: ${JSON.stringify(data).slice(0, 50)}...`);
180
+ // OPTIMIZATION: Only log full packet in debug mode
181
+ if (this.debug)
182
+ this.logInternal(`New telemetry packet received: ${JSON.stringify(data).slice(0, 50)}...`);
178
183
  try {
179
184
  const msg = exports.MessageSchema.parse(data);
180
185
  if (this.seenMessages.has(msg.id))
@@ -237,7 +242,8 @@ class Agent extends events_1.EventEmitter {
237
242
  }
238
243
  // --- šŸŽÆ AUTOPILOT ---
239
244
  startAutopilot(options = {}) {
240
- const interval = options.scoutingInterval || 60000;
245
+ // OPTIMIZATION: Default interval increased to 5 minutes (300000ms)
246
+ const interval = options.scoutingInterval || 300000;
241
247
  const cap = options.maxConcurrentMissions || 1;
242
248
  const scout = async () => {
243
249
  this.logInternal(`Scouting for jobs... (Active: ${this.activeMissions.size}/${cap})`);
@@ -277,13 +283,20 @@ class Agent extends events_1.EventEmitter {
277
283
  return worker;
278
284
  }
279
285
  // --- ⚔ ACTIONS ---
280
- async execute(jobId, command) {
286
+ async execute(jobId, command, opts = {}) {
281
287
  const cwd = path.join(this.workspaceRoot, jobId);
282
288
  if (!fs.existsSync(cwd))
283
289
  fs.mkdirSync(cwd, { recursive: true });
290
+ // OPTIMIZATION: Timeout support
291
+ const timeout = opts.timeout || 300000; // 5 minutes default
284
292
  return new Promise((resolve) => {
285
293
  let output = '';
286
294
  const child = (0, child_process_1.spawn)(command, { cwd, shell: true });
295
+ // Kill mechanism for timeout
296
+ const timer = setTimeout(() => {
297
+ child.kill();
298
+ resolve({ exitCode: -1, output: output + '\n[TIMEOUT EXCEEDED]' });
299
+ }, timeout);
287
300
  child.stdout?.on('data', (d) => {
288
301
  output += d.toString();
289
302
  // Stream logs to dashboard if [TERM] is present
@@ -291,7 +304,10 @@ class Agent extends events_1.EventEmitter {
291
304
  this.sendMessage(jobId, d.toString()).catch(() => { });
292
305
  });
293
306
  child.stderr?.on('data', (d) => output += d.toString());
294
- child.on('close', (code) => resolve({ exitCode: code, output }));
307
+ child.on('close', (code) => {
308
+ clearTimeout(timer);
309
+ resolve({ exitCode: code, output });
310
+ });
295
311
  });
296
312
  }
297
313
  async delegateTask(taskData) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rentabots-sdk",
3
- "version": "1.5.6",
3
+ "version": "1.5.7",
4
4
  "description": "Official SDK for RentaBots AI Agent Marketplace",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,8 +28,10 @@
28
28
  "init_templates.js"
29
29
  ],
30
30
  "dependencies": {
31
+ "-": "^0.0.1",
31
32
  "axios": "^1.6.0",
32
33
  "dotenv": "^17.2.4",
34
+ "npm": "^11.10.0",
33
35
  "socket.io-client": "^4.8.3",
34
36
  "zod": "^4.3.6"
35
37
  },