/** * `orchestrate`: 1 → ?. An agent *decides* the split, then the split runs. * * How that decision is read - and why it is a parsed convention rather than a * tool call - lives in `plan.ts`. What is left here is the shape: plan, fan out * over it, optionally synthesise. */ import type { Agent } from "./../agent.ts"; import { type Result, type WorkflowResult } from "./../result.ts"; import { type PlannedTask, type PlanOptions } from "./plan.ts"; /** {@link PlanOptions}, plus how the planned subtasks are run and folded. */ export type OrchestrateOptions = PlanOptions & { /** Subtasks in flight at once, as in {@link fanOut}. Defaults to 4. */ concurrency?: number; /** When given, this agent turns the subtask results into one answer. */ reduceWith?: Agent; }; /** * The plan, what it produced, and optionally the one answer it was folded into. * * As a `Result`: the synthesis when `reduceWith` was given, otherwise the * planner's turn with the subtasks' outputs, labelled, where its own would be. * `usage` covers planning, subtasks and synthesis over the whole run; `ok` is * false when the planning failed, produced nothing runnable, or a subtask * failed. `steps` is the planner's turn, every subtask, then the synthesis. */ export type OrchestrateResult = WorkflowResult & { /** What the planner asked for, after validation. Empty when planning failed. */ plan: PlannedTask[]; /** The planner's own turn. Kept whatever happened next. */ planning: Result; /** One result per planned subtask, in plan order. */ results: Result[]; /** The synthesis, present only when `reduceWith` was given. */ answer?: Result; }; /** * Asks an agent to split the work, then runs the split it asked for. * * This is a **dynamic** fan-out: unlike {@link fanOut}, nobody wrote the tasks * in advance. Everything else is the same machinery - bounded concurrency, one * subagent per branch, no shared state - because a plan the model wrote deserves * no more trust than a plan the caller wrote, and a good deal less latitude. */ export declare function orchestrate(options: OrchestrateOptions): Promise; //# sourceMappingURL=orchestrate.d.ts.map