Packages
@loop-engine/events
@loop-engine/events defines the event contract and ships an in-memory event bus implementation.
Install
1npm install @loop-engine/eventsEvent catalog
The exported LOOP_EVENT_TYPES constants map to:
loop.startedloop.transition.requestedloop.transition.executedloop.transition.blockedloop.guard.failedloop.completedloop.errorloop.spawnedloop.signal.receivedloop.outcome.recorded
Every event extends:
1interface LoopEventBase {2 eventId: string3 loopId: LoopId4 aggregateId: AggregateId5 orgId: string6 occurredAt: string7 correlationId: CorrelationId8 causationId?: string9}InMemoryEventBus
1class InMemoryEventBus {2 emit(event: LoopEvent): Promise<void>3 subscribe(handler: (event: LoopEvent) => Promise<void>): () => void4}subscribe() returns an unsubscribe callback, and handler failures do not block other subscribers.
1import { InMemoryEventBus } from "@loop-engine/events"2 3const bus = new InMemoryEventBus()4const unsubscribe = bus.subscribe(async (event) => {5 if (event.type === "loop.transition.executed") {6 console.log(event.transitionId, event.actor.type)7 }8})9 10unsubscribe()Learning signal extraction
1extractLearningSignal(2 completed: LoopCompletedEvent,3 history: TransitionRecord[],4 predicted?: Record<string, unknown>5): LearningSignalThis helper derives actual, predicted, and numeric delta fields from completion history.