rentabots-sdk 1.6.0 → 1.6.3
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/dist/index.d.ts +58 -0
- package/dist/index.js +138 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -125,8 +125,66 @@ export declare class Agent extends EventEmitter {
|
|
|
125
125
|
error: any;
|
|
126
126
|
jobId?: undefined;
|
|
127
127
|
}>;
|
|
128
|
+
setProgress(jobId: string, percent: number): Promise<{
|
|
129
|
+
success: boolean;
|
|
130
|
+
error?: string;
|
|
131
|
+
}>;
|
|
132
|
+
createRepo(jobId: string, name?: string): Promise<{
|
|
133
|
+
success: boolean;
|
|
134
|
+
repo?: any;
|
|
135
|
+
error?: string;
|
|
136
|
+
}>;
|
|
137
|
+
getRepo(jobId: string): Promise<{
|
|
138
|
+
success: boolean;
|
|
139
|
+
exists: boolean;
|
|
140
|
+
repo?: any;
|
|
141
|
+
error?: string;
|
|
142
|
+
}>;
|
|
143
|
+
uploadRepoFile(jobId: string, filePath: string, content: string | Buffer, isBlob?: boolean): Promise<{
|
|
144
|
+
success: boolean;
|
|
145
|
+
repoId?: string;
|
|
146
|
+
error?: string;
|
|
147
|
+
}>;
|
|
148
|
+
private isBinaryFile;
|
|
128
149
|
deliver(jobId: string, files: string[]): Promise<void>;
|
|
150
|
+
verifyDeliverables(jobId: string): Promise<{
|
|
151
|
+
success: boolean;
|
|
152
|
+
verified: boolean;
|
|
153
|
+
files?: any[];
|
|
154
|
+
issues?: string[];
|
|
155
|
+
error?: string;
|
|
156
|
+
}>;
|
|
157
|
+
preDeliveryCheck(jobId: string): Promise<{
|
|
158
|
+
canDeliver: boolean;
|
|
159
|
+
checks: any[];
|
|
160
|
+
}>;
|
|
129
161
|
markComplete(jobId: string): Promise<any>;
|
|
162
|
+
generate(prompt: string, options?: {
|
|
163
|
+
model?: string;
|
|
164
|
+
temperature?: number;
|
|
165
|
+
maxTokens?: number;
|
|
166
|
+
system?: string;
|
|
167
|
+
}): Promise<{
|
|
168
|
+
success: boolean;
|
|
169
|
+
text?: string;
|
|
170
|
+
error?: string;
|
|
171
|
+
}>;
|
|
172
|
+
analyzeRequirements(job: Job): Promise<{
|
|
173
|
+
success: boolean;
|
|
174
|
+
requirements?: any;
|
|
175
|
+
error?: string;
|
|
176
|
+
}>;
|
|
177
|
+
codeGenerator(prompt: string, language?: string): Promise<{
|
|
178
|
+
success: boolean;
|
|
179
|
+
code?: string;
|
|
180
|
+
error?: string;
|
|
181
|
+
}>;
|
|
182
|
+
reviewCode(code: string, requirements: string): Promise<{
|
|
183
|
+
success: boolean;
|
|
184
|
+
review?: string;
|
|
185
|
+
passed: boolean;
|
|
186
|
+
error?: string;
|
|
187
|
+
}>;
|
|
130
188
|
bid(jobId: string, amount: number, message: string): Promise<any>;
|
|
131
189
|
sendMessage(jobId: string, content: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
|
|
132
190
|
setTyping(jobId: string, isTyping?: boolean): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -70,7 +70,7 @@ exports.MessageSchema = zod_1.z.object({
|
|
|
70
70
|
})
|
|
71
71
|
});
|
|
72
72
|
// --- CORE SDK ENGINE ---
|
|
73
|
-
let SDK_VERSION = '1.
|
|
73
|
+
let SDK_VERSION = '1.6.2'; // BUMP to v1.5.7
|
|
74
74
|
try {
|
|
75
75
|
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
76
76
|
SDK_VERSION = pkg.version;
|
|
@@ -411,6 +411,66 @@ class Agent extends events_1.EventEmitter {
|
|
|
411
411
|
return { success: false, error: e.response?.data?.error || e.message };
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
|
+
// --- 📊 PROGRESS TRACKING ---
|
|
415
|
+
async setProgress(jobId, percent) {
|
|
416
|
+
try {
|
|
417
|
+
const progress = Math.min(100, Math.max(0, Math.round(percent)));
|
|
418
|
+
await this.api.post(`jobs/${jobId}/progress`, { progress });
|
|
419
|
+
const job = this.activeMissions.get(jobId);
|
|
420
|
+
if (job) {
|
|
421
|
+
job.progress = progress;
|
|
422
|
+
this.activeMissions.set(jobId, job);
|
|
423
|
+
this.saveState();
|
|
424
|
+
}
|
|
425
|
+
return { success: true };
|
|
426
|
+
}
|
|
427
|
+
catch (e) {
|
|
428
|
+
return { success: false, error: e.response?.data?.error || e.message };
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
// --- 📦 REPO MANAGEMENT ---
|
|
432
|
+
async createRepo(jobId, name) {
|
|
433
|
+
try {
|
|
434
|
+
const res = await this.api.post(`jobs/${jobId}/repo`, { name });
|
|
435
|
+
this.logInternal(`Repo created: ${res.data.repo?.name}`);
|
|
436
|
+
return { success: true, repo: res.data.repo };
|
|
437
|
+
}
|
|
438
|
+
catch (e) {
|
|
439
|
+
return { success: false, error: e.response?.data?.error || e.message };
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
async getRepo(jobId) {
|
|
443
|
+
try {
|
|
444
|
+
const res = await this.api.get(`jobs/${jobId}/repo`);
|
|
445
|
+
return { success: true, exists: res.data.exists, repo: res.data.repo };
|
|
446
|
+
}
|
|
447
|
+
catch (e) {
|
|
448
|
+
if (e.response?.status === 404)
|
|
449
|
+
return { success: true, exists: false };
|
|
450
|
+
return { success: false, exists: false, error: e.response?.data?.error || e.message };
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
async uploadRepoFile(jobId, filePath, content, isBlob = false) {
|
|
454
|
+
try {
|
|
455
|
+
let finalContent;
|
|
456
|
+
if (Buffer.isBuffer(content)) {
|
|
457
|
+
finalContent = content.toString('base64');
|
|
458
|
+
isBlob = true;
|
|
459
|
+
}
|
|
460
|
+
else {
|
|
461
|
+
finalContent = String(content);
|
|
462
|
+
}
|
|
463
|
+
const res = await this.api.post(`jobs/${jobId}/repo/files`, { path: filePath, content: finalContent, isBlob });
|
|
464
|
+
return { success: true, repoId: res.data.repoId };
|
|
465
|
+
}
|
|
466
|
+
catch (e) {
|
|
467
|
+
return { success: false, error: e.response?.data?.error || e.message };
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
isBinaryFile(filePath) {
|
|
471
|
+
const textExts = ['.js', '.ts', '.json', '.md', '.txt', '.html', '.css', '.yml', '.yaml', '.toml'];
|
|
472
|
+
return !textExts.includes(path.extname(filePath).toLowerCase());
|
|
473
|
+
}
|
|
414
474
|
async deliver(jobId, files) {
|
|
415
475
|
const cwd = path.join(this.workspaceRoot, jobId);
|
|
416
476
|
for (const file of files) {
|
|
@@ -421,6 +481,43 @@ class Agent extends events_1.EventEmitter {
|
|
|
421
481
|
}
|
|
422
482
|
}
|
|
423
483
|
}
|
|
484
|
+
// --- ✅ VERIFICATION FLOW ---
|
|
485
|
+
async verifyDeliverables(jobId) {
|
|
486
|
+
try {
|
|
487
|
+
const cwd = path.join(this.workspaceRoot, jobId);
|
|
488
|
+
if (!fs.existsSync(cwd))
|
|
489
|
+
return { success: false, verified: false, error: 'No workspace' };
|
|
490
|
+
const issues = [];
|
|
491
|
+
const files = [];
|
|
492
|
+
const scanDir = (dir, rel = '') => {
|
|
493
|
+
fs.readdirSync(dir).forEach((item) => {
|
|
494
|
+
const full = path.join(dir, item);
|
|
495
|
+
const relPath = path.join(rel, item);
|
|
496
|
+
if (fs.statSync(full).isDirectory())
|
|
497
|
+
scanDir(full, relPath);
|
|
498
|
+
else
|
|
499
|
+
files.push({ path: relPath, size: fs.statSync(full).size });
|
|
500
|
+
});
|
|
501
|
+
};
|
|
502
|
+
scanDir(cwd);
|
|
503
|
+
if (files.length === 0)
|
|
504
|
+
issues.push('No deliverables');
|
|
505
|
+
if (!files.some(f => f.path.toLowerCase().includes('readme')))
|
|
506
|
+
issues.push('Missing README');
|
|
507
|
+
const verified = issues.length === 0;
|
|
508
|
+
return { success: true, verified, files, issues };
|
|
509
|
+
}
|
|
510
|
+
catch (e) {
|
|
511
|
+
return { success: false, verified: false, error: e.message };
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
async preDeliveryCheck(jobId) {
|
|
515
|
+
const verify = await this.verifyDeliverables(jobId);
|
|
516
|
+
const checks = [{ name: 'Deliverables', passed: verify.verified, details: verify.files?.length + ' files' }];
|
|
517
|
+
const job = this.activeMissions.get(jobId);
|
|
518
|
+
checks.push({ name: 'Progress', passed: (job?.progress || 0) >= 80, details: (job?.progress || 0) + '%' });
|
|
519
|
+
return { canDeliver: checks.every(c => c.passed), checks };
|
|
520
|
+
}
|
|
424
521
|
async markComplete(jobId) {
|
|
425
522
|
const res = await this.api.post(`jobs/${jobId}/complete`, { userId: this.agentId, role: 'agent' });
|
|
426
523
|
if (res.data.success) {
|
|
@@ -432,6 +529,46 @@ class Agent extends events_1.EventEmitter {
|
|
|
432
529
|
}
|
|
433
530
|
return res.data;
|
|
434
531
|
}
|
|
532
|
+
// --- 🧠 LLM INTEGRATION ---
|
|
533
|
+
async generate(prompt, options = {}) {
|
|
534
|
+
try {
|
|
535
|
+
const res = await this.api.post('agents/llm/generate', {
|
|
536
|
+
prompt, model: options.model || 'groq/llama-3.3-70b-versatile',
|
|
537
|
+
temperature: options.temperature ?? 0.7, maxTokens: options.maxTokens ?? 2048, system: options.system
|
|
538
|
+
});
|
|
539
|
+
return { success: true, text: res.data.text };
|
|
540
|
+
}
|
|
541
|
+
catch (e) {
|
|
542
|
+
return { success: false, error: e.response?.data?.error || e.message };
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
async analyzeRequirements(job) {
|
|
546
|
+
const prompt = 'Analyze job, return JSON with techStack, features, deliverables, timeline, risks. Title: ' + job.title + ' Desc: ' + job.description.slice(0, 500);
|
|
547
|
+
const res = await this.generate(prompt, { system: 'Extract requirements as JSON', temperature: 0.3 });
|
|
548
|
+
if (!res.success)
|
|
549
|
+
return res;
|
|
550
|
+
try {
|
|
551
|
+
const json = res.text?.match(/\{[^]*\}/)?.[0];
|
|
552
|
+
return { success: true, requirements: JSON.parse(json || '{}') };
|
|
553
|
+
}
|
|
554
|
+
catch {
|
|
555
|
+
return { success: false, error: 'Parse failed' };
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
async codeGenerator(prompt, language = 'javascript') {
|
|
559
|
+
const res = await this.generate(prompt, { system: 'Output only ' + language + ' code', temperature: 0.2, maxTokens: 4000 });
|
|
560
|
+
if (!res.success)
|
|
561
|
+
return res;
|
|
562
|
+
const code = res.text?.match(/```(?:\w+)?\n?([\s\S]*?)```/)?.[1] || res.text;
|
|
563
|
+
return { success: true, code: code?.trim() };
|
|
564
|
+
}
|
|
565
|
+
async reviewCode(code, requirements) {
|
|
566
|
+
const res = await this.generate('Review code. Reqs: ' + requirements + ' Code: ' + code.slice(0, 2000), { system: 'Code reviewer', temperature: 0.3 });
|
|
567
|
+
if (!res.success)
|
|
568
|
+
return { success: false, passed: false, error: res.error };
|
|
569
|
+
const passed = !!(res.text?.toUpperCase().includes('PASS') && !res.text?.toUpperCase().includes('FAIL'));
|
|
570
|
+
return { success: true, review: res.text, passed };
|
|
571
|
+
}
|
|
435
572
|
async bid(jobId, amount, message) {
|
|
436
573
|
try {
|
|
437
574
|
const res = await this.api.post('bids', { jobId, amount, message });
|