This directory contains Zod schemas and TypeScript types that mirror the Pydantic models from the Python eval_protocol/models.py file.
eval-protocol.ts- Main Zod schemas and TypeScript typeseval-protocol-utils.ts- Utility functions for working with evaluation dataindex.ts- Re-exports for easier importing
import { EvaluationRow, Message, EvaluateResult } from '@/types';import { EvaluationRowSchema, MessageSchema } from '@/types';
// Validate incoming data
const validateEvaluationRow = (data: unknown) => {
return EvaluationRowSchema.parse(data);
};
// Safe parsing with error handling
const safeParseMessage = (data: unknown) => {
const result = MessageSchema.safeParse(data);
if (!result.success) {
console.error('Validation failed:', result.error);
return null;
}
return result.data;
};import { evalRowUtils, messageUtils, evaluateResultUtils } from '@/types/eval-protocol-utils';
// Check if evaluation is trajectory-based
const isTrajectory = evalRowUtils.isTrajectoryEvaluation(evaluationRow);
// Get conversation length
const length = evalRowUtils.getConversationLength(evaluationRow);
// Get system message
const systemMsg = evalRowUtils.getSystemMessage(evaluationRow);
// Check if message has tool calls
const hasTools = messageUtils.hasToolCalls(message);
// Get message content as string
const content = messageUtils.getContentAsString(message);EvaluationRow- Main data structure for evaluation resultsMessage- Chat message with role, content, and optional metadataEvaluateResult- Evaluation results with scores and metricsMetricResult- Individual metric resultsStepOutput- Per-step evaluation output for RL scenarios
TaskDefinitionModel- Task configuration for agent evaluationResourceServerConfig- Server configuration for tasksEvaluationCriteriaModel- Criteria for evaluating task success
MCPMultiClientConfiguration- MCP server configurationMCPConfigurationServerStdio- Stdio-based MCP serverMCPConfigurationServerUrl- URL-based MCP server
import { EvaluationRowSchema } from '@/types';
async function fetchEvaluationData(): Promise<EvaluationRow> {
const response = await fetch('/api/evaluation');
const data = await response.json();
// Validate the response
return EvaluationRowSchema.parse(data);
}import { EvaluationRowSchema, MessageSchema } from '@/types';
const newMessage: Message = {
role: 'user',
content: 'Hello, how are you?'
};
// Validate the message
const validatedMessage = MessageSchema.parse(newMessage);
const newEvaluationRow = {
messages: [validatedMessage],
input_metadata: {
row_id: 'unique-id-123'
},
created_at: new Date()
};
// Validate the evaluation row
const validatedRow = EvaluationRowSchema.parse(newEvaluationRow);All types are derived from Zod schemas, ensuring runtime validation and compile-time type safety. The schemas include:
- Field validation (e.g., score ranges, required fields)
- Default values
- Optional fields
- Union types for flexible content
- Descriptive error messages
The TypeScript types closely mirror the Python Pydantic models:
BaseModel→z.object()Field()→z.string().describe()Optional[T]→z.optional()List[T]→z.array()Dict[str, Any]→z.record(z.any())extra="allow"→.passthrough()