akemon 0.2.9 → 0.2.11
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/server.js +13 -1
- package/dist/task-module.js +6 -0
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -342,6 +342,13 @@ export async function serve(options) {
|
|
|
342
342
|
// Wait for engine to become free (poll with backoff, max 5 min)
|
|
343
343
|
const deadline = Date.now() + 5 * 60 * 1000;
|
|
344
344
|
while (engineBusy) {
|
|
345
|
+
// If engine has been busy for >10 min, it's stuck — force release
|
|
346
|
+
if (engineBusySince && Date.now() - engineBusySince > 10 * 60 * 1000) {
|
|
347
|
+
console.log(`[engine] Force-releasing stuck engine lock (busy for ${Math.round((Date.now() - engineBusySince) / 60000)}min)`);
|
|
348
|
+
engineBusy = false;
|
|
349
|
+
engineBusySince = 0;
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
345
352
|
if (Date.now() > deadline) {
|
|
346
353
|
return { success: false, error: "Engine busy timeout (5 min)" };
|
|
347
354
|
}
|
|
@@ -353,7 +360,12 @@ export async function serve(options) {
|
|
|
353
360
|
const prompt = req.context
|
|
354
361
|
? `${req.context}\n\n---\n\n${req.question}`
|
|
355
362
|
: req.question;
|
|
356
|
-
|
|
363
|
+
// Hard timeout: if engine doesn't respond in 8 min, give up
|
|
364
|
+
const engineTimeout = new Promise((_, reject) => setTimeout(() => reject(new Error("Engine execution timeout (8 min)")), 8 * 60 * 1000));
|
|
365
|
+
const response = await Promise.race([
|
|
366
|
+
runEngine(options.engine || "claude", options.model, options.allowAll, prompt, workdir, req.tools, req.relay),
|
|
367
|
+
engineTimeout,
|
|
368
|
+
]);
|
|
357
369
|
// Track token usage via EventBus
|
|
358
370
|
emitTokenUsage(prompt.length, response.length);
|
|
359
371
|
return { success: true, response };
|
package/dist/task-module.js
CHANGED
|
@@ -130,6 +130,12 @@ export class TaskModule {
|
|
|
130
130
|
for (const order of orders) {
|
|
131
131
|
if (this.gaveUp.has(order.id))
|
|
132
132
|
continue;
|
|
133
|
+
// Skip orders older than 1 hour — stale orders shouldn't block the agent
|
|
134
|
+
const orderAge = Date.now() - new Date(order.created_at || 0).getTime();
|
|
135
|
+
if (orderAge > 3_600_000) {
|
|
136
|
+
this.gaveUp.add(order.id);
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
133
139
|
const retry = this.orderRetry.get(order.id);
|
|
134
140
|
if (retry && Date.now() < retry.nextAt)
|
|
135
141
|
continue;
|