@mastra/core
Version:
Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.
57 lines • 3.39 kB
TypeScript
import type { MastraScorer } from '../../evals/base.js';
import type { ScorerRunInputForAgent, ScorerRunOutputForAgent } from '../../evals/types.js';
import type { Mastra } from '../../mastra/index.js';
import type { MastraCompositeStore } from '../../storage/base.js';
import type { TargetType } from '../../storage/types.js';
import type { StepResult } from '../../workflows/index.js';
import type { ScorerResult } from './types.js';
/**
* Resolve scorers from mixed array of instances and string IDs.
* String IDs are looked up from Mastra's scorer registry.
*/
export declare function resolveScorers(mastra: Mastra, scorers?: (MastraScorer<any, any, any, any> | string)[]): MastraScorer<any, any, any, any>[];
/**
* Workflow-specific data forwarded to scorers so they can inspect step-level
* input/output and the executed step path. Surfaced via `targetMetadata` on
* the scorer run so existing scorer signatures stay unchanged.
*/
export interface WorkflowScorerData {
stepResults?: Record<string, StepResult<any, any, any, any>>;
stepExecutionPath?: string[];
spanId?: string | null;
}
/**
* Run all scorers for a single item result.
* Errors are isolated per scorer - one failing scorer doesn't affect others.
* Trajectory scorers (scorer.type === 'trajectory') receive a pre-extracted
* Trajectory as their output, mirroring the dispatch runEvals performs.
*/
export declare function runScorersForItem(scorers: MastraScorer<any, any, any, any>[], item: {
input: unknown;
groundTruth?: unknown;
metadata?: Record<string, unknown>;
}, output: unknown, storage: MastraCompositeStore | null, runId: string, targetType: TargetType, targetId: string, itemId: string, scorerInput?: ScorerRunInputForAgent, scorerOutput?: ScorerRunOutputForAgent, traceId?: string, workflowData?: WorkflowScorerData): Promise<ScorerResult[]>;
/**
* Resolve step-scoped scorers from a `Record<stepId, (MastraScorer | string)[]>`.
* String IDs are looked up from Mastra's scorer registry; missing IDs are skipped
* with a warning (matching `resolveScorers`).
*/
export declare function resolveStepScorers(mastra: Mastra, stepsConfig?: Record<string, (MastraScorer<any, any, any, any> | string)[]>): Record<string, MastraScorer<any, any, any, any>[]>;
/**
* Run step-scoped scorers for a single workflow item. Mirrors the per-step
* dispatch in `runEvals`: each scorer runs against `stepResult.payload` and
* `stepResult.output`, with `targetScope: 'span'` and
* `targetEntityType: WORKFLOW_STEP`. The returned `ScorerResult` carries the
* originating `stepId` so callers can disambiguate per-step results in the
* flat `scores` array. Steps whose result is missing or did not succeed
* surface as an error `ScorerResult` rather than disappearing silently.
*
* Errors are isolated per scorer (consistent with `runScorersForItem`); a
* failing scorer produces a `ScorerResult` with `error` set, not a throw.
*/
export declare function runStepScorersForItem(stepScorers: Record<string, MastraScorer<any, any, any, any>[]>, item: {
input: unknown;
groundTruth?: unknown;
metadata?: Record<string, unknown>;
}, workflowData: WorkflowScorerData | undefined, storage: MastraCompositeStore | null, runId: string, targetType: TargetType, targetId: string, itemId: string, traceId?: string): Promise<ScorerResult[]>;
//# sourceMappingURL=scorer.d.ts.map