@warlock.js/queue 5.33.0 → 5.34.1

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.
Files changed (52) hide show
  1. package/CHANGELOG.md +9 -54
  2. package/README.md +18 -3
  3. package/cjs/index.cjs +644 -168
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/dashboard-boot.mjs +1 -0
  6. package/esm/dashboard-boot.mjs.map +1 -1
  7. package/esm/dashboard.d.mts.map +1 -1
  8. package/esm/dashboard.mjs +2 -1
  9. package/esm/dashboard.mjs.map +1 -1
  10. package/esm/define-job.d.mts +0 -1
  11. package/esm/define-job.d.mts.map +1 -1
  12. package/esm/define-job.mjs +11 -64
  13. package/esm/define-job.mjs.map +1 -1
  14. package/esm/driver.d.mts +23 -0
  15. package/esm/driver.d.mts.map +1 -0
  16. package/esm/drivers/bullmq.mjs +132 -0
  17. package/esm/drivers/bullmq.mjs.map +1 -0
  18. package/esm/drivers/local-store.mjs +9 -0
  19. package/esm/drivers/local-store.mjs.map +1 -0
  20. package/esm/drivers/local.mjs +307 -0
  21. package/esm/drivers/local.mjs.map +1 -0
  22. package/esm/drivers/memory-store.mjs +48 -0
  23. package/esm/drivers/memory-store.mjs.map +1 -0
  24. package/esm/drivers/sqlite-store.mjs +89 -0
  25. package/esm/drivers/sqlite-store.mjs.map +1 -0
  26. package/esm/failed-jobs.d.mts +2 -8
  27. package/esm/failed-jobs.d.mts.map +1 -1
  28. package/esm/failed-jobs.mjs +5 -30
  29. package/esm/failed-jobs.mjs.map +1 -1
  30. package/esm/index.d.mts +4 -2
  31. package/esm/index.mjs +2 -1
  32. package/esm/job-options.d.mts +9 -0
  33. package/esm/job-options.d.mts.map +1 -0
  34. package/esm/job-options.mjs +20 -0
  35. package/esm/job-options.mjs.map +1 -0
  36. package/esm/queue-driver.d.mts +6 -0
  37. package/esm/queue-driver.d.mts.map +1 -0
  38. package/esm/queue-driver.mjs +37 -0
  39. package/esm/queue-driver.mjs.map +1 -0
  40. package/esm/queue-manager.d.mts +5 -26
  41. package/esm/queue-manager.d.mts.map +1 -1
  42. package/esm/queue-manager.mjs +28 -84
  43. package/esm/queue-manager.mjs.map +1 -1
  44. package/esm/types.d.mts +18 -5
  45. package/esm/types.d.mts.map +1 -1
  46. package/llms-full.txt +129 -3
  47. package/llms.txt +2 -1
  48. package/package.json +4 -4
  49. package/skills/configure-queue/SKILL.md +1 -1
  50. package/skills/index.md +4 -2
  51. package/skills/local-queues/SKILL.md +121 -0
  52. package/skills/overview/SKILL.md +3 -2
package/CHANGELOG.md CHANGED
@@ -1,14 +1,17 @@
1
- # Changelog — @warlock.js/queue
1
+ # Changelog — @warlock.js/queue
2
2
 
3
3
  All notable changes to `@warlock.js/queue` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
- ## 5.33.0 - 2026-10-19
7
+ ## 5.34.0 - 2026-10-19
8
8
 
9
- ### Changed
9
+ ### Added
10
10
 
11
- - Lockstep release; package APIs are unchanged.
11
+ - Select `driver: "local"` for durable single-host SQLite queues using Node's built-in `node:sqlite` without Redis, or `driver: "memory"` for tests executing real handlers. Existing configuration defaults to BullMQ.
12
+ - A shared `QueueDriver` contract and `getQueueDriver()` for dispatch, snapshots, failed-job recovery, and worker lifecycle across all backends.
13
+ - Local/memory delays, priorities, retries with fixed/exponential backoff, retention, per-queue concurrency, context propagation, progress, and results through the existing `defineJob()` API.
14
+ - Transactional claims, renewable fenced leases, recovery after worker crashes, and bounded graceful shutdown releasing unfinished local jobs. Local/memory handlers receive an optional cancellation `signal`.
12
15
 
13
16
  ## 5.32.0 - 2026-10-18
14
17
 
@@ -27,29 +30,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
27
30
 
28
31
  - Local Redis integration tests skip with a clear service message when Redis is unavailable; CI and explicitly requested integration runs fail instead. Unit cases remain runnable without Redis.
29
32
 
30
- ## 5.30.0 - 2026-10-16
31
-
32
- ### Changed
33
-
34
- - Lockstep release; package APIs are unchanged.
35
-
36
33
  ## 5.29.0 - 2026-10-01
37
34
 
38
35
  ### Changed
39
36
 
40
- - Lockstep release; package APIs are unchanged. Skills refer to other topics by name instead of file paths, so cross-references keep working after `agent-kit` copies them into an app.
37
+ - Skills refer to other topics by name instead of file paths, so cross-references keep working after `agent-kit` copies them into an app.
41
38
 
42
39
  ## 5.28.0 - 2026-10-01
43
40
 
44
41
  ### Changed
45
42
 
46
- - Lockstep release; package APIs are unchanged. `llms.txt` now lists every skill topic with its description (frontmatter in CRLF files was skipped).
47
-
48
- ## 5.27.0 - 2026-10-01
49
-
50
- ### Changed
51
-
52
- - Lockstep release; package APIs are unchanged.
43
+ - `llms.txt` now lists every skill topic with its description (frontmatter in CRLF files was skipped).
53
44
 
