Skip to content

AIDK API Reference / aidk-nestjs

aidk-nestjs ​

AIDK NestJS ​

NestJS integration for AIDK agents. Provides modules, controllers, guards, and interceptors for seamless engine integration.

Features ​

  • EngineModule - Configure engine as a NestJS module
  • ChannelModule - Real-time channel communication
  • Guards & Interceptors - Context extraction and validation
  • Decorators - Inject engine context into handlers

Quick Start ​

typescript
// app.module.ts
import { EngineModule } from 'aidk-nestjs';

@Module({
  imports: [
    EngineModule.forRoot({
      engine: createEngine(),
    }),
  ],
})
export class AppModule {}

// controller.ts
import { EngineController, Stream } from 'aidk-nestjs';

@Controller('api/run')
export class RunController {
  @Post('stream')
  @Stream()
  async stream(@Body() input: EngineInput) {
    return input;
  }
}

Classes ​

ClassDescription
EngineContextGuardGuard that ensures execution context is available. Use this if you need to verify context before handler execution.
EngineContextInterceptorInterceptor that sets up execution context for engine operations. Extracts user/tenant/thread IDs from request and sets them in async-local storage.
EngineModule-
SSETransportTransport adapter for external communication (e.g., SSE, WebSocket). Optional add-on layer - channels work without transport.

Interfaces ​

InterfaceDescription
EngineModuleOptions-
SSETransportConfigConfiguration for ChannelTransport.

Variables ​

VariableDescription
ExecuteAgent-
StreamAgent-

Functions ​

FunctionDescription
ExecuteDecorator to mark a route handler for execution. The handler should return EngineInput, and the root JSX will be provided via metadata.
StreamDecorator to mark a route handler for streaming execution. The handler should return EngineInput, and the root JSX will be provided via metadata.

References ​

AIDK_CONTEXT_KEY ​

Re-exports AIDK_CONTEXT_KEY


attachContext ​

Re-exports attachContext


buildEngineContext ​

Re-exports buildEngineContext


clearStore ​

Re-exports clearStore


ContextExtractor ​

Re-exports ContextExtractor


createContextExtractor ​

Re-exports createContextExtractor


createIdGenerator ​

Re-exports createIdGenerator


createInMemoryRepositories ​

Re-exports createInMemoryRepositories


createInMemoryStore ​

Re-exports createInMemoryStore


createInputTransformer ​

Re-exports createInputTransformer


createPrefixedIdGenerator ​

Re-exports createPrefixedIdGenerator


defaultContextExtractor ​

Re-exports defaultContextExtractor


defaultInputTransformer ​

Re-exports defaultInputTransformer


ExecutionContext ​

Re-exports ExecutionContext


ExecutionContextConfig ​

Re-exports ExecutionContextConfig


ExecutionEntity ​

Re-exports ExecutionEntity


ExecutionRepository ​

Re-exports ExecutionRepository


generateUUID ​

Re-exports generateUUID


getContext ​

Re-exports getContext


IdGenerator ​

Re-exports IdGenerator


InMemoryExecutionRepository ​

Re-exports InMemoryExecutionRepository


InMemoryInteractionRepository ​

Re-exports InMemoryInteractionRepository


InMemoryMessageBlockRepository ​

Re-exports InMemoryMessageBlockRepository


InMemoryMessageRepository ​

Re-exports InMemoryMessageRepository


InMemoryMetricsRepository ​

Re-exports InMemoryMetricsRepository


InMemoryStore ​

Re-exports InMemoryStore


InMemoryToolStateRepository ​

Re-exports InMemoryToolStateRepository


InputTransformer ​

Re-exports InputTransformer


InteractionEntity ​

Re-exports InteractionEntity


InteractionRepository ​

Re-exports InteractionRepository


MessageBlockEntity ​

Re-exports MessageBlockEntity


MessageBlockRepository ​

Re-exports MessageBlockRepository


MessageEntity ​

Re-exports MessageEntity


MessageRepository ​

Re-exports MessageRepository


messagesToTimeline ​

Re-exports messagesToTimeline


MetricsEntity ​

Re-exports MetricsEntity


MetricsRepository ​

Re-exports MetricsRepository


PersistenceRepositories ​

Re-exports PersistenceRepositories


RequestContext ​

Re-exports RequestContext


RequestWithContext ​

Re-exports RequestWithContext


requireContext ​

Re-exports requireContext


resolveConfig ​

Re-exports resolveConfig


StandardRequestBody ​

Re-exports StandardRequestBody


ToolStateEntity ​

Re-exports ToolStateEntity


ToolStateRepository ​

Re-exports ToolStateRepository


uuidV4Generator ​

Re-exports uuidV4Generator

Released under the MIT License.