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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MiddlewareStack():
MiddlewareStack
Returns
Section titled “Returns”MiddlewareStack
Methods
Section titled “Methods”clear()
Section titled “clear()”clear():
void
Defined in: ai.matey.core/src/middleware-stack.ts:239
Clear all middleware from the stack.
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If stack is locked
execute()
Section titled “execute()”execute(
context,finalHandler):Promise<IRChatResponse>
Defined in: ai.matey.core/src/middleware-stack.ts:127
Execute middleware stack for non-streaming requests.
Parameters
Section titled “Parameters”context
Section titled “context”Middleware context
finalHandler
Section titled “finalHandler”() => Promise<IRChatResponse>
Final handler function (backend.execute)
Returns
Section titled “Returns”Promise<IRChatResponse>
Response after middleware chain
executeStream()
Section titled “executeStream()”executeStream(
context,finalHandler):Promise<IRChatStream>
Defined in: ai.matey.core/src/middleware-stack.ts:184
Execute middleware stack for streaming requests.
Parameters
Section titled “Parameters”context
Section titled “context”Streaming middleware context
finalHandler
Section titled “finalHandler”() => Promise<IRChatStream>
Final handler function (backend.executeStream)
Returns
Section titled “Returns”Promise<IRChatStream>
Stream after middleware chain
getMiddleware()
Section titled “getMiddleware()”getMiddleware(): readonly
Middleware[]
Defined in: ai.matey.core/src/middleware-stack.ts:102
Get all middleware in the stack.
Returns
Section titled “Returns”readonly Middleware[]
getStreamingMiddleware()
Section titled “getStreamingMiddleware()”getStreamingMiddleware(): readonly
StreamingMiddleware[]
Defined in: ai.matey.core/src/middleware-stack.ts:109
Get all streaming middleware in the stack.
Returns
Section titled “Returns”readonly StreamingMiddleware[]
isLocked()
Section titled “isLocked()”isLocked():
boolean
Defined in: ai.matey.core/src/middleware-stack.ts:116
Check if stack is locked.
Returns
Section titled “Returns”boolean
lock()
Section titled “lock()”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.
Returns
Section titled “Returns”void
remove()
Section titled “remove()”remove(
middleware):boolean
Defined in: ai.matey.core/src/middleware-stack.ts:59
Remove middleware from the stack.
Parameters
Section titled “Parameters”middleware
Section titled “middleware”Middleware function to remove
Returns
Section titled “Returns”boolean
true if middleware was found and removed, false otherwise
Throws
Section titled “Throws”If stack is locked
use(
middleware):void
Defined in: ai.matey.core/src/middleware-stack.ts:42
Add middleware to the stack.
Parameters
Section titled “Parameters”middleware
Section titled “middleware”Middleware function to add
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If stack is locked
useStreaming()
Section titled “useStreaming()”useStreaming(
middleware):void
Defined in: ai.matey.core/src/middleware-stack.ts:80
Add streaming middleware to the stack.
Parameters
Section titled “Parameters”middleware
Section titled “middleware”Streaming middleware function to add
Returns
Section titled “Returns”void
Throws
Section titled “Throws”If stack is locked