import { ExecHookOptions } from './execHook'; /** * Configuration for a single hook in a batch execution. * @see {@link execHookBatch} */ export interface BatchHookConfig { /** Unique key to identify this hook's result in the returned object */ key: string; /** Hook execution options */ options: ExecHookOptions; } /** * 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. * * ## Three-Phase Execution * * 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. * * ## Examples * * ```typescript * import { Durable } from '@hotmeshio/hotmesh'; * * // Fan-out to multiple AI agents, gather all perspectives * export async function researchWorkflow(query: string): Promise { * 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(); * return await synthesize( * perspectives.optimistic, * perspectives.skeptical, * perspectives.neutral, * ); * } * ``` * * ```typescript * // 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 * } * ``` * * @template T - Object type with keys matching the batch hook keys. * @param {BatchHookConfig[]} hookConfigs - Array of hook configurations with unique keys. * @returns {Promise} Object mapping each config's `key` to its signal response. */ export declare function execHookBatch>(hookConfigs: BatchHookConfig[]): Promise;