• Executes multiple hooks in parallel and awaits all their signal responses. This solves the race condition where Promise.all() with execHook() would prevent all waitFor() registrations from completing.

    The method ensures all waitFor() registrations happen before any hooks execute, preventing signals from being sent before the framework is ready to receive them.

    Type Parameters

    • T extends Record<string, any>

      Object type with keys matching the batch hook keys and values as expected response types

    Parameters

    • hookConfigs: BatchHookConfig<any>[]

      Array of hook configurations with unique keys

    Returns Promise<T>

    Object with keys from hookConfigs and values as the signal responses

    // Execute multiple research perspectives in parallel
    const results = await MemFlow.workflow.execHookBatch<{
    optimistic: OptimisticResult;
    skeptical: SkepticalResult;
    }>([
    {
    key: 'optimistic',
    options: {
    taskQueue: 'agents',
    workflowName: 'optimisticPerspective',
    args: [query],
    signalId: 'optimistic-complete'
    }
    },
    {
    key: 'skeptical',
    options: {
    taskQueue: 'agents',
    workflowName: 'skepticalPerspective',
    args: [query],
    signalId: 'skeptical-complete'
    }
    }
    ]);

    // results.optimistic contains the OptimisticResult
    // results.skeptical contains the SkepticalResult