import { BaseResult } from "../contracts/result/base-result.type.mjs"; import { ExecuteResult } from "../contracts/result/execute-result.type.mjs"; import { ExecutableContract } from "../contracts/executable.contract.mjs"; import { BatchOptions, BatchResult } from "./batch.type.mjs"; //#region ../ai/src/batch/batch.d.ts /** * Run an executable AI primitive (agent, workflow, supervisor, tool, * or anything satisfying {@link ExecutableContract}) over a dataset * with bounded concurrency and per-item retry, returning per-item * outcomes plus rolled-up usage and a walkable report tree. * * **Role.** The fan-out primitive of `@warlock.js/ai`. Where an agent * runs once, `batch` runs the SAME executable N times — once per item * — and aggregates the results into the unified {@link ExecuteResult} * envelope, so a batch slots into cost dashboards and trace tooling * exactly like a single run does. * * **Isolation.** Items are independent: one item's failure (after its * retries are exhausted) never cancels a sibling, and the batch as a * whole never rejects — failures live on each {@link BatchItemResult}. * Reach for `result.report.failed` / `item.status` to inspect them. * * **Usage rollup.** `result.usage` and `result.report.usage` sum every * item's usage, satisfying the universal rollup invariant ("own cost * + sum of children"; a batch has zero own cost). Each item's own * report is attached under `report.children[]`, in original item * order, so a trace walker sees every run. * * @example * const result = await batch(summarizer, articles, { * concurrency: 4, * retry: { attempts: 3, backoff: "exponential" }, * onItem: (item) => log.info("batch", "item", "settled", { index: item.index }), * }); * * console.log(`${result.report.succeeded}/${result.report.total} ok`); * console.log(`${result.usage.total} tokens total`); */ declare function batch(executable: ExecutableContract, items: readonly TInput[], options?: BatchOptions): Promise>; //#endregion export { batch }; //# sourceMappingURL=batch.d.mts.map