rentabots-sdk 1.7.39 → 1.7.41
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 +43 -14
- package/init_templates.js +43 -14
- 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.41'; // 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
|
@@ -115,6 +115,24 @@ async function main() {
|
|
|
115
115
|
} catch (_) { return 0; }
|
|
116
116
|
};
|
|
117
117
|
|
|
118
|
+
const getMeaningfulRepoFileCount = async (jobId) => {
|
|
119
|
+
try {
|
|
120
|
+
const repoRes = await queen.getRepo(jobId);
|
|
121
|
+
if (!repoRes.success || !repoRes.exists || !repoRes.repo?.id) return 0;
|
|
122
|
+
const res = await fetch(apiBase + '/repos/' + repoRes.repo.id + '/files', {
|
|
123
|
+
headers: { Authorization: 'Bearer ' + agentApiKey }
|
|
124
|
+
});
|
|
125
|
+
const data = await res.json();
|
|
126
|
+
const files = Array.isArray(data.files) ? data.files : [];
|
|
127
|
+
const skip = new Set(['ACCEPTANCE.json', 'DELIVERY_SUMMARY.md', 'FAILSAFE_REPORT.md', '.repair_count', '.last_delivery_hash']);
|
|
128
|
+
return files.filter((f) => {
|
|
129
|
+
const p = String(f.path || f.name || '').split('/').pop();
|
|
130
|
+
if (!p || p.startsWith('.')) return false;
|
|
131
|
+
return !skip.has(p);
|
|
132
|
+
}).length;
|
|
133
|
+
} catch (_) { return 0; }
|
|
134
|
+
};
|
|
135
|
+
|
|
118
136
|
const spawnMissionWorker = async (job, source = 'assignment', opts = {}) => {
|
|
119
137
|
try {
|
|
120
138
|
const jobDataPath = path.join(__dirname, 'workspace', '_job_' + job.id + '.json');
|
|
@@ -196,6 +214,11 @@ async function main() {
|
|
|
196
214
|
// Recover workers for already-active missions after restart
|
|
197
215
|
for (const [jobId, job] of queen.activeMissions) {
|
|
198
216
|
if (queen.workers.has(jobId)) continue;
|
|
217
|
+
const existing = await getMeaningfulRepoFileCount(jobId);
|
|
218
|
+
if (existing > 0) {
|
|
219
|
+
await pushLog('INFO', 'Recovery skip for ' + jobId + ': found ' + existing + ' existing deliverable file(s). Waiting for human update.');
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
199
222
|
await spawnMissionWorker(job, 'recovery');
|
|
200
223
|
}
|
|
201
224
|
|
|
@@ -234,21 +257,27 @@ async function main() {
|
|
|
234
257
|
fs.writeFileSync(markerPath, JSON.stringify({ at: Date.now(), content: msg.content || '' }));
|
|
235
258
|
} catch (_) {}
|
|
236
259
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
260
|
+
// Immediate human ack so chat never feels ignored
|
|
261
|
+
await queen.sendMessage(msg.jobId, '🧠 Got it — applying your instruction now.');
|
|
262
|
+
|
|
263
|
+
try {
|
|
264
|
+
const replyPrompt = JSON.stringify([
|
|
265
|
+
'You are mission assistant. Reply briefly to the human and confirm what will be changed next.',
|
|
266
|
+
'Return only one short reply message text.',
|
|
267
|
+
'HUMAN MESSAGE: ' + (msg.content || ''),
|
|
268
|
+
'MISSION TITLE: ' + (job.title || ''),
|
|
269
|
+
].join('\\n'));
|
|
270
|
+
for (const c of ['openclaw sessions spawn --task ' + replyPrompt, 'openclaw sessions_spawn --task ' + replyPrompt]) {
|
|
271
|
+
const r = await queen.execute(msg.jobId, c, { timeout: 45000, shell: true });
|
|
272
|
+
const out = (r.output || '').trim();
|
|
273
|
+
if (r.exitCode === 0 && out && !/unknown command|usage: openclaw/i.test(out)) {
|
|
274
|
+
await queen.sendMessage(msg.jobId, out.slice(-500));
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
if (!/unknown command/i.test(out)) break;
|
|
278
|
+
}
|
|
279
|
+
} catch (_) {}
|
|
250
280
|
|
|
251
|
-
await queen.sendMessage(msg.jobId, autoReply);
|
|
252
281
|
await spawnMissionWorker(job, 'human-followup', { watchAfterClarification: true, baselineFiles });
|
|
253
282
|
});
|
|
254
283
|
|
package/init_templates.js
CHANGED
|
@@ -84,6 +84,24 @@ async function main() {
|
|
|
84
84
|
} catch (_) { return 0; }
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
const getMeaningfulRepoFileCount = async (jobId) => {
|
|
88
|
+
try {
|
|
89
|
+
const repoRes = await queen.getRepo(jobId);
|
|
90
|
+
if (!repoRes.success || !repoRes.exists || !repoRes.repo?.id) return 0;
|
|
91
|
+
const res = await fetch(apiBase + '/repos/' + repoRes.repo.id + '/files', {
|
|
92
|
+
headers: { Authorization: 'Bearer ' + agentApiKey }
|
|
93
|
+
});
|
|
94
|
+
const data = await res.json();
|
|
95
|
+
const files = Array.isArray(data.files) ? data.files : [];
|
|
96
|
+
const skip = new Set(['ACCEPTANCE.json', 'DELIVERY_SUMMARY.md', 'FAILSAFE_REPORT.md', '.repair_count', '.last_delivery_hash']);
|
|
97
|
+
return files.filter((f) => {
|
|
98
|
+
const p = String(f.path || f.name || '').split('/').pop();
|
|
99
|
+
if (!p || p.startsWith('.')) return false;
|
|
100
|
+
return !skip.has(p);
|
|
101
|
+
}).length;
|
|
102
|
+
} catch (_) { return 0; }
|
|
103
|
+
};
|
|
104
|
+
|
|
87
105
|
const spawnMissionWorker = async (job, source = 'assignment', opts = {}) => {
|
|
88
106
|
try {
|
|
89
107
|
const jobDataPath = path.join(__dirname, 'workspace', '_job_' + job.id + '.json');
|
|
@@ -165,6 +183,11 @@ async function main() {
|
|
|
165
183
|
// Recover workers for already-active missions after restart
|
|
166
184
|
for (const [jobId, job] of queen.activeMissions) {
|
|
167
185
|
if (queen.workers.has(jobId)) continue;
|
|
186
|
+
const existing = await getMeaningfulRepoFileCount(jobId);
|
|
187
|
+
if (existing > 0) {
|
|
188
|
+
await pushLog('INFO', 'Recovery skip for ' + jobId + ': found ' + existing + ' existing deliverable file(s). Waiting for human update.');
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
168
191
|
await spawnMissionWorker(job, 'recovery');
|
|
169
192
|
}
|
|
170
193
|
|
|
@@ -203,21 +226,27 @@ async function main() {
|
|
|
203
226
|
fs.writeFileSync(markerPath, JSON.stringify({ at: Date.now(), content: msg.content || '' }));
|
|
204
227
|
} catch (_) {}
|
|
205
228
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
229
|
+
// Immediate human ack so chat never feels ignored
|
|
230
|
+
await queen.sendMessage(msg.jobId, '🧠 Got it — applying your instruction now.');
|
|
231
|
+
|
|
232
|
+
try {
|
|
233
|
+
const replyPrompt = JSON.stringify([
|
|
234
|
+
'You are mission assistant. Reply briefly to the human and confirm what will be changed next.',
|
|
235
|
+
'Return only one short reply message text.',
|
|
236
|
+
'HUMAN MESSAGE: ' + (msg.content || ''),
|
|
237
|
+
'MISSION TITLE: ' + (job.title || ''),
|
|
238
|
+
].join('\\n'));
|
|
239
|
+
for (const c of ['openclaw sessions spawn --task ' + replyPrompt, 'openclaw sessions_spawn --task ' + replyPrompt]) {
|
|
240
|
+
const r = await queen.execute(msg.jobId, c, { timeout: 45000, shell: true });
|
|
241
|
+
const out = (r.output || '').trim();
|
|
242
|
+
if (r.exitCode === 0 && out && !/unknown command|usage: openclaw/i.test(out)) {
|
|
243
|
+
await queen.sendMessage(msg.jobId, out.slice(-500));
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
if (!/unknown command/i.test(out)) break;
|
|
247
|
+
}
|
|
248
|
+
} catch (_) {}
|
|
219
249
|
|
|
220
|
-
await queen.sendMessage(msg.jobId, autoReply);
|
|
221
250
|
await spawnMissionWorker(job, 'human-followup', { watchAfterClarification: true, baselineFiles });
|
|
222
251
|
});
|
|
223
252
|
|