Interface: StreamContext
@providerprotocol/ai / @providerprotocol/ai / StreamContext
Interface: StreamContext
Section titled “Interface: StreamContext”Defined in: src/types/middleware.ts:111
Context for stream event hooks.
Provides a shared state map for middleware to store and retrieve data. Middleware that need to accumulate text or other data should manage their own state using the provided state map.
Example
Section titled “Example”const filterMiddleware: Middleware = { name: 'reasoning-filter', onStreamEvent(event, ctx) { // Filter out reasoning events if (event.type === StreamEventType.ReasoningDelta) { return null; } return event; },};Properties
Section titled “Properties”
readonlystate:Map<string,unknown>
Defined in: src/types/middleware.ts:113
Shared state (same reference as MiddlewareContext.state)