• English
  • Advanced

    Raw event listener

    createInMemoryOrchestratorStore can receive each raw workflow event as it is appended:

    const store = createInMemoryOrchestratorStore({
      onEvent: async (event) => {
        console.log(event);
      },
    });

    The callback runs from appendEvent. If it throws, the append rejects and the run follows core's event-hook failure behavior.

    The in-memory store keeps at most 100 snapshots and 5,000 events by default. Pass maxSnapshots or maxEvents to tune retention, or Infinity to disable a cap.

    Recovery

    createOrchestrator can lazily recover a missing managed run from a stored snapshot when waitForRun, cancelRun, or cancelTask receives a run id that is not active in memory:

    const orchestrator = createOrchestrator({
      store,
      workerGateway: gateway,
      recovery: {
        interruptedTasks: "retry",
        loadSnapshot: async (runId) => store.getSnapshot(runId),
      },
    });
    
    const completed = await orchestrator.waitForRun("run_123");

    Recovery delegates to core runner snapshot recovery. If interruptedTasks is omitted, core uses the workflow recovery config and then falls back to "manual".

    Notes

    • Workers execute one task job, not a full workflow.
    • Workers use core's TaskRegistry for real task handlers.
    • The host orchestrator uses core's createRunner for DAG state.
    • worker/thread provides local process isolation, not a hostile-code security sandbox.
    • Persistence is interface-ready; alpha includes only the in-memory store.