rentabots-sdk 1.7.35 → 1.7.37
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 +47 -8
- package/init_templates.js +47 -8
- 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.37'; // 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
|
@@ -234,7 +234,21 @@ async function main() {
|
|
|
234
234
|
fs.writeFileSync(markerPath, JSON.stringify({ at: Date.now(), content: msg.content || '' }));
|
|
235
235
|
} catch (_) {}
|
|
236
236
|
|
|
237
|
-
|
|
237
|
+
const replyPrompt = JSON.stringify([
|
|
238
|
+
'You are mission assistant. Reply briefly to the human and confirm implementation has started.',
|
|
239
|
+
'Return only the reply message text.',
|
|
240
|
+
'HUMAN MESSAGE: ' + (msg.content || ''),
|
|
241
|
+
'MISSION TITLE: ' + (job.title || ''),
|
|
242
|
+
].join('\n'));
|
|
243
|
+
let autoReply = '🧠 Got it. I am applying your instruction now and will deliver updated output shortly.';
|
|
244
|
+
for (const c of ['openclaw sessions spawn --task ' + replyPrompt, 'openclaw sessions_spawn --task ' + replyPrompt]) {
|
|
245
|
+
const r = await queen.execute(msg.jobId, c, { timeout: 120000, shell: true });
|
|
246
|
+
const out = (r.output || '').trim();
|
|
247
|
+
if (r.exitCode === 0 && out && !/unknown command|usage: openclaw/i.test(out)) { autoReply = out.slice(-500); break; }
|
|
248
|
+
if (!/unknown command/i.test(out)) break;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
await queen.sendMessage(msg.jobId, autoReply);
|
|
238
252
|
await spawnMissionWorker(job, 'human-followup', { watchAfterClarification: true, baselineFiles });
|
|
239
253
|
});
|
|
240
254
|
|
|
@@ -339,6 +353,22 @@ async function main() {
|
|
|
339
353
|
'openclaw sessions_spawn --task ' + taskArg,
|
|
340
354
|
];
|
|
341
355
|
|
|
356
|
+
const countMeaningfulFiles = () => {
|
|
357
|
+
const skip = new Set(['ACCEPTANCE.json', 'DELIVERY_SUMMARY.md', 'FAILSAFE_REPORT.md']);
|
|
358
|
+
const files = [];
|
|
359
|
+
const walk = (dir) => {
|
|
360
|
+
if (!fs.existsSync(dir)) return;
|
|
361
|
+
for (const item of fs.readdirSync(dir)) {
|
|
362
|
+
if (item === 'node_modules' || item === '.git' || item.startsWith('.') || skip.has(item)) continue;
|
|
363
|
+
const full = path.join(dir, item);
|
|
364
|
+
if (fs.statSync(full).isDirectory()) walk(full);
|
|
365
|
+
else files.push(full);
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
walk(workDir);
|
|
369
|
+
return files.length;
|
|
370
|
+
};
|
|
371
|
+
|
|
342
372
|
let beat = 0;
|
|
343
373
|
const heartbeat = setInterval(async () => {
|
|
344
374
|
try {
|
|
@@ -363,6 +393,7 @@ async function main() {
|
|
|
363
393
|
let output = '';
|
|
364
394
|
|
|
365
395
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
396
|
+
const beforeCount = countMeaningfulFiles();
|
|
366
397
|
const result = await agent.execute(job.id, cmd, { timeout: 1200000, shell: true }); // 20m
|
|
367
398
|
exitCode = result.exitCode;
|
|
368
399
|
output = result.output || '';
|
|
@@ -371,9 +402,14 @@ async function main() {
|
|
|
371
402
|
const low = (output || '').toLowerCase();
|
|
372
403
|
const pseudoSuccess = low.includes('usage: openclaw') || low.includes('pass --to') || low.includes('unknown command');
|
|
373
404
|
if (!pseudoSuccess) {
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
405
|
+
await new Promise(r => setTimeout(r, 1200));
|
|
406
|
+
const afterCount = countMeaningfulFiles();
|
|
407
|
+
if (afterCount > beforeCount) {
|
|
408
|
+
overallSuccess = true;
|
|
409
|
+
lastOutput = output;
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
await agent.sendMessage(job.id, '⚠️ OpenClaw returned but no new implementation files were created. Forcing file-creation repair pass.');
|
|
377
413
|
}
|
|
378
414
|
}
|
|
379
415
|
|
|
@@ -511,7 +547,7 @@ async function main() {
|
|
|
511
547
|
} else if (contract.adapter === 'docs') {
|
|
512
548
|
const hasDocFile = hasFile((f) => f.toLowerCase().endsWith('.md'));
|
|
513
549
|
const hasSections = /(##\s+overview|##\s+setup|##\s+usage|table of contents|getting started)/i.test(combinedText);
|
|
514
|
-
const hasExamples = /(example|sample|command|curl|code block
|
|
550
|
+
const hasExamples = /(example|sample|command|curl|code block)/i.test(combinedText);
|
|
515
551
|
if (!hasDocFile) issues.push('docs adapter: missing markdown documentation');
|
|
516
552
|
if (!hasSections) issues.push('docs adapter: missing core documentation sections');
|
|
517
553
|
if (!hasExamples) issues.push('docs adapter: missing usage examples');
|
|
@@ -536,8 +572,9 @@ async function main() {
|
|
|
536
572
|
fs.writeFileSync(repairPath, String(repairCount));
|
|
537
573
|
|
|
538
574
|
if (repairCount > 6) {
|
|
539
|
-
await agent.sendMessage(job.id, '
|
|
540
|
-
|
|
575
|
+
await agent.sendMessage(job.id, '🔁 OpenClaw repair limit exceeded; continuing autonomous deep-repair cycle.');
|
|
576
|
+
repairCount = 3;
|
|
577
|
+
fs.writeFileSync(repairPath, String(repairCount));
|
|
541
578
|
}
|
|
542
579
|
|
|
543
580
|
const repairPrompt = [
|
|
@@ -705,7 +742,9 @@ async function main() {
|
|
|
705
742
|
|
|
706
743
|
// Fail-safe report only after OpenClaw retry budget exhausted
|
|
707
744
|
await agent.setProgress(job.id, 25);
|
|
708
|
-
await agent.sendMessage(job.id, "
|
|
745
|
+
await agent.sendMessage(job.id, "🔁 OpenClaw execution still failing after retries. Continuing autonomous retries with adjusted strategy.");
|
|
746
|
+
await new Promise(r => setTimeout(r, 8000));
|
|
747
|
+
process.exit(42);
|
|
709
748
|
|
|
710
749
|
try {
|
|
711
750
|
const repoRes = await agent.getRepo(job.id);
|
package/init_templates.js
CHANGED
|
@@ -203,7 +203,21 @@ async function main() {
|
|
|
203
203
|
fs.writeFileSync(markerPath, JSON.stringify({ at: Date.now(), content: msg.content || '' }));
|
|
204
204
|
} catch (_) {}
|
|
205
205
|
|
|
206
|
-
|
|
206
|
+
const replyPrompt = JSON.stringify([
|
|
207
|
+
'You are mission assistant. Reply briefly to the human and confirm implementation has started.',
|
|
208
|
+
'Return only the reply message text.',
|
|
209
|
+
'HUMAN MESSAGE: ' + (msg.content || ''),
|
|
210
|
+
'MISSION TITLE: ' + (job.title || ''),
|
|
211
|
+
].join('\n'));
|
|
212
|
+
let autoReply = '🧠 Got it. I am applying your instruction now and will deliver updated output shortly.';
|
|
213
|
+
for (const c of ['openclaw sessions spawn --task ' + replyPrompt, 'openclaw sessions_spawn --task ' + replyPrompt]) {
|
|
214
|
+
const r = await queen.execute(msg.jobId, c, { timeout: 120000, shell: true });
|
|
215
|
+
const out = (r.output || '').trim();
|
|
216
|
+
if (r.exitCode === 0 && out && !/unknown command|usage: openclaw/i.test(out)) { autoReply = out.slice(-500); break; }
|
|
217
|
+
if (!/unknown command/i.test(out)) break;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
await queen.sendMessage(msg.jobId, autoReply);
|
|
207
221
|
await spawnMissionWorker(job, 'human-followup', { watchAfterClarification: true, baselineFiles });
|
|
208
222
|
});
|
|
209
223
|
|
|
@@ -323,6 +337,22 @@ async function main() {
|
|
|
323
337
|
'openclaw sessions_spawn --task ' + taskArg,
|
|
324
338
|
];
|
|
325
339
|
|
|
340
|
+
const countMeaningfulFiles = () => {
|
|
341
|
+
const skip = new Set(['ACCEPTANCE.json', 'DELIVERY_SUMMARY.md', 'FAILSAFE_REPORT.md']);
|
|
342
|
+
const files = [];
|
|
343
|
+
const walk = (dir) => {
|
|
344
|
+
if (!fs.existsSync(dir)) return;
|
|
345
|
+
for (const item of fs.readdirSync(dir)) {
|
|
346
|
+
if (item === 'node_modules' || item === '.git' || item.startsWith('.') || skip.has(item)) continue;
|
|
347
|
+
const full = path.join(dir, item);
|
|
348
|
+
if (fs.statSync(full).isDirectory()) walk(full);
|
|
349
|
+
else files.push(full);
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
walk(workDir);
|
|
353
|
+
return files.length;
|
|
354
|
+
};
|
|
355
|
+
|
|
326
356
|
let beat = 0;
|
|
327
357
|
const heartbeat = setInterval(async () => {
|
|
328
358
|
try {
|
|
@@ -347,6 +377,7 @@ async function main() {
|
|
|
347
377
|
let output = '';
|
|
348
378
|
|
|
349
379
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
380
|
+
const beforeCount = countMeaningfulFiles();
|
|
350
381
|
const result = await agent.execute(job.id, cmd, { timeout: 1200000, shell: true }); // 20m
|
|
351
382
|
exitCode = result.exitCode;
|
|
352
383
|
output = result.output || '';
|
|
@@ -355,9 +386,14 @@ async function main() {
|
|
|
355
386
|
const low = (output || '').toLowerCase();
|
|
356
387
|
const pseudoSuccess = low.includes('usage: openclaw') || low.includes('pass --to') || low.includes('unknown command');
|
|
357
388
|
if (!pseudoSuccess) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
389
|
+
await new Promise(r => setTimeout(r, 1200));
|
|
390
|
+
const afterCount = countMeaningfulFiles();
|
|
391
|
+
if (afterCount > beforeCount) {
|
|
392
|
+
overallSuccess = true;
|
|
393
|
+
lastOutput = output;
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
await agent.sendMessage(job.id, '⚠️ OpenClaw returned but no new implementation files were created. Forcing file-creation repair pass.');
|
|
361
397
|
}
|
|
362
398
|
}
|
|
363
399
|
|
|
@@ -496,7 +532,7 @@ async function main() {
|
|
|
496
532
|
} else if (contract.adapter === 'docs') {
|
|
497
533
|
const hasDocFile = hasFile((f) => f.toLowerCase().endsWith('.md'));
|
|
498
534
|
const hasSections = /(##\s+overview|##\s+setup|##\s+usage|table of contents|getting started)/i.test(combinedText);
|
|
499
|
-
const hasExamples = /(example|sample|command|curl|code block
|
|
535
|
+
const hasExamples = /(example|sample|command|curl|code block)/i.test(combinedText);
|
|
500
536
|
if (!hasDocFile) issues.push('docs adapter: missing markdown documentation');
|
|
501
537
|
if (!hasSections) issues.push('docs adapter: missing core documentation sections');
|
|
502
538
|
if (!hasExamples) issues.push('docs adapter: missing usage examples');
|
|
@@ -521,8 +557,9 @@ async function main() {
|
|
|
521
557
|
fs.writeFileSync(repairPath, String(repairCount));
|
|
522
558
|
|
|
523
559
|
if (repairCount > 6) {
|
|
524
|
-
await agent.sendMessage(job.id, '
|
|
525
|
-
|
|
560
|
+
await agent.sendMessage(job.id, '🔁 OpenClaw repair limit exceeded; continuing autonomous deep-repair cycle.');
|
|
561
|
+
repairCount = 3;
|
|
562
|
+
fs.writeFileSync(repairPath, String(repairCount));
|
|
526
563
|
}
|
|
527
564
|
|
|
528
565
|
const repairPrompt = [
|
|
@@ -690,7 +727,9 @@ async function main() {
|
|
|
690
727
|
|
|
691
728
|
// Fail-safe report only after OpenClaw retry budget exhausted
|
|
692
729
|
await agent.setProgress(job.id, 25);
|
|
693
|
-
await agent.sendMessage(job.id, "
|
|
730
|
+
await agent.sendMessage(job.id, "🔁 OpenClaw execution still failing after retries. Continuing autonomous retries with adjusted strategy.");
|
|
731
|
+
await new Promise(r => setTimeout(r, 8000));
|
|
732
|
+
process.exit(42);
|
|
694
733
|
|
|
695
734
|
try {
|
|
696
735
|
const repoRes = await agent.getRepo(job.id);
|