UNPKG

@salesforce/agents

Version:

Client side APIs for working with Salesforce agents

58 lines (57 loc) 2.23 kB
export type EvalPayload = { tests: EvalTest[]; }; export type EvalTest = { id: string; steps: EvalStep[]; }; export type EvalStep = { [key: string]: unknown; type: string; id: string; }; /** * Apply all normalizations to a test payload. * Passes run in order: mcp-shorthand -> auto-correct -> camelCase -> evaluator fields -> shorthand refs -> defaults -> strip. */ export declare function normalizePayload(payload: EvalPayload): EvalPayload; /** * Convert MCP shorthand format to raw Eval API format. * MCP uses type="evaluator" + evaluator_type, raw API uses type="evaluator.xxx". * Also maps `field` to `actual` with proper JSONPath and auto-generates missing `id` fields. */ export declare function normalizeMcpShorthand(steps: EvalStep[]): EvalStep[]; /** * Auto-correct common field name mistakes. * Maps wrong field names to correct ones (agentId->agent_id, text->utterance, etc.) */ export declare function autoCorrectFields(steps: EvalStep[]): EvalStep[]; /** * Normalize camelCase agent field names to snake_case. * useAgentApi->use_agent_api, plannerDefinitionId->planner_id, etc. */ export declare function normalizeCamelCase(steps: EvalStep[]): EvalStep[]; /** * Normalize evaluator field names based on evaluator category. * Maps actual/expected <-> generated_output/reference_answer. * Also auto-lowercases operator values and auto-injects metric_name. */ export declare function normalizeEvaluatorFields(steps: EvalStep[]): EvalStep[]; /** * Convert {step_id.field} shorthand references to JSONPath $.outputs[N].field. * Builds step_id->index mapping from non-evaluator steps. */ export declare function convertShorthandRefs(steps: EvalStep[]): EvalStep[]; /** * Inject default values: * - use_agent_api=true on agent.create_session if neither use_agent_api nor planner_id present */ export declare function injectDefaults(steps: EvalStep[]): EvalStep[]; /** * Strip unrecognized fields from steps based on type-specific whitelists. */ export declare function stripUnrecognizedFields(steps: EvalStep[]): EvalStep[]; /** * Split tests array into chunks of batchSize. */ export declare function splitIntoBatches(tests: EvalTest[], batchSize: number): EvalTest[][];