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> { 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): ToolInputResult> { const invalid = rejectUnknownKeys(raw, []); return invalid ?? { ok: true, value: {} }; } execute(_input: Record, context: AgentToolContext) { return this.service.agentGetDashboardStats(context.userId, this.scopes.canManageAllDashboard(context)); } }