All files provider.ts

85.71% Statements 6/7
100% Branches 2/2
66.66% Functions 2/3
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58                                1x         1x       1x               1x                         1x           1x          
import {
  ToolProvider,
  ToolName,
  SpokeOutput,
  ScanOptions,
  ToolScoringOutput,
  AnalysisResult,
  SpokeOutputSchema,
} from '@aiready/core';
import { analyzeAgentGrounding } from './analyzer';
import { calculateGroundingScore } from './scoring';
import { AgentGroundingOptions, AgentGroundingReport } from './types';
 
/**
 * Agent Grounding Tool Provider
 */
export const AgentGroundingProvider: ToolProvider = {
  id: ToolName.AgentGrounding,
  alias: ['agent-grounding', 'grounding', 'navigation'],
 
  async analyze(options: ScanOptions): Promise<SpokeOutput> {
    const report = await analyzeAgentGrounding(
      options as AgentGroundingOptions
    );
 
    const results: AnalysisResult[] = report.issues.map((i) => ({
      fileName: i.location.file,
      issues: [i] as any[],
      metrics: {
        agentGroundingScore: report.summary.score,
      },
    }));
 
    return SpokeOutputSchema.parse({
      results,
      summary: report.summary,
      metadata: {
        toolName: ToolName.AgentGrounding,
        version: '0.9.5',
        timestamp: new Date().toISOString(),
        rawData: report.rawData,
      },
    });
  },
 
  score(output: SpokeOutput, options: ScanOptions): ToolScoringOutput {
    const report = {
      summary: output.summary,
      rawData: (output.metadata as any).rawData,
      recommendations: (output.summary as any).recommendations || [],
    } as unknown as AgentGroundingReport;
 
    return calculateGroundingScore(report);
  },
 
  defaultWeight: 10,
};