Running Loops
Loading
Loading
Running Loops
createLoopSystem(options)Factory from @loop-engine/sdk:
1createLoopSystem(options: {2 loops: LoopDefinition[]3 store?: LoopStore4 guards?: GuardRegistry5 signals?: boolean6 registry?: LoopRegistry7}): Promise<{8 engine: LoopEngine9 eventBus: InMemoryEventBus10 signals?: SignalEngine11}>loops is required and becomes the in-memory set of definitions.store defaults to memoryStore().guards defaults to defaultRegistry from @loop-engine/guards.signals: true adds a default SignalEngine.registry is the optional loop catalog client (LoopRegistry); if registry.list() fails, startup falls back to loops[].1import { createLoopSystem } from '@loop-engine/sdk'2 3const { engine, eventBus } = await createLoopSystem({ loops: [definition] })1import { createLoopSystem } from '@loop-engine/sdk'2import { postgresStore } from '@loop-engine/adapter-postgres'3import { Pool } from 'pg'4 5const pool = new Pool({ connectionString: process.env.DATABASE_URL })6const { engine } = await createLoopSystem({7 loops: [definition],8 store: postgresStore(pool)9})1import { createLoopSystem } from '@loop-engine/sdk'2 3const { signals } = await createLoopSystem({4 loops: [definition],5 signals: true6})7 8signals?.subscribe((signal) => {9 console.log(signal.type, signal.subject)10})