Skip to content

AIDK API Reference / aidk-nestjs / EngineContextInterceptor

Class: EngineContextInterceptor ​

Defined in: packages/nestjs/src/interceptors/engine-context.interceptor.ts:29

Interceptor that sets up execution context for engine operations. Extracts user/tenant/thread IDs from request and sets them in async-local storage.

The context is available during:

  1. Controller method execution (synchronous)
  2. Engine.stream()/execute() calls (they capture and propagate context internally)

Context is also attached to the request object via attachContext() from aidk-server, making it accessible in guards, decorators, and other middleware via getContext(request).

Note: If you need context in custom RxJS operators or async callbacks outside the Engine, use Context.run() explicitly.

Implements ​

  • NestInterceptor

Constructors ​

Constructor ​

ts
new EngineContextInterceptor(engine: Engine): EngineContextInterceptor;

Defined in: packages/nestjs/src/interceptors/engine-context.interceptor.ts:30

Parameters ​

ParameterType
engineEngine

Returns ​

EngineContextInterceptor

Methods ​

intercept() ​

ts
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;

Defined in: packages/nestjs/src/interceptors/engine-context.interceptor.ts:32

Method to implement a custom interceptor.

Parameters ​

ParameterTypeDescription
contextExecutionContextan ExecutionContext object providing methods to access the route handler and class about to be invoked.
nextCallHandlera reference to the CallHandler, which provides access to an Observable representing the response stream from the route handler.

Returns ​

Observable<any>

Implementation of ​

ts
NestInterceptor.intercept

Released under the MIT License.