UNPKG

@hotmeshio/hotmesh

Version:

Permanent-Memory Workflows & AI Agents

55 lines (54 loc) 1.88 kB
import { ExecHookOptions } from './execHook'; /** * Configuration for a single hook in a batch execution */ export interface BatchHookConfig<T = any> { /** 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. * 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. * * @template T - Object type with keys matching the batch hook keys and values as expected response types * @param {BatchHookConfig[]} hookConfigs - Array of hook configurations with unique keys * @returns {Promise<T>} Object with keys from hookConfigs and values as the signal responses * * @example * ```typescript * // 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 * ``` */ export declare function execHookBatch<T extends Record<string, any>>(hookConfigs: BatchHookConfig[]): Promise<T>;