@cognitive-swarm/signals
v0.2.0
Published
Signal bus — the nervous system of the cognitive swarm
Readme
@cognitive-swarm/signals
Signal bus -- the nervous system of the cognitive swarm.
Install
npm install @cognitive-swarm/signalsOverview
This package provides the communication backbone for the swarm. Agents exchange typed signals (task, discovery, proposal, doubt, challenge, vote, conflict, consensus, escalate) through the SignalBus. The ConflictDetector monitors the bus and flags contradictory signals automatically.
Usage
import { SignalBus, ConflictDetector } from '@cognitive-swarm/signals'
import type { ResolvedSignalBusConfig } from '@cognitive-swarm/core'
// Create the bus
const bus = new SignalBus(config)
// Emit a signal
bus.emit({
type: 'discovery',
source: 'agent-analyst',
payload: { content: 'Found correlation in dataset' },
})
// Subscribe to signals
bus.on('proposal', (signal) => {
console.log(signal.source, signal.payload)
})
// Detect contradictions
const detector = new ConflictDetector(bus)
// Conflict signals are emitted back onto the bus automaticallyAPI
SignalBus
emit(signal)-- broadcast a typed signal to the swarmon(type, handler)-- subscribe to a specific signal typegetHistory()-- retrieve the full signal log
ConflictDetector
- Attaches to a
SignalBusand watches for contradictory discovery/proposal signals - Emits
conflictsignals when contradictions are detected
License
Apache-2.0