54
45
  ## 5.26.0 - 2026-09-30
55
46
 
@@ -63,24 +54,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
63
54
 
64
55
  - `startWorkers()` (and the `queueConnector`'s `start()`, which calls it) no longer starts in-process workers on a process that doesn't serve the `worker` role (`WARLOCK_ROLES`), logging `queue: workers not started (role: ...)` instead. Producers (`dispatch`) and the dashboard mount are unaffected. With no `--role` passed, every role is on and nothing changes.
65
56
 
66
- ## 5.24.0 - 2026-09-27
67
-
68
- ### Changed
69
-
70
- - Lockstep release; package APIs are unchanged.
71
-
72
- ## 5.23.2 - 2026-09-26
73
-
74
- ### Changed
75
-
76
- - Lockstep patch release; package APIs are unchanged.
77
-
78
- ## 5.23.1 - 2026-09-26
79
-
80
- ### Changed
81
-
82
- - Lockstep patch release; package APIs are unchanged.
83
-
84
57
  ## 5.23.0 - 2026-09-25
85
58
 
86
59
  ### Added
@@ -88,24 +61,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
88
61
  - `defineQueueContext()` / `setQueueContext()`: capture ambient state (tenant, request id) at `dispatch` and restore it around the job handler. The captured value travels in a versioned envelope; jobs without one still run. Exposed as `ctx.context`. Opt a job out with `context: false`.
89
62
  - `UnrecoverableJobError`: throw it from a handler or `restore` to fail the job permanently (mapped to BullMQ's `UnrecoverableError`).
90
63
 
91
- ## 5.22.1 - 2026-09-25
92
-
93
- ### Changed
94
-
95
- - Lockstep patch release; package APIs are unchanged.
96
-
97
- ## 5.22.0 - 2026-09-25
98
-
99
- ### Changed
100
-
101
- - Lockstep release maintenance and dependency refresh.
102
-
103
- ## 5.21.0 - 2026-09-25
104
-
105
- ### Changed
106
-
107
- - Lockstep release maintenance and dependency refresh.
108
-
109
64
  ## 5.20.0 - 2026-09-24
110
65
 
111
66
  ### Changed
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @warlock.js/queue
2
2
 
3
- Durable background jobs for Warlock.js, built on [BullMQ](https://docs.bullmq.io).
3
+ Background jobs for Warlock.js with [BullMQ](https://docs.bullmq.io), durable local SQLite, or memory for tests.
4
4
 
5
5
  - `defineJob({ name, handle, attempts, backoff })` → a typed job with `.dispatch(payload, { delay, priority, jobId })`
6
6
  - Retries with fixed or exponential backoff, delays, priorities, progress
@@ -11,13 +11,15 @@ Durable background jobs for Warlock.js, built on [BullMQ](https://docs.bullmq.io
11
11
 
12
12
  ## Requirements
13
13
 
14
- **Redis is required.** BullMQ stores every job in Redis (5.0 or newer; any Redis-compatible server BullMQ supports, such as Valkey or Dragonfly, also works). This package does not start or bundle Redis.
14
+ **BullMQ (the default)** stores jobs in Redis (5.0 or newer; any Redis-compatible server BullMQ supports, such as Valkey or Dragonfly, also works). This package does not start or bundle Redis.
15
+
16
+ Select `driver: "local"` for SQLite on Node >= 22.15 (built-in `node:sqlite`, no flags; experimental in 22.15), or `driver: "memory"` for tests. Both use the same `defineJob` API. See the [local queues guide](https://warlock.js.org/v/latest/queue/guides/local-queues/) for leases, crash recovery, shutdown, and cancellation.
15
17
 
16
18
  ## Not the same as core's `Queue`
17
19
 
18
20
  `@warlock.js/core` exports a `Queue` class (`core/src/utils/queue.ts`). That one is an **in-memory batcher inside one process**: it collects items and flushes them when a size or time limit is reached. Nothing is stored; items are lost when the process exits; there are no retries.
19
21
 
20
- `@warlock.js/queue` is for **durable jobs**: they are stored in Redis, survive restarts, retry on failure, and can be processed by another process.
22
+ `@warlock.js/queue` provides retries and worker execution; Redis and local SQLite storage survive restarts and support multiple worker processes. The memory driver is process-local and loses jobs on close/exit.
21
23
 
22
24
  ## Install
23
25
 
@@ -53,6 +55,19 @@ The connector starts after your app code is loaded, so every `defineJob` is regi
53
55
 
54
56
  Set `workers.enabled: false` in a process that should only dispatch jobs.
55
57
 
58
+ ### Without Redis
59
+
60
+ ```ts
61
+ setQueueConfig({
62
+ driver: "local",
63
+ local: { path: "/var/lib/my-app/jobs.sqlite", leaseDuration: 30_000, pollInterval: 100 },
64
+ workers: { concurrency: 4, shutdownTimeout: 5000 },
65
+ });
66
+ // Tests: setQueueConfig({ driver: "memory" });
67
+ ```
68
+
69
+ Import `setQueueConfig` from `@warlock.js/queue`, or put these options in the config file. Share the same absolute path and `prefix` across processes on one host. Local storage uses transactions and renewable leases; crashed jobs re-deliver after lease expiry. Shutdown releases unfinished jobs after its timeout and aborts their `ctx.signal`. Handlers must be idempotent and observe cancellation. Keep SQLite on local disk. The memory driver clears jobs on close/exit; bull-board and `getQueue()` require BullMQ.
70
+
56
71
  ## Define and dispatch
57
72
 
58
73
  ```ts