20 lines
1.2 KiB
TypeScript
20 lines
1.2 KiB
TypeScript
import { Injectable } from '@nestjs/common';
|
|
import { DashboardService } from '../../dashboard/dashboard.service';
|
|
import { AgentBusinessScopeFactory } from '../agent-business-scope.factory';
|
|
import type { AgentToolContext, ToolDef, ToolInputResult } from '../agent-tool.types';
|
|
import { rejectUnknownKeys } from './tool-input';
|
|
|
|
@Injectable()
|
|
export class GetDashboardStatsTool implements ToolDef<Record<string, never>> {
|
|
readonly name = 'get_dashboard_stats'; readonly requiredPermission = 'dashboard:view';
|
|
readonly description = '获取当前用户数据范围内的学生、班级和今日考勤概览。';
|
|
readonly inputSchema = { type: 'object', properties: {}, additionalProperties: false };
|
|
constructor(private readonly service: DashboardService, private readonly scopes: AgentBusinessScopeFactory) {}
|
|
validate(raw: Record<string, unknown>): ToolInputResult<Record<string, never>> {
|
|
const invalid = rejectUnknownKeys(raw, []); return invalid ?? { ok: true, value: {} };
|
|
}
|
|
execute(_input: Record<string, never>, context: AgentToolContext) {
|
|
return this.service.agentGetDashboardStats(context.userId, this.scopes.canManageAllDashboard(context));
|
|
}
|
|
}
|