Interface: PipelineStage
@providerprotocol/ai / middleware/pipeline / PipelineStage
Interface: PipelineStage<TData>
Section titled “Interface: PipelineStage<TData>”Defined in: src/middleware/pipeline/index.ts:100
A single pipeline stage that runs after turn completion.
Stages can mutate the turn object to attach computed properties (like slugs,
image URLs, etc.) that will be available in the .then() callback. Use a
type assertion to add properties:
Example
Section titled “Example”// Define extended turn typeinterface ExtendedTurn { slug?: string; imageUrl?: string; }
// In stage run functionrun: (turn, emit) => { const slug = generateSlug(turn.data!.title); (turn as Turn<TData> & ExtendedTurn).slug = slug; emit({ slug });}
// Access in .then() callbackmodel.stream(prompt).then(turn => { const extended = turn as typeof turn & ExtendedTurn; console.log(extended.slug); // Available!});Type Parameters
Section titled “Type Parameters”TData = unknown
Type of the turn’s structured data
Properties
Section titled “Properties”run: (
turn,emit) =>void|Promise<void>
Defined in: src/middleware/pipeline/index.ts:110
Execute this stage.
Parameters
Section titled “Parameters”Turn<TData>
The completed turn (can mutate via type assertion to add properties)
Function to emit progress events to subscribers
Returns
Section titled “Returns”void | Promise<void>
type:
string
Defined in: src/middleware/pipeline/index.ts:102
Unique identifier for this stage (used in events)