• Executes multiple hooks in parallel and awaits all their signal responses, returning a keyed object of results. This is the recommended way to run concurrent hooks — it solves a race condition where calling Promise.all([execHook(), execHook()]) would throw before all waitFor registrations complete.

    1. Fire all hooks via Promise.all (registers streams immediately).
    2. Await all signals via Promise.all (all waitFor registrations happen together before any DurableWaitForError is thrown).
    3. Combine results into a { [key]: result } map.
    import { Durable } from '@hotmeshio/hotmesh';

    // Fan-out to multiple AI agents, gather all perspectives
    export async function researchWorkflow(query: string): Promise<Summary> {
    const perspectives = await Durable.workflow.execHookBatch<{
    optimistic: PerspectiveResult;
    skeptical: PerspectiveResult;
    neutral: PerspectiveResult;
    }>([
    {
    key: 'optimistic',
    options: {
    taskQueue: 'agents',
    workflowName: 'analyzeOptimistic',
    args: [query],
    },
    },
    {
    key: 'skeptical',
    options: {
    taskQueue: 'agents',
    workflowName: 'analyzeSkeptical',
    args: [query],
    },
    },
    {
    key: 'neutral',
    options: {
    taskQueue: 'agents',
    workflowName: 'analyzeNeutral',
    args: [query],
    },
    },
    ]);

    // All three results are available as typed properties
    const { synthesize } = Durable.workflow.proxyActivities<typeof activities>();
    return await synthesize(
    perspectives.optimistic,
    perspectives.skeptical,
    perspectives.neutral,
    );
    }
    // Parallel validation with different services
    const checks = await Durable.workflow.execHookBatch<{
    fraud: { safe: boolean };
    compliance: { approved: boolean };
    }>([
    {
    key: 'fraud',
    options: {
    taskQueue: 'fraud-detection',
    workflowName: 'checkFraud',
    args: [transactionId],
    },
    },
    {
    key: 'compliance',
    options: {
    taskQueue: 'compliance',
    workflowName: 'checkCompliance',
    args: [transactionId],
    },
    },
    ]);

    if (checks.fraud.safe && checks.compliance.approved) {
    // proceed with transaction
    }

    Type Parameters

    • T extends Record<string, any>

      Object type with keys matching the batch hook keys.

    Parameters

    • hookConfigs: BatchHookConfig<any>[]

      Array of hook configurations with unique keys.

    Returns Promise<T>

    Object mapping each config's key to its signal response.