feat: add CASL authorization and AI configuration

This commit is contained in:
2026-07-11 14:25:34 +08:00
parent 8f0991a51f
commit 1e1c476bc3
59 changed files with 7733 additions and 120 deletions

View File

@@ -0,0 +1,43 @@
import { Module, OnModuleInit } from '@nestjs/common';
import { StudentsModule } from '../students/students.module';
import { AgentToolRegistry } from './agent-tool.registry';
import { AgentToolExecutor } from './agent-tool.executor';
import { SearchStudentsTool } from './tools/search-students.tool';
import { GetStudentBasicTool } from './tools/get-student-basic.tool';
/**
* Agent Tools feature module.
*
* Provides a provider-neutral tool executor for LLM agent frameworks.
* SDK consumers interact ONLY with {@link AgentToolExecutor}.
*
* `AgentToolRegistry` is an internal provider — it is NOT exported from
* this module. All tool listing and execution goes through the executor,
* which enforces double-check authorization, audit logging, and context
* trust validation.
*
* Imports `StudentsModule` for student data access and relies on the
* globally available `AuthorizationModule` and `OperationLogsModule`.
*/
@Module({
imports: [StudentsModule],
providers: [
AgentToolRegistry,
AgentToolExecutor,
SearchStudentsTool,
GetStudentBasicTool,
],
exports: [AgentToolExecutor],
})
export class AgentToolsModule implements OnModuleInit {
constructor(
private readonly registry: AgentToolRegistry,
private readonly searchTool: SearchStudentsTool,
private readonly getTool: GetStudentBasicTool,
) {}
onModuleInit(): void {
this.registry.register(this.searchTool);
this.registry.register(this.getTool);
}
}