Loop Engine

Packages

@loop-engine/sdk

@loop-engine/sdk

Top-level package for building and running loops with default runtime wiring.

Install

1npm install @loop-engine/sdk

What's included

Direct exports:

  • createLoopSystem(...) (SDK factory)
  • createLoopEngine (from @loop-engine/runtime)
  • LoopBuilder (from @loop-engine/dsl)
  • guardRegistry (default guard registry)
  • createSignalEngine (from @loop-engine/signals)
  • InMemoryEventBus (from @loop-engine/events)
  • computeMetrics, buildTimeline (from @loop-engine/observability)

Type exports:

  • LoopDefinition, LoopInstance, TransitionRecord, Signal (from @loop-engine/core)

API reference

createLoopSystem

1createLoopSystem(options: {
2 loops: LoopDefinition[]
3 store?: LoopStore
4 guards?: GuardRegistry
5 signals?: boolean
6}): {
7 engine: LoopEngine
8 signals?: SignalEngine
9 eventBus: InMemoryEventBus
10}

Creates:

  • runtime engine
  • in-memory event bus
  • optional signal engine

Defaults:

  • store -> memoryStore()
  • guards -> default registry with built-in guards

Example

1import { aggregateId, transitionId } from '@loop-engine/core'
2import { LoopBuilder, createLoopSystem } from '@loop-engine/sdk'
3 
4const loop = LoopBuilder
5 .create('demo.loop', 'demo')
6 .state('OPEN')
7 .state('DONE', { isTerminal: true })
8 .initialState('OPEN')
9 .transition({ id: 'finish', from: 'OPEN', to: 'DONE', actors: ['human'] })
10 .outcome({ id: 'done', description: 'Loop done', valueUnit: 'done' })
11 .build()
12 
13const { engine } = createLoopSystem({ loops: [loop] })
14 
15await engine.start({
16 loopId: 'demo.loop',
17 aggregateId: aggregateId('A-1'),
18 orgId: 'acme',
19 actor: { type: 'system', id: 'system:bootstrap' }
20})
21 
22await engine.transition({
23 aggregateId: aggregateId('A-1'),
24 transitionId: transitionId('finish'),
25 actor: { type: 'human', id: 'owner@acme.com' }
26})
  • Depends on runtime, dsl, guards, signals, events, observability, adapter-memory, core.
  • If you need lower-level control, use @loop-engine/runtime directly.