pipeai 0.8.4 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -559,6 +559,32 @@ const pipeline = Workflow.create<Ctx>()
559
559
  .foreach(processItem, { concurrency: 5 });
560
560
  ```
561
561
 
562
+ #### Per-item pipelines: the builder-callback form
563
+
564
+ Each item runs its **entire** sub-workflow as one independent unit, so item 0 can be at the
565
+ last step while item 1 is still at the first — true per-item pipeline parallelism, with the only
566
+ barrier at the end (collecting the `Result[]`). When the per-item path is specific to this
567
+ `foreach`, you don't need to declare a separate named workflow: pass a **builder callback** and
568
+ the element type is inferred for you.
569
+
570
+ ```ts
571
+ const pipeline = Workflow.create<Ctx>()
572
+ .step("fetch-items", async ({ ctx }) => ctx.db.items.getAll()) // Item[]
573
+ .foreach(
574
+ item => item // `item` is a sub-builder seeded with the element type
575
+ .step("normalize", ({ input }) => normalize(input))
576
+ .step(analyzeAgent)
577
+ .step(enrichAgent),
578
+ { concurrency: 5 }, // up to 5 items running their full path at once
579
+ );
580
+ ```
581
+
582
+ This is exactly equivalent to passing the pre-built `processItem` workflow above — same
583
+ concurrency, same collect-at-end semantics — it just saves the `Workflow.create<Ctx, Item>()`
584
+ boilerplate and infers the item type from the array. All `foreach` options (`concurrency`,
585
+ `onError`, `id`) apply unchanged. A gate inside the per-item path is forbidden, same as any
586
+ `foreach` body.
587
+
562
588
  #### Streaming `foreach` / `parallel` items
563
589
 
564
590
  When the workflow is run with `.stream(...)`, pass `handleStream` to `foreach` or `parallel` to run each **agent** item/branch in stream mode and control how it surfaces to the writer — the same hook as a single `.step(agent)`, plus an `itemIndex`: