Map
Run one workflow node concurrently for every item in a list.
Map derives a list with over, runs each once per item concurrently, and
returns the outputs in the original item order. An empty list returns [].
import { Chain, Map } from "@nylorun/agents/define";
export const digest = Chain({
id: "digest",
steps: [
planner,
Map({
id: "write",
over: (plan) => plan.sections,
each: sectionWriter,
}),
{
run: merge,
input: ({ value }) => ({ parts: value }),
},
],
});over is durable workflow logic. Keep it deterministic and return a JSON-safe
array. each can be an agent, tool, nested workflow, or slot. A slot can use
index while shaping each item's input:
Map({
id: "write",
over: (plan) => plan.sections,
each: {
run: sectionWriter,
input: ({ value, index }) => ({ title: value, position: index }),
},
})Use Map for data-driven fan-out. Use Parallel when
branches have different names or behavior known at definition time.
See the shipped map example,
then use Loop for repeat-until-accepted work.