Registry / ai-ml / swarm-queue

swarm-queue

JSON →
library0.1.0jsnpmunverified

Distributed job queue for coordinating multi-agent swarms, built on BullMQ and Redis. Version 0.1.0 is the current stable release with weekly updates. Differentiator: lightweight, typed, and designed specifically for agent-to-agent task distribution, not generic job queuing.

npm install swarm-queue
INSTALL
IMPORT
SIG · SWARM-QUEUE
S
swarm-queue
ai-mljavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SwarmQueue
import { SwarmQueue } from 'swarm-queue'
const SwarmQueue = require('swarm-queue')
ESM-only; CommonJS require() breaks with dynamic export
createQueue
import { createQueue } from 'swarm-queue'
import { createQueue } from 'swarm-queue/createQueue'
Top-level export; do not subpath import
Job
import type { Job } from 'swarm-queue'
import { Job } from 'swarm-queue'
Job is a TypeScript type only, not a runtime value since v0.1.0

Initializes a SwarmQueue with Redis, adds a job, and runs a worker to process it.

import { SwarmQueue } from 'swarm-queue'; import Redis from 'ioredis'; const connection = new Redis(process.env.REDIS_URL ?? 'redis://localhost:6379'); const queue = new SwarmQueue({ connection, queueName: 'swarm-tasks' }); async function main() { await queue.add({ agentId: 'agent-1', payload: { instruction: 'process data' } }); const worker = queue.createWorker(async (job) => { console.log(`Agent ${job.data.agentId} executing: ${job.data.payload.instruction}`); return { status: 'done' }; }); await worker.waitUntilReady(); console.log('Queue ready'); } main().catch(console.error);
Debug
Known issues
breakingQueue constructor now requires explicit `connection` option; removed default Redis connection
fix
Pass a Redis connection or ioredis instance as `{ connection }`
affects: >=0.1.0
deprecated`delay` option on job add() is deprecated, use `defer` instead
fix
Replace `delay` with `defer` in job options
affects: >=0.1.0
gotchaDo not share same Redis connection across multiple SwarmQueue instances; BullMQ expects exclusive connections per queue
fix
Create a new Redis connection per SwarmQueue instance
affects: *
breakingType `Job` no longer exported as runtime value; use TypeScript `import type`
fix
Change `import { Job }` to `import type { Job }`
affects: >=0.1.0
gotchaWorker callbacks must return a value; returning undefined causes job to hang indefinitely
fix
Ensure worker handler returns a result or Promise
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: queue.add is not a function
Imported SwarmQueue incorrectly using default import (import SwarmQueue) instead of named import
fix
Use `import { SwarmQueue } from 'swarm-queue'`
Error: Job type is not a constructor
Imported Job as runtime value instead of type-only import in TypeScript
fix
Use `import type { Job } from 'swarm-queue'`
BullMQ: Error: connection is not a Redis connection (Missing connection)
Instantiated SwarmQueue without passing `connection` option
fix
Pass `{ connection: new Redis() }` to the constructor
Worker never completes job
Worker callback returns undefined (or void) instead of a value
fix
Return a result object from the worker handler
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies
bullmqrequiredCore job queue engine
ioredisrequiredRedis client for BullMQ
Agent activity
15 hits · last 30 days
node
12
Amazon
1
OpenAI (training)
1
Resources
swarm-queue — npm install swarm-queue · libregistry