import { AgentContract } from "../contracts/agent/agent.contract.mjs"; import { WorkflowInstance } from "../contracts/workflow/workflow.contract.mjs"; import { IntentEntry } from "../contracts/supervisor/intent-entry.type.mjs"; //#region ../ai/src/supervisor/fan-out.d.ts /** * A dispatchable unit that can be fanned out — an agent or a workflow. * The same union the supervisor's `intents` map accepts for its * agent/workflow object entries. */ type FanOutUnit = AgentContract | WorkflowInstance; /** * Options for {@link fanOut}. */ type FanOutOptions = { /** * Base name for the generated intent keys. Defaults to the unit's own * `name`. The keys are `1`, `2`, … `n`. */ keyPrefix?: string; /** * Description applied to every generated entry. Defaults to the * unit's own `description`. A description is required when the * supervisor uses a `router` (the LLM needs a signal per intent); the * factory enforces that downstream, so supply one here when the * underlying unit has none. */ description?: string; }; /** * Spread one agent/workflow into `n` distinctly-keyed intent entries * for voting / self-consistency under a supervisor. * * A supervisor dispatches a fan-out array (`["writer1", "writer2", * "writer3"]`) in parallel; each branch runs the SAME unit independently * so a downstream evaluate/aggregate intent can pick the majority answer * or the best of `n` samples. Because every branch needs its own intent * KEY, this helper clones the unit across distinct keys rather than * cloning the unit itself — the underlying agent/workflow is referenced * by all entries, but each entry is a separate dispatch slot. * * Returns a `Record` you spread directly into the * supervisor's `intents` map. The keys are `1..n`. * * @example * const writer = ai.agent({ name: "writer", description: "Drafts an answer.", model }); * * const support = ai.supervisor({ * name: "self-consistency", * intents: { * ...ai.fanOut(writer, 3), // writer1, writer2, writer3 * vote: { run: pickMajority, description: "Choose the majority answer." }, * }, * route: (ctx) => * ctx.iteration === 0 ? ["writer1", "writer2", "writer3"] : "vote", * }); * * @param unit The agent or workflow to fan out. * @param count Number of parallel copies. Must be an integer >= 1. * @param options Optional key-prefix / description overrides. */ declare function fanOut(unit: FanOutUnit, count: number, options?: FanOutOptions): Record; //#endregion export { FanOutOptions, FanOutUnit, fanOut }; //# sourceMappingURL=fan-out.d.mts.map