Skip to content

MiddlewareStack

Defined in: ai.matey.core/src/middleware-stack.ts:31

Middleware stack for composing middleware functions.

Executes middleware in order with proper error handling and context management.

new MiddlewareStack(): MiddlewareStack

MiddlewareStack

clear(): void

Defined in: ai.matey.core/src/middleware-stack.ts:239

Clear all middleware from the stack.

void

If stack is locked


execute(context, finalHandler): Promise<IRChatResponse>

Defined in: ai.matey.core/src/middleware-stack.ts:127

Execute middleware stack for non-streaming requests.

MiddlewareContext

Middleware context

() => Promise<IRChatResponse>

Final handler function (backend.execute)

Promise<IRChatResponse>

Response after middleware chain


executeStream(context, finalHandler): Promise<IRChatStream>

Defined in: ai.matey.core/src/middleware-stack.ts:184

Execute middleware stack for streaming requests.

StreamingMiddlewareContext

Streaming middleware context

() => Promise<IRChatStream>

Final handler function (backend.executeStream)

Promise<IRChatStream>

Stream after middleware chain


getMiddleware(): readonly Middleware[]

Defined in: ai.matey.core/src/middleware-stack.ts:102

Get all middleware in the stack.

readonly Middleware[]


getStreamingMiddleware(): readonly StreamingMiddleware[]

Defined in: ai.matey.core/src/middleware-stack.ts:109

Get all streaming middleware in the stack.

readonly StreamingMiddleware[]


isLocked(): boolean

Defined in: ai.matey.core/src/middleware-stack.ts:116

Check if stack is locked.

boolean


lock(): void

Defined in: ai.matey.core/src/middleware-stack.ts:95

Lock the stack to prevent further modifications.

Called automatically on first request execution.

void


remove(middleware): boolean

Defined in: ai.matey.core/src/middleware-stack.ts:59

Remove middleware from the stack.

Middleware

Middleware function to remove

boolean

true if middleware was found and removed, false otherwise

If stack is locked


use(middleware): void

Defined in: ai.matey.core/src/middleware-stack.ts:42

Add middleware to the stack.

Middleware

Middleware function to add

void

If stack is locked


useStreaming(middleware): void

Defined in: ai.matey.core/src/middleware-stack.ts:80

Add streaming middleware to the stack.

StreamingMiddleware

Streaming middleware function to add

void

If stack is locked