rentabots-sdk 1.7.26 → 1.7.27
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.js +1 -1
- package/init.js +52 -16
- package/init_templates.js +52 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ exports.MessageSchema = zod_1.z.object({
|
|
|
71
71
|
})
|
|
72
72
|
});
|
|
73
73
|
// --- CORE SDK ENGINE ---
|
|
74
|
-
let SDK_VERSION = '1.7.
|
|
74
|
+
let SDK_VERSION = '1.7.27'; // fallback when package.json is unavailable
|
|
75
75
|
try {
|
|
76
76
|
const pkg = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf8'));
|
|
77
77
|
SDK_VERSION = pkg.version;
|
package/init.js
CHANGED
|
@@ -497,8 +497,43 @@ async function main() {
|
|
|
497
497
|
|
|
498
498
|
if (issues.length > 0) {
|
|
499
499
|
await agent.setProgress(job.id, 70);
|
|
500
|
-
await agent.sendMessage(job.id, '⚠️ Contract QA failed: ' + issues.slice(0, 4).join('; ') + '.
|
|
501
|
-
|
|
500
|
+
await agent.sendMessage(job.id, '⚠️ Contract QA failed: ' + issues.slice(0, 4).join('; ') + '. Running targeted OpenClaw repair pass now.');
|
|
501
|
+
|
|
502
|
+
const repairPath = path.join(workDir, '.repair_count');
|
|
503
|
+
let repairCount = 0;
|
|
504
|
+
try { repairCount = Number(fs.readFileSync(repairPath, 'utf8') || '0'); } catch (_) {}
|
|
505
|
+
repairCount += 1;
|
|
506
|
+
fs.writeFileSync(repairPath, String(repairCount));
|
|
507
|
+
|
|
508
|
+
if (repairCount > 6) {
|
|
509
|
+
await agent.sendMessage(job.id, '🚨 OpenClaw repair limit reached. Please send one concrete clarification so I can continue with a precise fix.');
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
const repairPrompt = [
|
|
514
|
+
'Repair the existing workspace to satisfy missing deterministic gates.',
|
|
515
|
+
'Do not explain. Edit files now and finish.',
|
|
516
|
+
'MISSING GATES:',
|
|
517
|
+
...issues.map(i => '- ' + i),
|
|
518
|
+
'',
|
|
519
|
+
'MISSION TITLE: ' + job.title,
|
|
520
|
+
'MISSION DESCRIPTION: ' + job.description,
|
|
521
|
+
].join('\n');
|
|
522
|
+
|
|
523
|
+
const repairArg = JSON.stringify(repairPrompt);
|
|
524
|
+
const repairCmds = [
|
|
525
|
+
'openclaw sessions spawn --task ' + repairArg,
|
|
526
|
+
'openclaw sessions_spawn --task ' + repairArg,
|
|
527
|
+
];
|
|
528
|
+
for (const rcmd of repairCmds) {
|
|
529
|
+
const r = await agent.execute(job.id, rcmd, { timeout: 900000, shell: true });
|
|
530
|
+
const out = (r.output || '').toLowerCase();
|
|
531
|
+
const pseudo = out.includes('usage: openclaw') || out.includes('unknown command') || out.includes('pass --to');
|
|
532
|
+
if (r.exitCode === 0 && !pseudo) break;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
await agent.sendMessage(job.id, '🔁 OpenClaw repair pass complete. Re-validating now.');
|
|
536
|
+
return main();
|
|
502
537
|
}
|
|
503
538
|
|
|
504
539
|
if (fallbackGenerated) {
|
|
@@ -614,28 +649,29 @@ async function main() {
|
|
|
614
649
|
const snippet = lastOutput.slice(-500) || 'No output captured';
|
|
615
650
|
console.error("Worker Error:", snippet);
|
|
616
651
|
|
|
617
|
-
|
|
652
|
+
const failPath = path.join(workDir, '.openclaw_fail_count');
|
|
653
|
+
let fails = 0;
|
|
654
|
+
try { fails = Number(fs.readFileSync(failPath, 'utf8') || '0'); } catch (_) {}
|
|
655
|
+
fails += 1;
|
|
656
|
+
fs.writeFileSync(failPath, String(fails));
|
|
657
|
+
|
|
658
|
+
if (fails <= 5) {
|
|
659
|
+
await agent.setProgress(job.id, 25);
|
|
660
|
+
await agent.sendMessage(job.id, '⚠️ OpenClaw run failed (attempt ' + fails + '). Auto-retrying with OpenClaw only...');
|
|
661
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
662
|
+
return main();
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
// Fail-safe report only after OpenClaw retry budget exhausted
|
|
618
666
|
await agent.setProgress(job.id, 25);
|
|
619
|
-
await agent.sendMessage(job.id, "
|
|
667
|
+
await agent.sendMessage(job.id, "🚨 OpenClaw execution repeatedly failed. Please send one concrete clarification and I will continue immediately.");
|
|
620
668
|
|
|
621
669
|
try {
|
|
622
|
-
generateAdapterFallbackFiles(workDir, job, contract);
|
|
623
|
-
|
|
624
670
|
const repoRes = await agent.getRepo(job.id);
|
|
625
671
|
if (!repoRes.success || !repoRes.exists) {
|
|
626
672
|
await agent.createRepo(job.id, 'mission-recovery-' + job.id.slice(0, 8));
|
|
627
673
|
}
|
|
628
674
|
|
|
629
|
-
// Upload fallback draft artifacts first
|
|
630
|
-
const fallbackFiles = fs.readdirSync(workDir).filter((f) => fs.statSync(path.join(workDir, f)).isFile());
|
|
631
|
-
for (const f of fallbackFiles) {
|
|
632
|
-
try {
|
|
633
|
-
const full = path.join(workDir, f);
|
|
634
|
-
const content = fs.readFileSync(full, 'utf8');
|
|
635
|
-
await agent.uploadRepoFile(job.id, f, content, false);
|
|
636
|
-
} catch (_) {}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
675
|
const report = [
|
|
640
676
|
'# FAILSAFE_REPORT',
|
|
641
677
|
'',
|
package/init_templates.js
CHANGED
|
@@ -482,8 +482,43 @@ async function main() {
|
|
|
482
482
|
|
|
483
483
|
if (issues.length > 0) {
|
|
484
484
|
await agent.setProgress(job.id, 70);
|
|
485
|
-
await agent.sendMessage(job.id, '⚠️ Contract QA failed: ' + issues.slice(0, 4).join('; ') + '.
|
|
486
|
-
|
|
485
|
+
await agent.sendMessage(job.id, '⚠️ Contract QA failed: ' + issues.slice(0, 4).join('; ') + '. Running targeted OpenClaw repair pass now.');
|
|
486
|
+
|
|
487
|
+
const repairPath = path.join(workDir, '.repair_count');
|
|
488
|
+
let repairCount = 0;
|
|
489
|
+
try { repairCount = Number(fs.readFileSync(repairPath, 'utf8') || '0'); } catch (_) {}
|
|
490
|
+
repairCount += 1;
|
|
491
|
+
fs.writeFileSync(repairPath, String(repairCount));
|
|
492
|
+
|
|
493
|
+
if (repairCount > 6) {
|
|
494
|
+
await agent.sendMessage(job.id, '🚨 OpenClaw repair limit reached. Please send one concrete clarification so I can continue with a precise fix.');
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
const repairPrompt = [
|
|
499
|
+
'Repair the existing workspace to satisfy missing deterministic gates.',
|
|
500
|
+
'Do not explain. Edit files now and finish.',
|
|
501
|
+
'MISSING GATES:',
|
|
502
|
+
...issues.map(i => '- ' + i),
|
|
503
|
+
'',
|
|
504
|
+
'MISSION TITLE: ' + job.title,
|
|
505
|
+
'MISSION DESCRIPTION: ' + job.description,
|
|
506
|
+
].join('\n');
|
|
507
|
+
|
|
508
|
+
const repairArg = JSON.stringify(repairPrompt);
|
|
509
|
+
const repairCmds = [
|
|
510
|
+
'openclaw sessions spawn --task ' + repairArg,
|
|
511
|
+
'openclaw sessions_spawn --task ' + repairArg,
|
|
512
|
+
];
|
|
513
|
+
for (const rcmd of repairCmds) {
|
|
514
|
+
const r = await agent.execute(job.id, rcmd, { timeout: 900000, shell: true });
|
|
515
|
+
const out = (r.output || '').toLowerCase();
|
|
516
|
+
const pseudo = out.includes('usage: openclaw') || out.includes('unknown command') || out.includes('pass --to');
|
|
517
|
+
if (r.exitCode === 0 && !pseudo) break;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
await agent.sendMessage(job.id, '🔁 OpenClaw repair pass complete. Re-validating now.');
|
|
521
|
+
return main();
|
|
487
522
|
}
|
|
488
523
|
|
|
489
524
|
if (fallbackGenerated) {
|
|
@@ -599,28 +634,29 @@ async function main() {
|
|
|
599
634
|
const snippet = lastOutput.slice(-500) || 'No output captured';
|
|
600
635
|
console.error("Worker Error:", snippet);
|
|
601
636
|
|
|
602
|
-
|
|
637
|
+
const failPath = path.join(workDir, '.openclaw_fail_count');
|
|
638
|
+
let fails = 0;
|
|
639
|
+
try { fails = Number(fs.readFileSync(failPath, 'utf8') || '0'); } catch (_) {}
|
|
640
|
+
fails += 1;
|
|
641
|
+
fs.writeFileSync(failPath, String(fails));
|
|
642
|
+
|
|
643
|
+
if (fails <= 5) {
|
|
644
|
+
await agent.setProgress(job.id, 25);
|
|
645
|
+
await agent.sendMessage(job.id, '⚠️ OpenClaw run failed (attempt ' + fails + '). Auto-retrying with OpenClaw only...');
|
|
646
|
+
await new Promise(r => setTimeout(r, 5000));
|
|
647
|
+
return main();
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
// Fail-safe report only after OpenClaw retry budget exhausted
|
|
603
651
|
await agent.setProgress(job.id, 25);
|
|
604
|
-
await agent.sendMessage(job.id, "
|
|
652
|
+
await agent.sendMessage(job.id, "🚨 OpenClaw execution repeatedly failed. Please send one concrete clarification and I will continue immediately.");
|
|
605
653
|
|
|
606
654
|
try {
|
|
607
|
-
generateAdapterFallbackFiles(workDir, job, contract);
|
|
608
|
-
|
|
609
655
|
const repoRes = await agent.getRepo(job.id);
|
|
610
656
|
if (!repoRes.success || !repoRes.exists) {
|
|
611
657
|
await agent.createRepo(job.id, 'mission-recovery-' + job.id.slice(0, 8));
|
|
612
658
|
}
|
|
613
659
|
|
|
614
|
-
// Upload fallback draft artifacts first
|
|
615
|
-
const fallbackFiles = fs.readdirSync(workDir).filter((f) => fs.statSync(path.join(workDir, f)).isFile());
|
|
616
|
-
for (const f of fallbackFiles) {
|
|
617
|
-
try {
|
|
618
|
-
const full = path.join(workDir, f);
|
|
619
|
-
const content = fs.readFileSync(full, 'utf8');
|
|
620
|
-
await agent.uploadRepoFile(job.id, f, content, false);
|
|
621
|
-
} catch (_) {}
|
|
622
|
-
}
|
|
623
|
-
|
|
624
660
|
const report = [
|
|
625
661
|
'# FAILSAFE_REPORT',
|
|
626
662
|
'',
|