bluera-knowledge 0.12.10 → 0.12.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/.claude-plugin/plugin.json +1 -1
- package/dist/{chunk-VTATT3IR.js → chunk-7DZZHYDU.js} +35 -1
- package/dist/chunk-7DZZHYDU.js.map +1 -0
- package/dist/{chunk-6777ULXC.js → chunk-S5VW7NPH.js} +2 -2
- package/dist/{chunk-JET33NMA.js → chunk-XVVMSRLO.js} +3 -2
- package/dist/chunk-XVVMSRLO.js.map +1 -0
- package/dist/index.js +3 -3
- package/dist/mcp/server.js +2 -2
- package/dist/workers/background-worker-cli.js +2 -2
- package/package.json +1 -1
- package/src/mcp/handlers/job.handler.ts +5 -0
- package/src/services/job.service.test.ts +87 -0
- package/src/services/job.service.ts +43 -0
- package/dist/chunk-JET33NMA.js.map +0 -1
- package/dist/chunk-VTATT3IR.js.map +0 -1
- /package/dist/{chunk-6777ULXC.js.map → chunk-S5VW7NPH.js.map} +0 -0
|
@@ -464,6 +464,40 @@ var JobService = class {
|
|
|
464
464
|
}
|
|
465
465
|
return cleaned;
|
|
466
466
|
}
|
|
467
|
+
/**
|
|
468
|
+
* Clean up stale pending jobs that never started or got stuck
|
|
469
|
+
*
|
|
470
|
+
* @param olderThanHours - Consider pending jobs stale after this many hours (default 2)
|
|
471
|
+
* @param options - Options for cleanup behavior
|
|
472
|
+
* @param options.markAsFailed - If true, mark jobs as failed instead of deleting
|
|
473
|
+
* @returns Number of jobs cleaned up or marked as failed
|
|
474
|
+
*/
|
|
475
|
+
cleanupStalePendingJobs(olderThanHours = 2, options = {}) {
|
|
476
|
+
const jobs = this.listJobs();
|
|
477
|
+
const cutoffTime = Date.now() - olderThanHours * 60 * 60 * 1e3;
|
|
478
|
+
let cleaned = 0;
|
|
479
|
+
for (const job of jobs) {
|
|
480
|
+
if (job.status === "pending" && new Date(job.updatedAt).getTime() < cutoffTime) {
|
|
481
|
+
const jobFile = path.join(this.jobsDir, `${job.id}.json`);
|
|
482
|
+
if (options.markAsFailed === true) {
|
|
483
|
+
this.updateJob(job.id, {
|
|
484
|
+
status: "failed",
|
|
485
|
+
message: `Job marked as stale - pending for over ${String(olderThanHours)} hours without progress`
|
|
486
|
+
});
|
|
487
|
+
} else {
|
|
488
|
+
try {
|
|
489
|
+
fs.unlinkSync(jobFile);
|
|
490
|
+
} catch (error) {
|
|
491
|
+
throw new Error(
|
|
492
|
+
`Failed to delete stale job ${job.id}: ${error instanceof Error ? error.message : String(error)}`
|
|
493
|
+
);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
cleaned++;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return cleaned;
|
|
500
|
+
}
|
|
467
501
|
/**
|
|
468
502
|
* Delete a specific job
|
|
469
503
|
*/
|
|
@@ -4617,4 +4651,4 @@ export {
|
|
|
4617
4651
|
createServices,
|
|
4618
4652
|
destroyServices
|
|
4619
4653
|
};
|
|
4620
|
-
//# sourceMappingURL=chunk-
|
|
4654
|
+
//# sourceMappingURL=chunk-7DZZHYDU.js.map
|