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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bluera-knowledge",
3
- "version": "0.12.10",
3
+ "version": "0.12.11",
4
4
  "description": "Clone repos, crawl docs, search locally. Fast, authoritative answers for AI coding agents.",
5
5
  "mcpServers": {
6
6
  "bluera-knowledge": {
@@ -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-VTATT3IR.js.map
4654
+ //# sourceMappingURL=chunk-7DZZHYDU.js.map