/** * Surface 9 (V0.4) — `darwinAccumulatingAnnotation(extra?)`. * * Variant of {@link darwinAnnotation} that REPLACES the singleton * `darwinTrajectory: ExecutionTrace | undefined` channel with an * accumulating `darwinTrajectories: ExecutionTrace[]` channel — every * node write appends, the channel never overwrites. * * Use this when you orchestrate multiple Darwin nodes in a single graph * (fan-out, sequential pipeline, supervisor pattern) and want ALL * trajectories preserved in graph state for end-of-run analysis without * having to declare a separate `*Trace` channel per node manually. * * The matching `trajectoryKey` you pass to each `createDarwinNode(...)` * call is `"darwinTrajectories"`. The reducer accepts EITHER a single * `ExecutionTrace` (matching the bare {@link createDarwinNode} contract) * OR an `ExecutionTrace[]` (lets advanced users batch-append from a * worker). Both paths flatten into the same accumulator array. * * @example * ```ts * import { * createDarwinNode, * darwinAccumulatingAnnotation, * } from "darwin-langgraph"; * import { StateGraph } from "@langchain/langgraph"; * * const State = darwinAccumulatingAnnotation(); * * const graph = new StateGraph(State) * .addNode("research", createDarwinNode(researcher, { * trajectoryKey: "darwinTrajectories", * })) * .addNode("critique", createDarwinNode(critic, { * trajectoryKey: "darwinTrajectories", * taskKey: "output", * })) * .addEdge("__start__", "research") * .addEdge("research", "critique") * .compile(); * * const result = await graph.invoke({ task: "What is GEPA?" }); * console.log(`captured ${result.darwinTrajectories.length} trajectories`); * // → captured 2 trajectories * ``` * * NEW V0.4 (S1235). */ import type { ExecutionTrace } from "darwin-agents"; /** * Tolerant accumulator reducer — accepts either a single * `ExecutionTrace` (the shape `createDarwinNode` actually emits) or an * `ExecutionTrace[]` (lets advanced users batch-append from a worker * graph). Both paths flatten into the previous array. * * Pure, exported for testability and so advanced users can hand-roll * their own `Annotation.Root` with the same semantics. */ export declare function darwinTrajectoryAccumulatorReducer(prev: ExecutionTrace[] | undefined, next: ExecutionTrace | ExecutionTrace[] | undefined): ExecutionTrace[]; /** * Channel spec for the accumulating trajectory variant — re-exported for * power-users who want to spread it into their own `Annotation.Root` * call manually. Mirrors the {@link getDarwinChannelSpec} pattern. * * NEW V0.4 (S1235). */ export declare function getDarwinAccumulatingChannelSpec(): { task: import("@langchain/langgraph").LastValue; output: import("@langchain/langgraph").LastValue; darwinTrajectories: import("@langchain/langgraph").BaseChannel, unknown>; }; /** * Build an `Annotation.Root` with `task` + `output` + accumulating * `darwinTrajectories: ExecutionTrace[]` plus any extra channels. */ export declare function darwinAccumulatingAnnotation = {}>(extra?: Extra): import("@langchain/langgraph").AnnotationRoot<{ task: import("@langchain/langgraph").LastValue; output: import("@langchain/langgraph").LastValue; darwinTrajectories: import("@langchain/langgraph").BaseChannel, unknown>; } & Extra>; //# sourceMappingURL=darwin-accumulating-annotation.d.ts.map