@agentv/core 0.25.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-OYTL3LNN.js → chunk-V3JCB3HI.js} +5 -2
- package/dist/chunk-V3JCB3HI.js.map +1 -0
- package/dist/evaluation/validation/index.cjs.map +1 -1
- package/dist/evaluation/validation/index.js +1 -1
- package/dist/evaluation/validation/index.js.map +1 -1
- package/dist/index.cjs +93 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -7
- package/dist/index.d.ts +13 -7
- package/dist/index.js +89 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-OYTL3LNN.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/evaluation/validation/file-type.ts","../../../src/evaluation/validation/eval-validator.ts","../../../src/evaluation/validation/targets-validator.ts","../../../src/evaluation/validation/config-validator.ts","../../../src/evaluation/validation/file-reference-validator.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport type { FileType } from './types.js';\n\nconst SCHEMA_EVAL_V2 = 'agentv-eval-v2';\nconst SCHEMA_TARGETS_V2 = 'agentv-targets-v2.2';\nconst SCHEMA_CONFIG_V2 = 'agentv-config-v2';\n\n/**\n * Detect file type by reading $schema field from YAML file.\n * If $schema is missing, infers type from filename/path:\n * - config.yaml under .agentv folder → 'config'\n * - targets.yaml under .agentv folder → 'targets'\n * - All other YAML files → 'eval' (default)\n */\nexport async function detectFileType(filePath: string): Promise<FileType> {\n try {\n const content = await readFile(filePath, 'utf8');\n const parsed = parse(content) as unknown;\n\n if (typeof parsed !== 'object' || parsed === null) {\n return inferFileTypeFromPath(filePath);\n }\n\n const record = parsed as Record<string, unknown>;\n const schema = record.$schema;\n\n if (typeof schema !== 'string') {\n // No $schema field - infer from path\n return inferFileTypeFromPath(filePath);\n }\n\n switch (schema) {\n case SCHEMA_EVAL_V2:\n return 'eval';\n case SCHEMA_TARGETS_V2:\n return 'targets';\n case SCHEMA_CONFIG_V2:\n return 'config';\n default:\n // Unknown schema - infer from path\n return inferFileTypeFromPath(filePath);\n }\n } catch {\n return inferFileTypeFromPath(filePath);\n }\n}\n\n/**\n * Infer file type from filename and directory path.\n */\nfunction inferFileTypeFromPath(filePath: string): FileType {\n const normalized = path.normalize(filePath).replace(/\\\\/g, '/');\n const basename = path.basename(filePath);\n\n // Check if file is under .agentv folder\n if (normalized.includes('/.agentv/')) {\n if (basename === 'config.yaml' || basename === 'config.yml') {\n return 'config';\n }\n if (basename === 'targets.yaml' || basename === 'targets.yml') {\n return 'targets';\n }\n }\n\n // Default to eval file\n return 'eval';\n}\n\n/**\n * Check if a schema value is a valid AgentV schema identifier.\n */\nexport function isValidSchema(schema: unknown): boolean {\n return schema === SCHEMA_EVAL_V2 || schema === SCHEMA_TARGETS_V2 || schema === SCHEMA_CONFIG_V2;\n}\n\n/**\n * Get the expected schema for a file type.\n */\nexport function getExpectedSchema(fileType: FileType): string | undefined {\n switch (fileType) {\n case 'eval':\n return SCHEMA_EVAL_V2;\n case 'targets':\n return SCHEMA_TARGETS_V2;\n case 'config':\n return SCHEMA_CONFIG_V2;\n default:\n return undefined;\n }\n}\n","import { readFile } from 'node:fs/promises';\r\nimport path from 'node:path';\r\nimport { parse } from 'yaml';\r\n\r\nimport type { ValidationError, ValidationResult } from './types.js';\r\n\r\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\r\ntype JsonObject = { readonly [key: string]: JsonValue };\r\ntype JsonArray = readonly JsonValue[];\r\n\r\nfunction isObject(value: unknown): value is JsonObject {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value);\r\n}\r\n\r\n/**\r\n * Validate an eval file (agentv-eval-v2 schema).\r\n */\r\nexport async function validateEvalFile(filePath: string): Promise<ValidationResult> {\r\n const errors: ValidationError[] = [];\r\n const absolutePath = path.resolve(filePath);\r\n\r\n let parsed: unknown;\r\n try {\r\n const content = await readFile(absolutePath, 'utf8');\r\n parsed = parse(content);\r\n } catch (error) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n message: `Failed to parse YAML: ${(error as Error).message}`,\r\n });\r\n return {\r\n valid: false,\r\n filePath: absolutePath,\r\n fileType: 'eval',\r\n errors,\r\n };\r\n }\r\n\r\n if (!isObject(parsed)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n message: 'File must contain a YAML object',\r\n });\r\n return {\r\n valid: false,\r\n filePath: absolutePath,\r\n fileType: 'eval',\r\n errors,\r\n };\r\n }\r\n\r\n // Validate evalcases array\r\n const evalcases = parsed.evalcases;\r\n if (!Array.isArray(evalcases)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: 'evalcases',\r\n message: \"Missing or invalid 'evalcases' field (must be an array)\",\r\n });\r\n return {\r\n valid: errors.length === 0,\r\n filePath: absolutePath,\r\n fileType: 'eval',\r\n errors,\r\n };\r\n }\r\n\r\n // Validate each eval case\r\n for (let i = 0; i < evalcases.length; i++) {\r\n const evalCase = evalcases[i];\r\n const location = `evalcases[${i}]`;\r\n\r\n if (!isObject(evalCase)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location,\r\n message: 'Eval case must be an object',\r\n });\r\n continue;\r\n }\r\n\r\n // Required fields: id, input_messages, expected_messages\r\n const id = evalCase.id;\r\n if (typeof id !== 'string' || id.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.id`,\r\n message: \"Missing or invalid 'id' field (must be a non-empty string)\",\r\n });\r\n }\r\n\r\n // Optional: expected_outcome or outcome for backward compatibility\r\n const expectedOutcome = evalCase.expected_outcome ?? evalCase.outcome;\r\n if (\r\n expectedOutcome !== undefined &&\r\n (typeof expectedOutcome !== 'string' || expectedOutcome.trim().length === 0)\r\n ) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.expected_outcome`,\r\n message:\r\n \"Invalid 'expected_outcome' or 'outcome' field (must be a non-empty string if provided)\",\r\n });\r\n }\r\n\r\n const inputMessages = evalCase.input_messages;\r\n if (!Array.isArray(inputMessages)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.input_messages`,\r\n message: \"Missing or invalid 'input_messages' field (must be an array)\",\r\n });\r\n } else {\r\n validateMessages(inputMessages, `${location}.input_messages`, absolutePath, errors);\r\n }\r\n\r\n // expected_messages is optional - for outcome-only evaluation\r\n const expectedMessages = evalCase.expected_messages;\r\n if (expectedMessages !== undefined && !Array.isArray(expectedMessages)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.expected_messages`,\r\n message: \"Invalid 'expected_messages' field (must be an array if provided)\",\r\n });\r\n } else if (Array.isArray(expectedMessages)) {\r\n validateMessages(expectedMessages, `${location}.expected_messages`, absolutePath, errors);\r\n }\r\n }\r\n\r\n return {\r\n valid: errors.length === 0,\r\n filePath: absolutePath,\r\n fileType: 'eval',\r\n errors,\r\n };\r\n}\r\n\r\nfunction validateMessages(\r\n messages: JsonArray,\r\n location: string,\r\n filePath: string,\r\n errors: ValidationError[],\r\n): void {\r\n for (let i = 0; i < messages.length; i++) {\r\n const message = messages[i];\r\n const msgLocation = `${location}[${i}]`;\r\n\r\n if (!isObject(message)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: msgLocation,\r\n message: 'Message must be an object',\r\n });\r\n continue;\r\n }\r\n\r\n // Validate role field\r\n const role = message.role;\r\n const validRoles = ['system', 'user', 'assistant'];\r\n if (!validRoles.includes(role as string)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${msgLocation}.role`,\r\n message: `Invalid role '${role}'. Must be one of: ${validRoles.join(', ')}`,\r\n });\r\n }\r\n\r\n // Validate tool_calls field for assistant messages\r\n const toolCalls = message.tool_calls;\r\n if (toolCalls !== undefined) {\r\n if (role !== 'assistant') {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${msgLocation}.tool_calls`,\r\n message: 'tool_calls can only be specified on assistant messages',\r\n });\r\n } else if (!Array.isArray(toolCalls)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${msgLocation}.tool_calls`,\r\n message: 'tool_calls must be an array',\r\n });\r\n } else {\r\n validateToolCalls(toolCalls, `${msgLocation}.tool_calls`, filePath, errors);\r\n }\r\n }\r\n\r\n // Validate content field (can be string or array)\r\n const content = message.content;\r\n if (typeof content === 'string') {\r\n validateContentForRoleMarkers(content, `${msgLocation}.content`, filePath, errors);\r\n } else if (Array.isArray(content)) {\r\n // Array content - validate each element\r\n for (let j = 0; j < content.length; j++) {\r\n const contentItem = content[j];\r\n const contentLocation = `${msgLocation}.content[${j}]`;\r\n\r\n if (typeof contentItem === 'string') {\r\n validateContentForRoleMarkers(contentItem, contentLocation, filePath, errors);\r\n } else if (isObject(contentItem)) {\r\n const type = contentItem.type;\r\n if (typeof type !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${contentLocation}.type`,\r\n message: \"Content object must have a 'type' field\",\r\n });\r\n }\r\n\r\n // For 'file' type, we'll validate existence later in file-reference-validator\r\n // For 'text' type, require 'value' field\r\n if (type === 'text') {\r\n const value = contentItem.value;\r\n if (typeof value !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${contentLocation}.value`,\r\n message: \"Content with type 'text' must have a 'value' field\",\r\n });\r\n } else {\r\n validateContentForRoleMarkers(value, `${contentLocation}.value`, filePath, errors);\r\n }\r\n }\r\n } else {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: contentLocation,\r\n message: 'Content array items must be strings or objects',\r\n });\r\n }\r\n }\r\n } else {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${msgLocation}.content`,\r\n message: \"Missing or invalid 'content' field (must be a string or array)\",\r\n });\r\n }\r\n }\r\n}\r\n\r\nfunction validateContentForRoleMarkers(\r\n content: string,\r\n location: string,\r\n filePath: string,\r\n errors: ValidationError[],\r\n): void {\r\n // Check for standard role markers that might confuse agentic providers\r\n const markers = ['@[System]:', '@[User]:', '@[Assistant]:', '@[Tool]:'];\r\n for (const marker of markers) {\r\n if (content.toLowerCase().includes(marker.toLowerCase())) {\r\n errors.push({\r\n severity: 'warning',\r\n filePath,\r\n location,\r\n message: `Content contains potential role marker '${marker}'. This may confuse agentic providers or cause prompt injection.`,\r\n });\r\n }\r\n }\r\n}\r\n\r\nfunction validateToolCalls(\r\n toolCalls: JsonArray,\r\n location: string,\r\n filePath: string,\r\n errors: ValidationError[],\r\n): void {\r\n for (let i = 0; i < toolCalls.length; i++) {\r\n const toolCall = toolCalls[i];\r\n const callLocation = `${location}[${i}]`;\r\n\r\n if (!isObject(toolCall)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: callLocation,\r\n message: 'Tool call must be an object',\r\n });\r\n continue;\r\n }\r\n\r\n // Required: tool field\r\n const tool = toolCall.tool;\r\n if (typeof tool !== 'string' || tool.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath,\r\n location: `${callLocation}.tool`,\r\n message: \"Missing or invalid 'tool' field (must be a non-empty string)\",\r\n });\r\n }\r\n\r\n // Optional: input field (any JSON value is valid)\r\n // Optional: output field (any JSON value is valid)\r\n // No additional validation needed for input/output - they're flexible\r\n }\r\n}\r\n","import { readFile } from 'node:fs/promises';\r\nimport path from 'node:path';\r\nimport { parse } from 'yaml';\r\n\r\nimport { CLI_PLACEHOLDERS } from '../providers/targets.js';\r\nimport { KNOWN_PROVIDERS, PROVIDER_ALIASES, TARGETS_SCHEMA_V2 } from '../providers/types.js';\r\nimport type { ValidationError, ValidationResult } from './types.js';\r\n\r\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\r\ntype JsonObject = { readonly [key: string]: JsonValue };\r\ntype JsonArray = readonly JsonValue[];\r\n\r\nfunction isObject(value: unknown): value is JsonObject {\r\n return typeof value === 'object' && value !== null && !Array.isArray(value);\r\n}\r\n\r\n// Known settings properties for each provider type\r\nconst COMMON_SETTINGS = new Set(['provider_batching', 'providerBatching']);\r\n\r\nconst RETRY_SETTINGS = new Set([\r\n 'max_retries',\r\n 'maxRetries',\r\n 'retry_initial_delay_ms',\r\n 'retryInitialDelayMs',\r\n 'retry_max_delay_ms',\r\n 'retryMaxDelayMs',\r\n 'retry_backoff_factor',\r\n 'retryBackoffFactor',\r\n 'retry_status_codes',\r\n 'retryStatusCodes',\r\n]);\r\n\r\nconst AZURE_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n ...RETRY_SETTINGS,\r\n 'endpoint',\r\n 'resource',\r\n 'resourceName',\r\n 'api_key',\r\n 'apiKey',\r\n 'deployment',\r\n 'deploymentName',\r\n 'model',\r\n 'version',\r\n 'api_version',\r\n 'temperature',\r\n 'max_output_tokens',\r\n 'maxTokens',\r\n]);\r\n\r\nconst ANTHROPIC_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n ...RETRY_SETTINGS,\r\n 'api_key',\r\n 'apiKey',\r\n 'model',\r\n 'deployment',\r\n 'variant',\r\n 'temperature',\r\n 'max_output_tokens',\r\n 'maxTokens',\r\n 'thinking_budget',\r\n 'thinkingBudget',\r\n]);\r\n\r\nconst GEMINI_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n ...RETRY_SETTINGS,\r\n 'api_key',\r\n 'apiKey',\r\n 'model',\r\n 'deployment',\r\n 'variant',\r\n 'temperature',\r\n 'max_output_tokens',\r\n 'maxTokens',\r\n]);\r\n\r\nconst CODEX_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n 'executable',\r\n 'command',\r\n 'binary',\r\n 'args',\r\n 'arguments',\r\n 'cwd',\r\n 'timeout_seconds',\r\n 'timeoutSeconds',\r\n 'log_dir',\r\n 'logDir',\r\n 'log_directory',\r\n 'logDirectory',\r\n 'log_format',\r\n 'logFormat',\r\n 'log_output_format',\r\n 'logOutputFormat',\r\n]);\r\n\r\nconst VSCODE_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n 'workspace_template',\r\n 'workspaceTemplate',\r\n 'vscode_cmd',\r\n 'command',\r\n 'wait',\r\n 'dry_run',\r\n 'dryRun',\r\n 'subagent_root',\r\n 'subagentRoot',\r\n]);\r\n\r\nconst MOCK_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n 'response',\r\n 'delayMs',\r\n 'delayMinMs',\r\n 'delayMaxMs',\r\n 'trace', // For testing tool_trajectory evaluator\r\n]);\r\n\r\nconst CLI_SETTINGS = new Set([\r\n ...COMMON_SETTINGS,\r\n 'command_template',\r\n 'commandTemplate',\r\n 'files_format',\r\n 'filesFormat',\r\n 'attachments_format',\r\n 'attachmentsFormat',\r\n 'cwd',\r\n 'env',\r\n 'timeout_seconds',\r\n 'timeoutSeconds',\r\n 'healthcheck',\r\n]);\r\n\r\nfunction getKnownSettings(provider: string): Set<string> | null {\r\n const normalizedProvider = provider.toLowerCase();\r\n switch (normalizedProvider) {\r\n case 'azure':\r\n case 'azure-openai':\r\n return AZURE_SETTINGS;\r\n case 'anthropic':\r\n return ANTHROPIC_SETTINGS;\r\n case 'gemini':\r\n case 'google':\r\n case 'google-gemini':\r\n return GEMINI_SETTINGS;\r\n case 'codex':\r\n case 'codex-cli':\r\n return CODEX_SETTINGS;\r\n case 'vscode':\r\n case 'vscode-insiders':\r\n return VSCODE_SETTINGS;\r\n case 'mock':\r\n return MOCK_SETTINGS;\r\n case 'cli':\r\n return CLI_SETTINGS;\r\n default:\r\n return null; // Unknown provider, can't validate settings\r\n }\r\n}\r\n\r\nfunction validateUnknownSettings(\r\n target: JsonObject,\r\n provider: string,\r\n absolutePath: string,\r\n location: string,\r\n errors: ValidationError[],\r\n): void {\r\n const knownSettings = getKnownSettings(provider);\r\n if (!knownSettings) {\r\n // Unknown provider, skip settings validation\r\n return;\r\n }\r\n\r\n // Known base target fields that aren't settings\r\n const baseFields = new Set(['name', 'provider', 'judge_target', 'workers', '$schema', 'targets']);\r\n\r\n for (const key of Object.keys(target)) {\r\n if (!baseFields.has(key) && !knownSettings.has(key)) {\r\n errors.push({\r\n severity: 'warning',\r\n filePath: absolutePath,\r\n location: `${location}.${key}`,\r\n message: `Unknown setting '${key}' for ${provider} provider. This property will be ignored.`,\r\n });\r\n }\r\n }\r\n}\r\n\r\n/**\r\n * Validate a targets file (agentv-targets-v2.1 schema).\r\n */\r\nexport async function validateTargetsFile(filePath: string): Promise<ValidationResult> {\r\n const errors: ValidationError[] = [];\r\n const absolutePath = path.resolve(filePath);\r\n\r\n let parsed: unknown;\r\n try {\r\n const content = await readFile(absolutePath, 'utf8');\r\n parsed = parse(content);\r\n } catch (error) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n message: `Failed to parse YAML: ${(error as Error).message}`,\r\n });\r\n return {\r\n valid: false,\r\n filePath: absolutePath,\r\n fileType: 'targets',\r\n errors,\r\n };\r\n }\r\n\r\n function validateCliSettings(\r\n target: JsonObject,\r\n absolutePath: string,\r\n location: string,\r\n errors: ValidationError[],\r\n ): void {\r\n const commandTemplate = target.command_template ?? target.commandTemplate;\r\n if (typeof commandTemplate !== 'string' || commandTemplate.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.commandTemplate`,\r\n message: \"CLI provider requires 'commandTemplate' as a non-empty string\",\r\n });\r\n } else {\r\n recordUnknownPlaceholders(\r\n commandTemplate,\r\n absolutePath,\r\n `${location}.commandTemplate`,\r\n errors,\r\n );\r\n }\r\n\r\n const attachmentsFormat = target.attachments_format ?? target.attachmentsFormat;\r\n if (attachmentsFormat !== undefined && typeof attachmentsFormat !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.attachmentsFormat`,\r\n message: \"'attachmentsFormat' must be a string when provided\",\r\n });\r\n }\r\n\r\n const filesFormat = target.files_format ?? target.filesFormat;\r\n if (filesFormat !== undefined && typeof filesFormat !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.filesFormat`,\r\n message: \"'filesFormat' must be a string when provided\",\r\n });\r\n }\r\n\r\n const cwd = target.cwd;\r\n if (cwd !== undefined && typeof cwd !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.cwd`,\r\n message: \"'cwd' must be a string when provided\",\r\n });\r\n }\r\n\r\n const timeoutSeconds = target.timeout_seconds ?? target.timeoutSeconds;\r\n if (timeoutSeconds !== undefined) {\r\n const numericTimeout = Number(timeoutSeconds);\r\n if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.timeoutSeconds`,\r\n message: \"'timeoutSeconds' must be a positive number when provided\",\r\n });\r\n }\r\n }\r\n\r\n const healthcheck = target.healthcheck;\r\n if (healthcheck !== undefined) {\r\n validateCliHealthcheck(healthcheck, absolutePath, `${location}.healthcheck`, errors);\r\n }\r\n }\r\n\r\n function validateCliHealthcheck(\r\n healthcheck: unknown,\r\n absolutePath: string,\r\n location: string,\r\n errors: ValidationError[],\r\n ): void {\r\n if (!isObject(healthcheck)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location,\r\n message: \"'healthcheck' must be an object when provided\",\r\n });\r\n return;\r\n }\r\n\r\n const type = healthcheck.type;\r\n if (type !== 'http' && type !== 'command') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.type`,\r\n message: \"healthcheck.type must be either 'http' or 'command'\",\r\n });\r\n return;\r\n }\r\n\r\n const timeoutSeconds = healthcheck.timeout_seconds ?? healthcheck.timeoutSeconds;\r\n if (timeoutSeconds !== undefined) {\r\n const numericTimeout = Number(timeoutSeconds);\r\n if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.timeoutSeconds`,\r\n message: 'healthcheck.timeoutSeconds must be a positive number when provided',\r\n });\r\n }\r\n }\r\n\r\n if (type === 'http') {\r\n const url = healthcheck.url;\r\n if (typeof url !== 'string' || url.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.url`,\r\n message: 'healthcheck.url must be a non-empty string for http checks',\r\n });\r\n }\r\n return;\r\n }\r\n\r\n const commandTemplate = healthcheck.command_template ?? healthcheck.commandTemplate;\r\n if (typeof commandTemplate !== 'string' || commandTemplate.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.commandTemplate`,\r\n message: 'healthcheck.commandTemplate must be a non-empty string for command checks',\r\n });\r\n } else {\r\n recordUnknownPlaceholders(\r\n commandTemplate,\r\n absolutePath,\r\n `${location}.commandTemplate`,\r\n errors,\r\n );\r\n }\r\n\r\n const cwd = healthcheck.cwd;\r\n if (cwd !== undefined && typeof cwd !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.cwd`,\r\n message: 'healthcheck.cwd must be a string when provided',\r\n });\r\n }\r\n }\r\n\r\n function recordUnknownPlaceholders(\r\n template: string,\r\n absolutePath: string,\r\n location: string,\r\n errors: ValidationError[],\r\n ): void {\r\n const placeholders = extractPlaceholders(template);\r\n for (const placeholder of placeholders) {\r\n if (!CLI_PLACEHOLDERS.has(placeholder)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location,\r\n message: `Unknown CLI placeholder '{${placeholder}}'. Supported placeholders: ${Array.from(CLI_PLACEHOLDERS).join(', ')}`,\r\n });\r\n }\r\n }\r\n }\r\n\r\n function extractPlaceholders(template: string): string[] {\r\n const matches = template.matchAll(/\\{([A-Z_]+)\\}/g);\r\n const result: string[] = [];\r\n for (const match of matches) {\r\n const placeholder = match[1];\r\n if (placeholder) {\r\n result.push(placeholder);\r\n }\r\n }\r\n return result;\r\n }\r\n\r\n if (!isObject(parsed)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n message: 'File must contain a YAML object',\r\n });\r\n return {\r\n valid: false,\r\n filePath: absolutePath,\r\n fileType: 'targets',\r\n errors,\r\n };\r\n }\r\n\r\n // Validate targets array\r\n const targets = parsed.targets;\r\n if (!Array.isArray(targets)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: 'targets',\r\n message: \"Missing or invalid 'targets' field (must be an array)\",\r\n });\r\n return {\r\n valid: errors.length === 0,\r\n filePath: absolutePath,\r\n fileType: 'targets',\r\n errors,\r\n };\r\n }\r\n\r\n // Validate each target definition\r\n const knownProviders = [...KNOWN_PROVIDERS, ...PROVIDER_ALIASES];\r\n\r\n for (let i = 0; i < targets.length; i++) {\r\n const target = targets[i];\r\n const location = `targets[${i}]`;\r\n\r\n if (!isObject(target)) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location,\r\n message: 'Target must be an object',\r\n });\r\n continue;\r\n }\r\n\r\n // Required field: name\r\n const name = target.name;\r\n if (typeof name !== 'string' || name.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.name`,\r\n message: \"Missing or invalid 'name' field (must be a non-empty string)\",\r\n });\r\n }\r\n\r\n // Required field: provider\r\n const provider = target.provider;\r\n const providerValue = typeof provider === 'string' ? provider.trim().toLowerCase() : undefined;\r\n if (typeof provider !== 'string' || provider.trim().length === 0) {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.provider`,\r\n message: \"Missing or invalid 'provider' field (must be a non-empty string)\",\r\n });\r\n } else if (!knownProviders.includes(provider)) {\r\n // Warning for unknown providers (non-fatal)\r\n errors.push({\r\n severity: 'warning',\r\n filePath: absolutePath,\r\n location: `${location}.provider`,\r\n message: `Unknown provider '${provider}'. Known providers: ${knownProviders.join(', ')}`,\r\n });\r\n }\r\n\r\n // Validate CLI provider fields\r\n if (providerValue === 'cli') {\r\n validateCliSettings(target, absolutePath, location, errors);\r\n }\r\n\r\n // Check for unknown settings properties on target object\r\n if (typeof provider === 'string') {\r\n validateUnknownSettings(target, provider, absolutePath, location, errors);\r\n }\r\n\r\n // Optional field: judge_target (must be string if present)\r\n const judgeTarget = target.judge_target;\r\n if (judgeTarget !== undefined && typeof judgeTarget !== 'string') {\r\n errors.push({\r\n severity: 'error',\r\n filePath: absolutePath,\r\n location: `${location}.judge_target`,\r\n message: \"Invalid 'judge_target' field (must be a string)\",\r\n });\r\n }\r\n }\r\n\r\n return {\r\n valid: errors.filter((e) => e.severity === 'error').length === 0,\r\n filePath: absolutePath,\r\n fileType: 'targets',\r\n errors,\r\n };\r\n}\r\n","import { readFile } from 'node:fs/promises';\nimport { parse } from 'yaml';\n\nimport type { ValidationError, ValidationResult } from './types.js';\n\nconst SCHEMA_CONFIG_V2 = 'agentv-config-v2';\n\n/**\n * Validate a config.yaml file for schema compliance and structural correctness.\n */\nexport async function validateConfigFile(filePath: string): Promise<ValidationResult> {\n const errors: ValidationError[] = [];\n\n try {\n const content = await readFile(filePath, 'utf8');\n const parsed = parse(content) as unknown;\n\n // Check if parsed content is an object\n if (typeof parsed !== 'object' || parsed === null) {\n errors.push({\n severity: 'error',\n filePath,\n message: 'Config file must contain a valid YAML object',\n });\n return { valid: false, filePath, fileType: 'config', errors };\n }\n\n const config = parsed as Record<string, unknown>;\n\n // Validate $schema field (optional, but if present must be correct)\n const schema = config.$schema;\n if (schema !== undefined && schema !== SCHEMA_CONFIG_V2) {\n const message = `Invalid $schema value '${schema}'. Expected '${SCHEMA_CONFIG_V2}' or omit the field.`;\n errors.push({\n severity: 'error',\n filePath,\n location: '$schema',\n message,\n });\n }\n\n // Validate guideline_patterns if present\n const guidelinePatterns = config.guideline_patterns;\n if (guidelinePatterns !== undefined) {\n if (!Array.isArray(guidelinePatterns)) {\n errors.push({\n severity: 'error',\n filePath,\n location: 'guideline_patterns',\n message: \"Field 'guideline_patterns' must be an array\",\n });\n } else if (!guidelinePatterns.every((p) => typeof p === 'string')) {\n errors.push({\n severity: 'error',\n filePath,\n location: 'guideline_patterns',\n message: \"All entries in 'guideline_patterns' must be strings\",\n });\n } else if (guidelinePatterns.length === 0) {\n errors.push({\n severity: 'warning',\n filePath,\n location: 'guideline_patterns',\n message: \"Field 'guideline_patterns' is empty. Consider removing it or adding patterns.\",\n });\n }\n }\n\n // Check for unexpected fields\n const allowedFields = new Set(['$schema', 'guideline_patterns']);\n const unexpectedFields = Object.keys(config).filter((key) => !allowedFields.has(key));\n\n if (unexpectedFields.length > 0) {\n errors.push({\n severity: 'warning',\n filePath,\n message: `Unexpected fields: ${unexpectedFields.join(', ')}`,\n });\n }\n\n return {\n valid: errors.filter((e) => e.severity === 'error').length === 0,\n filePath,\n fileType: 'config',\n errors,\n };\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath,\n message: `Failed to parse config file: ${(error as Error).message}`,\n });\n return { valid: false, filePath, fileType: 'config', errors };\n }\n}\n","import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport { buildSearchRoots, findGitRoot, resolveFileReference } from '../file-utils.js';\nimport type { ValidationError } from './types.js';\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\ntype JsonObject = { readonly [key: string]: JsonValue };\ntype JsonArray = readonly JsonValue[];\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Validate that file references in eval file content exist.\n * Checks content blocks with type: \"file\" and validates the referenced file exists.\n * Also checks that referenced files are not empty.\n */\nexport async function validateFileReferences(\n evalFilePath: string,\n): Promise<readonly ValidationError[]> {\n const errors: ValidationError[] = [];\n const absolutePath = path.resolve(evalFilePath);\n\n // Find git root and build search roots (same as yaml-parser does at runtime)\n const gitRoot = await findGitRoot(absolutePath);\n if (!gitRoot) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: 'Cannot validate file references: git repository root not found',\n });\n return errors;\n }\n\n const searchRoots = buildSearchRoots(absolutePath, gitRoot);\n\n let parsed: unknown;\n try {\n const content = await readFile(absolutePath, 'utf8');\n parsed = parse(content);\n } catch {\n // Parse errors are already caught by eval-validator\n return errors;\n }\n\n if (!isObject(parsed)) {\n return errors;\n }\n\n const evalcases = parsed.evalcases;\n if (!Array.isArray(evalcases)) {\n return errors;\n }\n\n for (let i = 0; i < evalcases.length; i++) {\n const evalCase = evalcases[i];\n if (!isObject(evalCase)) {\n continue;\n }\n\n // Check input_messages\n const inputMessages = evalCase.input_messages;\n if (Array.isArray(inputMessages)) {\n await validateMessagesFileRefs(\n inputMessages,\n `evalcases[${i}].input_messages`,\n searchRoots,\n absolutePath,\n errors,\n );\n }\n\n // Check expected_messages\n const expectedMessages = evalCase.expected_messages;\n if (Array.isArray(expectedMessages)) {\n await validateMessagesFileRefs(\n expectedMessages,\n `evalcases[${i}].expected_messages`,\n searchRoots,\n absolutePath,\n errors,\n );\n }\n }\n\n return errors;\n}\n\nasync function validateMessagesFileRefs(\n messages: JsonArray,\n location: string,\n searchRoots: readonly string[],\n filePath: string,\n errors: ValidationError[],\n): Promise<void> {\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i];\n if (!isObject(message)) {\n continue;\n }\n\n const content = message.content;\n if (typeof content === 'string') {\n continue;\n }\n\n if (!Array.isArray(content)) {\n continue;\n }\n\n for (let j = 0; j < content.length; j++) {\n const contentItem = content[j];\n if (!isObject(contentItem)) {\n continue;\n }\n\n const type = contentItem.type;\n if (type !== 'file') {\n continue;\n }\n\n const value = contentItem.value;\n if (typeof value !== 'string') {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}].value`,\n message: \"File reference must have a 'value' field with the file path\",\n });\n continue;\n }\n\n // Use the same file resolution logic as yaml-parser at runtime\n const { resolvedPath } = await resolveFileReference(value, searchRoots);\n\n if (!resolvedPath) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Referenced file not found: ${value}`,\n });\n } else {\n // Check that file is not empty\n try {\n const fileContent = await readFile(resolvedPath, 'utf8');\n if (fileContent.trim().length === 0) {\n errors.push({\n severity: 'warning',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Referenced file is empty: ${value}`,\n });\n }\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Cannot read referenced file: ${value} (${(error as Error).message})`,\n });\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAS,aAAa;AAItB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AASzB,eAAsB,eAAe,UAAqC;AACxE,MAAI;AACF,UAAM,UAAU,MAAM,SAAS,UAAU,MAAM;AAC/C,UAAM,SAAS,MAAM,OAAO;AAE5B,QAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,aAAO,sBAAsB,QAAQ;AAAA,IACvC;AAEA,UAAM,SAAS;AACf,UAAM,SAAS,OAAO;AAEtB,QAAI,OAAO,WAAW,UAAU;AAE9B,aAAO,sBAAsB,QAAQ;AAAA,IACvC;AAEA,YAAQ,QAAQ;AAAA,MACd,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AAEE,eAAO,sBAAsB,QAAQ;AAAA,IACzC;AAAA,EACF,QAAQ;AACN,WAAO,sBAAsB,QAAQ;AAAA,EACvC;AACF;AAKA,SAAS,sBAAsB,UAA4B;AACzD,QAAM,aAAa,KAAK,UAAU,QAAQ,EAAE,QAAQ,OAAO,GAAG;AAC9D,QAAM,WAAW,KAAK,SAAS,QAAQ;AAGvC,MAAI,WAAW,SAAS,WAAW,GAAG;AACpC,QAAI,aAAa,iBAAiB,aAAa,cAAc;AAC3D,aAAO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AAO;AAEL,YAAI;AACF,gBAAM,cAAc,MAAME,UAAS,cAAc,MAAM;AACvD,cAAI,YAAY,KAAK,EAAE,WAAW,GAAG;AACnC,mBAAO,KAAK;AAAA,cACV,UAAU;AAAA,cACV;AAAA,cACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,cACxC,SAAS,6BAA6B,KAAK;AAAA,YAC7C,CAAC;AAAA,UACH;AAAA,QACF,SAAS,OAAO;AACd,iBAAO,KAAK;AAAA,YACV,UAAU;AAAA,YACV;AAAA,YACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,YACxC,SAAS,gCAAgC,KAAK,KAAM,MAAgB,OAAO;AAAA,UAC7E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["readFile","path","parse","readFile","path","parse","isObject","path","readFile","parse","absolutePath","errors","readFile","parse","SCHEMA_CONFIG_V2","readFile","path","parse","isObject","path","readFile","parse"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/evaluation/validation/file-type.ts","../../../src/evaluation/validation/eval-validator.ts","../../../src/evaluation/validation/targets-validator.ts","../../../src/evaluation/validation/config-validator.ts","../../../src/evaluation/validation/file-reference-validator.ts"],"sourcesContent":["import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport type { FileType } from './types.js';\n\nconst SCHEMA_EVAL_V2 = 'agentv-eval-v2';\nconst SCHEMA_TARGETS_V2 = 'agentv-targets-v2.2';\nconst SCHEMA_CONFIG_V2 = 'agentv-config-v2';\n\n/**\n * Detect file type by reading $schema field from YAML file.\n * If $schema is missing, infers type from filename/path:\n * - config.yaml under .agentv folder → 'config'\n * - targets.yaml under .agentv folder → 'targets'\n * - All other YAML files → 'eval' (default)\n */\nexport async function detectFileType(filePath: string): Promise<FileType> {\n try {\n const content = await readFile(filePath, 'utf8');\n const parsed = parse(content) as unknown;\n\n if (typeof parsed !== 'object' || parsed === null) {\n return inferFileTypeFromPath(filePath);\n }\n\n const record = parsed as Record<string, unknown>;\n const schema = record.$schema;\n\n if (typeof schema !== 'string') {\n // No $schema field - infer from path\n return inferFileTypeFromPath(filePath);\n }\n\n switch (schema) {\n case SCHEMA_EVAL_V2:\n return 'eval';\n case SCHEMA_TARGETS_V2:\n return 'targets';\n case SCHEMA_CONFIG_V2:\n return 'config';\n default:\n // Unknown schema - infer from path\n return inferFileTypeFromPath(filePath);\n }\n } catch {\n return inferFileTypeFromPath(filePath);\n }\n}\n\n/**\n * Infer file type from filename and directory path.\n */\nfunction inferFileTypeFromPath(filePath: string): FileType {\n const normalized = path.normalize(filePath).replace(/\\\\/g, '/');\n const basename = path.basename(filePath);\n\n // Check if file is under .agentv folder\n if (normalized.includes('/.agentv/')) {\n if (basename === 'config.yaml' || basename === 'config.yml') {\n return 'config';\n }\n if (basename === 'targets.yaml' || basename === 'targets.yml') {\n return 'targets';\n }\n }\n\n // Default to eval file\n return 'eval';\n}\n\n/**\n * Check if a schema value is a valid AgentV schema identifier.\n */\nexport function isValidSchema(schema: unknown): boolean {\n return schema === SCHEMA_EVAL_V2 || schema === SCHEMA_TARGETS_V2 || schema === SCHEMA_CONFIG_V2;\n}\n\n/**\n * Get the expected schema for a file type.\n */\nexport function getExpectedSchema(fileType: FileType): string | undefined {\n switch (fileType) {\n case 'eval':\n return SCHEMA_EVAL_V2;\n case 'targets':\n return SCHEMA_TARGETS_V2;\n case 'config':\n return SCHEMA_CONFIG_V2;\n default:\n return undefined;\n }\n}\n","import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport type { ValidationError, ValidationResult } from './types.js';\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\ntype JsonObject = { readonly [key: string]: JsonValue };\ntype JsonArray = readonly JsonValue[];\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Validate an eval file (agentv-eval-v2 schema).\n */\nexport async function validateEvalFile(filePath: string): Promise<ValidationResult> {\n const errors: ValidationError[] = [];\n const absolutePath = path.resolve(filePath);\n\n let parsed: unknown;\n try {\n const content = await readFile(absolutePath, 'utf8');\n parsed = parse(content);\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: `Failed to parse YAML: ${(error as Error).message}`,\n });\n return {\n valid: false,\n filePath: absolutePath,\n fileType: 'eval',\n errors,\n };\n }\n\n if (!isObject(parsed)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: 'File must contain a YAML object',\n });\n return {\n valid: false,\n filePath: absolutePath,\n fileType: 'eval',\n errors,\n };\n }\n\n // Validate evalcases array\n const evalcases = parsed.evalcases;\n if (!Array.isArray(evalcases)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: 'evalcases',\n message: \"Missing or invalid 'evalcases' field (must be an array)\",\n });\n return {\n valid: errors.length === 0,\n filePath: absolutePath,\n fileType: 'eval',\n errors,\n };\n }\n\n // Validate each eval case\n for (let i = 0; i < evalcases.length; i++) {\n const evalCase = evalcases[i];\n const location = `evalcases[${i}]`;\n\n if (!isObject(evalCase)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location,\n message: 'Eval case must be an object',\n });\n continue;\n }\n\n // Required fields: id, input_messages, expected_messages\n const id = evalCase.id;\n if (typeof id !== 'string' || id.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.id`,\n message: \"Missing or invalid 'id' field (must be a non-empty string)\",\n });\n }\n\n // Optional: expected_outcome or outcome for backward compatibility\n const expectedOutcome = evalCase.expected_outcome ?? evalCase.outcome;\n if (\n expectedOutcome !== undefined &&\n (typeof expectedOutcome !== 'string' || expectedOutcome.trim().length === 0)\n ) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.expected_outcome`,\n message:\n \"Invalid 'expected_outcome' or 'outcome' field (must be a non-empty string if provided)\",\n });\n }\n\n const inputMessages = evalCase.input_messages;\n if (!Array.isArray(inputMessages)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.input_messages`,\n message: \"Missing or invalid 'input_messages' field (must be an array)\",\n });\n } else {\n validateMessages(inputMessages, `${location}.input_messages`, absolutePath, errors);\n }\n\n // expected_messages is optional - for outcome-only evaluation\n const expectedMessages = evalCase.expected_messages;\n if (expectedMessages !== undefined && !Array.isArray(expectedMessages)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.expected_messages`,\n message: \"Invalid 'expected_messages' field (must be an array if provided)\",\n });\n } else if (Array.isArray(expectedMessages)) {\n validateMessages(expectedMessages, `${location}.expected_messages`, absolutePath, errors);\n }\n }\n\n return {\n valid: errors.length === 0,\n filePath: absolutePath,\n fileType: 'eval',\n errors,\n };\n}\n\nfunction validateMessages(\n messages: JsonArray,\n location: string,\n filePath: string,\n errors: ValidationError[],\n): void {\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i];\n const msgLocation = `${location}[${i}]`;\n\n if (!isObject(message)) {\n errors.push({\n severity: 'error',\n filePath,\n location: msgLocation,\n message: 'Message must be an object',\n });\n continue;\n }\n\n // Validate role field\n const role = message.role;\n const validRoles = ['system', 'user', 'assistant'];\n if (!validRoles.includes(role as string)) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${msgLocation}.role`,\n message: `Invalid role '${role}'. Must be one of: ${validRoles.join(', ')}`,\n });\n }\n\n // Validate tool_calls field for assistant messages\n const toolCalls = message.tool_calls;\n if (toolCalls !== undefined) {\n if (role !== 'assistant') {\n errors.push({\n severity: 'error',\n filePath,\n location: `${msgLocation}.tool_calls`,\n message: 'tool_calls can only be specified on assistant messages',\n });\n } else if (!Array.isArray(toolCalls)) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${msgLocation}.tool_calls`,\n message: 'tool_calls must be an array',\n });\n } else {\n validateToolCalls(toolCalls, `${msgLocation}.tool_calls`, filePath, errors);\n }\n }\n\n // Validate content field (can be string or array)\n const content = message.content;\n if (typeof content === 'string') {\n validateContentForRoleMarkers(content, `${msgLocation}.content`, filePath, errors);\n } else if (Array.isArray(content)) {\n // Array content - validate each element\n for (let j = 0; j < content.length; j++) {\n const contentItem = content[j];\n const contentLocation = `${msgLocation}.content[${j}]`;\n\n if (typeof contentItem === 'string') {\n validateContentForRoleMarkers(contentItem, contentLocation, filePath, errors);\n } else if (isObject(contentItem)) {\n const type = contentItem.type;\n if (typeof type !== 'string') {\n errors.push({\n severity: 'error',\n filePath,\n location: `${contentLocation}.type`,\n message: \"Content object must have a 'type' field\",\n });\n }\n\n // For 'file' type, we'll validate existence later in file-reference-validator\n // For 'text' type, require 'value' field\n if (type === 'text') {\n const value = contentItem.value;\n if (typeof value !== 'string') {\n errors.push({\n severity: 'error',\n filePath,\n location: `${contentLocation}.value`,\n message: \"Content with type 'text' must have a 'value' field\",\n });\n } else {\n validateContentForRoleMarkers(value, `${contentLocation}.value`, filePath, errors);\n }\n }\n } else {\n errors.push({\n severity: 'error',\n filePath,\n location: contentLocation,\n message: 'Content array items must be strings or objects',\n });\n }\n }\n } else {\n errors.push({\n severity: 'error',\n filePath,\n location: `${msgLocation}.content`,\n message: \"Missing or invalid 'content' field (must be a string or array)\",\n });\n }\n }\n}\n\nfunction validateContentForRoleMarkers(\n content: string,\n location: string,\n filePath: string,\n errors: ValidationError[],\n): void {\n // Check for standard role markers that might confuse agentic providers\n const markers = ['@[System]:', '@[User]:', '@[Assistant]:', '@[Tool]:'];\n for (const marker of markers) {\n if (content.toLowerCase().includes(marker.toLowerCase())) {\n errors.push({\n severity: 'warning',\n filePath,\n location,\n message: `Content contains potential role marker '${marker}'. This may confuse agentic providers or cause prompt injection.`,\n });\n }\n }\n}\n\nfunction validateToolCalls(\n toolCalls: JsonArray,\n location: string,\n filePath: string,\n errors: ValidationError[],\n): void {\n for (let i = 0; i < toolCalls.length; i++) {\n const toolCall = toolCalls[i];\n const callLocation = `${location}[${i}]`;\n\n if (!isObject(toolCall)) {\n errors.push({\n severity: 'error',\n filePath,\n location: callLocation,\n message: 'Tool call must be an object',\n });\n continue;\n }\n\n // Required: tool field\n const tool = toolCall.tool;\n if (typeof tool !== 'string' || tool.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${callLocation}.tool`,\n message: \"Missing or invalid 'tool' field (must be a non-empty string)\",\n });\n }\n\n // Optional: input field (any JSON value is valid)\n // Optional: output field (any JSON value is valid)\n // No additional validation needed for input/output - they're flexible\n }\n}\n","import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport { CLI_PLACEHOLDERS } from '../providers/targets.js';\nimport { KNOWN_PROVIDERS, PROVIDER_ALIASES, TARGETS_SCHEMA_V2 } from '../providers/types.js';\nimport type { ValidationError, ValidationResult } from './types.js';\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\ntype JsonObject = { readonly [key: string]: JsonValue };\ntype JsonArray = readonly JsonValue[];\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n// Known settings properties for each provider type\nconst COMMON_SETTINGS = new Set(['provider_batching', 'providerBatching']);\n\nconst RETRY_SETTINGS = new Set([\n 'max_retries',\n 'maxRetries',\n 'retry_initial_delay_ms',\n 'retryInitialDelayMs',\n 'retry_max_delay_ms',\n 'retryMaxDelayMs',\n 'retry_backoff_factor',\n 'retryBackoffFactor',\n 'retry_status_codes',\n 'retryStatusCodes',\n]);\n\nconst AZURE_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n ...RETRY_SETTINGS,\n 'endpoint',\n 'resource',\n 'resourceName',\n 'api_key',\n 'apiKey',\n 'deployment',\n 'deploymentName',\n 'model',\n 'version',\n 'api_version',\n 'temperature',\n 'max_output_tokens',\n 'maxTokens',\n]);\n\nconst ANTHROPIC_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n ...RETRY_SETTINGS,\n 'api_key',\n 'apiKey',\n 'model',\n 'deployment',\n 'variant',\n 'temperature',\n 'max_output_tokens',\n 'maxTokens',\n 'thinking_budget',\n 'thinkingBudget',\n]);\n\nconst GEMINI_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n ...RETRY_SETTINGS,\n 'api_key',\n 'apiKey',\n 'model',\n 'deployment',\n 'variant',\n 'temperature',\n 'max_output_tokens',\n 'maxTokens',\n]);\n\nconst CODEX_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n 'executable',\n 'command',\n 'binary',\n 'args',\n 'arguments',\n 'cwd',\n 'timeout_seconds',\n 'timeoutSeconds',\n 'log_dir',\n 'logDir',\n 'log_directory',\n 'logDirectory',\n 'log_format',\n 'logFormat',\n 'log_output_format',\n 'logOutputFormat',\n]);\n\nconst VSCODE_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n 'workspace_template',\n 'workspaceTemplate',\n 'vscode_cmd',\n 'command',\n 'wait',\n 'dry_run',\n 'dryRun',\n 'subagent_root',\n 'subagentRoot',\n]);\n\nconst MOCK_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n 'response',\n 'delayMs',\n 'delayMinMs',\n 'delayMaxMs',\n 'trace', // For testing tool_trajectory evaluator\n]);\n\nconst CLI_SETTINGS = new Set([\n ...COMMON_SETTINGS,\n 'command_template',\n 'commandTemplate',\n 'files_format',\n 'filesFormat',\n 'attachments_format',\n 'attachmentsFormat',\n 'cwd',\n 'env',\n 'timeout_seconds',\n 'timeoutSeconds',\n 'healthcheck',\n]);\n\nfunction getKnownSettings(provider: string): Set<string> | null {\n const normalizedProvider = provider.toLowerCase();\n switch (normalizedProvider) {\n case 'azure':\n case 'azure-openai':\n return AZURE_SETTINGS;\n case 'anthropic':\n return ANTHROPIC_SETTINGS;\n case 'gemini':\n case 'google':\n case 'google-gemini':\n return GEMINI_SETTINGS;\n case 'codex':\n case 'codex-cli':\n return CODEX_SETTINGS;\n case 'vscode':\n case 'vscode-insiders':\n return VSCODE_SETTINGS;\n case 'mock':\n return MOCK_SETTINGS;\n case 'cli':\n return CLI_SETTINGS;\n default:\n return null; // Unknown provider, can't validate settings\n }\n}\n\nfunction validateUnknownSettings(\n target: JsonObject,\n provider: string,\n absolutePath: string,\n location: string,\n errors: ValidationError[],\n): void {\n const knownSettings = getKnownSettings(provider);\n if (!knownSettings) {\n // Unknown provider, skip settings validation\n return;\n }\n\n // Known base target fields that aren't settings\n const baseFields = new Set(['name', 'provider', 'judge_target', 'workers', '$schema', 'targets']);\n\n for (const key of Object.keys(target)) {\n if (!baseFields.has(key) && !knownSettings.has(key)) {\n errors.push({\n severity: 'warning',\n filePath: absolutePath,\n location: `${location}.${key}`,\n message: `Unknown setting '${key}' for ${provider} provider. This property will be ignored.`,\n });\n }\n }\n}\n\n/**\n * Validate a targets file (agentv-targets-v2.1 schema).\n */\nexport async function validateTargetsFile(filePath: string): Promise<ValidationResult> {\n const errors: ValidationError[] = [];\n const absolutePath = path.resolve(filePath);\n\n let parsed: unknown;\n try {\n const content = await readFile(absolutePath, 'utf8');\n parsed = parse(content);\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: `Failed to parse YAML: ${(error as Error).message}`,\n });\n return {\n valid: false,\n filePath: absolutePath,\n fileType: 'targets',\n errors,\n };\n }\n\n function validateCliSettings(\n target: JsonObject,\n absolutePath: string,\n location: string,\n errors: ValidationError[],\n ): void {\n const commandTemplate = target.command_template ?? target.commandTemplate;\n if (typeof commandTemplate !== 'string' || commandTemplate.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.commandTemplate`,\n message: \"CLI provider requires 'commandTemplate' as a non-empty string\",\n });\n } else {\n recordUnknownPlaceholders(\n commandTemplate,\n absolutePath,\n `${location}.commandTemplate`,\n errors,\n );\n }\n\n const attachmentsFormat = target.attachments_format ?? target.attachmentsFormat;\n if (attachmentsFormat !== undefined && typeof attachmentsFormat !== 'string') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.attachmentsFormat`,\n message: \"'attachmentsFormat' must be a string when provided\",\n });\n }\n\n const filesFormat = target.files_format ?? target.filesFormat;\n if (filesFormat !== undefined && typeof filesFormat !== 'string') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.filesFormat`,\n message: \"'filesFormat' must be a string when provided\",\n });\n }\n\n const cwd = target.cwd;\n if (cwd !== undefined && typeof cwd !== 'string') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.cwd`,\n message: \"'cwd' must be a string when provided\",\n });\n }\n\n const timeoutSeconds = target.timeout_seconds ?? target.timeoutSeconds;\n if (timeoutSeconds !== undefined) {\n const numericTimeout = Number(timeoutSeconds);\n if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.timeoutSeconds`,\n message: \"'timeoutSeconds' must be a positive number when provided\",\n });\n }\n }\n\n const healthcheck = target.healthcheck;\n if (healthcheck !== undefined) {\n validateCliHealthcheck(healthcheck, absolutePath, `${location}.healthcheck`, errors);\n }\n }\n\n function validateCliHealthcheck(\n healthcheck: unknown,\n absolutePath: string,\n location: string,\n errors: ValidationError[],\n ): void {\n if (!isObject(healthcheck)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location,\n message: \"'healthcheck' must be an object when provided\",\n });\n return;\n }\n\n const type = healthcheck.type;\n if (type !== 'http' && type !== 'command') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.type`,\n message: \"healthcheck.type must be either 'http' or 'command'\",\n });\n return;\n }\n\n const timeoutSeconds = healthcheck.timeout_seconds ?? healthcheck.timeoutSeconds;\n if (timeoutSeconds !== undefined) {\n const numericTimeout = Number(timeoutSeconds);\n if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.timeoutSeconds`,\n message: 'healthcheck.timeoutSeconds must be a positive number when provided',\n });\n }\n }\n\n if (type === 'http') {\n const url = healthcheck.url;\n if (typeof url !== 'string' || url.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.url`,\n message: 'healthcheck.url must be a non-empty string for http checks',\n });\n }\n return;\n }\n\n const commandTemplate = healthcheck.command_template ?? healthcheck.commandTemplate;\n if (typeof commandTemplate !== 'string' || commandTemplate.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.commandTemplate`,\n message: 'healthcheck.commandTemplate must be a non-empty string for command checks',\n });\n } else {\n recordUnknownPlaceholders(\n commandTemplate,\n absolutePath,\n `${location}.commandTemplate`,\n errors,\n );\n }\n\n const cwd = healthcheck.cwd;\n if (cwd !== undefined && typeof cwd !== 'string') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.cwd`,\n message: 'healthcheck.cwd must be a string when provided',\n });\n }\n }\n\n function recordUnknownPlaceholders(\n template: string,\n absolutePath: string,\n location: string,\n errors: ValidationError[],\n ): void {\n const placeholders = extractPlaceholders(template);\n for (const placeholder of placeholders) {\n if (!CLI_PLACEHOLDERS.has(placeholder)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location,\n message: `Unknown CLI placeholder '{${placeholder}}'. Supported placeholders: ${Array.from(CLI_PLACEHOLDERS).join(', ')}`,\n });\n }\n }\n }\n\n function extractPlaceholders(template: string): string[] {\n const matches = template.matchAll(/\\{([A-Z_]+)\\}/g);\n const result: string[] = [];\n for (const match of matches) {\n const placeholder = match[1];\n if (placeholder) {\n result.push(placeholder);\n }\n }\n return result;\n }\n\n if (!isObject(parsed)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: 'File must contain a YAML object',\n });\n return {\n valid: false,\n filePath: absolutePath,\n fileType: 'targets',\n errors,\n };\n }\n\n // Validate targets array\n const targets = parsed.targets;\n if (!Array.isArray(targets)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: 'targets',\n message: \"Missing or invalid 'targets' field (must be an array)\",\n });\n return {\n valid: errors.length === 0,\n filePath: absolutePath,\n fileType: 'targets',\n errors,\n };\n }\n\n // Validate each target definition\n const knownProviders = [...KNOWN_PROVIDERS, ...PROVIDER_ALIASES];\n\n for (let i = 0; i < targets.length; i++) {\n const target = targets[i];\n const location = `targets[${i}]`;\n\n if (!isObject(target)) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location,\n message: 'Target must be an object',\n });\n continue;\n }\n\n // Required field: name\n const name = target.name;\n if (typeof name !== 'string' || name.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.name`,\n message: \"Missing or invalid 'name' field (must be a non-empty string)\",\n });\n }\n\n // Required field: provider\n const provider = target.provider;\n const providerValue = typeof provider === 'string' ? provider.trim().toLowerCase() : undefined;\n if (typeof provider !== 'string' || provider.trim().length === 0) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.provider`,\n message: \"Missing or invalid 'provider' field (must be a non-empty string)\",\n });\n } else if (!knownProviders.includes(provider)) {\n // Warning for unknown providers (non-fatal)\n errors.push({\n severity: 'warning',\n filePath: absolutePath,\n location: `${location}.provider`,\n message: `Unknown provider '${provider}'. Known providers: ${knownProviders.join(', ')}`,\n });\n }\n\n // Validate CLI provider fields\n if (providerValue === 'cli') {\n validateCliSettings(target, absolutePath, location, errors);\n }\n\n // Check for unknown settings properties on target object\n if (typeof provider === 'string') {\n validateUnknownSettings(target, provider, absolutePath, location, errors);\n }\n\n // Optional field: judge_target (must be string if present)\n const judgeTarget = target.judge_target;\n if (judgeTarget !== undefined && typeof judgeTarget !== 'string') {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n location: `${location}.judge_target`,\n message: \"Invalid 'judge_target' field (must be a string)\",\n });\n }\n }\n\n return {\n valid: errors.filter((e) => e.severity === 'error').length === 0,\n filePath: absolutePath,\n fileType: 'targets',\n errors,\n };\n}\n","import { readFile } from 'node:fs/promises';\nimport { parse } from 'yaml';\n\nimport type { ValidationError, ValidationResult } from './types.js';\n\nconst SCHEMA_CONFIG_V2 = 'agentv-config-v2';\n\n/**\n * Validate a config.yaml file for schema compliance and structural correctness.\n */\nexport async function validateConfigFile(filePath: string): Promise<ValidationResult> {\n const errors: ValidationError[] = [];\n\n try {\n const content = await readFile(filePath, 'utf8');\n const parsed = parse(content) as unknown;\n\n // Check if parsed content is an object\n if (typeof parsed !== 'object' || parsed === null) {\n errors.push({\n severity: 'error',\n filePath,\n message: 'Config file must contain a valid YAML object',\n });\n return { valid: false, filePath, fileType: 'config', errors };\n }\n\n const config = parsed as Record<string, unknown>;\n\n // Validate $schema field (optional, but if present must be correct)\n const schema = config.$schema;\n if (schema !== undefined && schema !== SCHEMA_CONFIG_V2) {\n const message = `Invalid $schema value '${schema}'. Expected '${SCHEMA_CONFIG_V2}' or omit the field.`;\n errors.push({\n severity: 'error',\n filePath,\n location: '$schema',\n message,\n });\n }\n\n // Validate guideline_patterns if present\n const guidelinePatterns = config.guideline_patterns;\n if (guidelinePatterns !== undefined) {\n if (!Array.isArray(guidelinePatterns)) {\n errors.push({\n severity: 'error',\n filePath,\n location: 'guideline_patterns',\n message: \"Field 'guideline_patterns' must be an array\",\n });\n } else if (!guidelinePatterns.every((p) => typeof p === 'string')) {\n errors.push({\n severity: 'error',\n filePath,\n location: 'guideline_patterns',\n message: \"All entries in 'guideline_patterns' must be strings\",\n });\n } else if (guidelinePatterns.length === 0) {\n errors.push({\n severity: 'warning',\n filePath,\n location: 'guideline_patterns',\n message: \"Field 'guideline_patterns' is empty. Consider removing it or adding patterns.\",\n });\n }\n }\n\n // Check for unexpected fields\n const allowedFields = new Set(['$schema', 'guideline_patterns']);\n const unexpectedFields = Object.keys(config).filter((key) => !allowedFields.has(key));\n\n if (unexpectedFields.length > 0) {\n errors.push({\n severity: 'warning',\n filePath,\n message: `Unexpected fields: ${unexpectedFields.join(', ')}`,\n });\n }\n\n return {\n valid: errors.filter((e) => e.severity === 'error').length === 0,\n filePath,\n fileType: 'config',\n errors,\n };\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath,\n message: `Failed to parse config file: ${(error as Error).message}`,\n });\n return { valid: false, filePath, fileType: 'config', errors };\n }\n}\n","import { readFile } from 'node:fs/promises';\nimport path from 'node:path';\nimport { parse } from 'yaml';\n\nimport { buildSearchRoots, findGitRoot, resolveFileReference } from '../file-utils.js';\nimport type { ValidationError } from './types.js';\n\ntype JsonValue = string | number | boolean | null | JsonObject | JsonArray;\ntype JsonObject = { readonly [key: string]: JsonValue };\ntype JsonArray = readonly JsonValue[];\n\nfunction isObject(value: unknown): value is JsonObject {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\n/**\n * Validate that file references in eval file content exist.\n * Checks content blocks with type: \"file\" and validates the referenced file exists.\n * Also checks that referenced files are not empty.\n */\nexport async function validateFileReferences(\n evalFilePath: string,\n): Promise<readonly ValidationError[]> {\n const errors: ValidationError[] = [];\n const absolutePath = path.resolve(evalFilePath);\n\n // Find git root and build search roots (same as yaml-parser does at runtime)\n const gitRoot = await findGitRoot(absolutePath);\n if (!gitRoot) {\n errors.push({\n severity: 'error',\n filePath: absolutePath,\n message: 'Cannot validate file references: git repository root not found',\n });\n return errors;\n }\n\n const searchRoots = buildSearchRoots(absolutePath, gitRoot);\n\n let parsed: unknown;\n try {\n const content = await readFile(absolutePath, 'utf8');\n parsed = parse(content);\n } catch {\n // Parse errors are already caught by eval-validator\n return errors;\n }\n\n if (!isObject(parsed)) {\n return errors;\n }\n\n const evalcases = parsed.evalcases;\n if (!Array.isArray(evalcases)) {\n return errors;\n }\n\n for (let i = 0; i < evalcases.length; i++) {\n const evalCase = evalcases[i];\n if (!isObject(evalCase)) {\n continue;\n }\n\n // Check input_messages\n const inputMessages = evalCase.input_messages;\n if (Array.isArray(inputMessages)) {\n await validateMessagesFileRefs(\n inputMessages,\n `evalcases[${i}].input_messages`,\n searchRoots,\n absolutePath,\n errors,\n );\n }\n\n // Check expected_messages\n const expectedMessages = evalCase.expected_messages;\n if (Array.isArray(expectedMessages)) {\n await validateMessagesFileRefs(\n expectedMessages,\n `evalcases[${i}].expected_messages`,\n searchRoots,\n absolutePath,\n errors,\n );\n }\n }\n\n return errors;\n}\n\nasync function validateMessagesFileRefs(\n messages: JsonArray,\n location: string,\n searchRoots: readonly string[],\n filePath: string,\n errors: ValidationError[],\n): Promise<void> {\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i];\n if (!isObject(message)) {\n continue;\n }\n\n const content = message.content;\n if (typeof content === 'string') {\n continue;\n }\n\n if (!Array.isArray(content)) {\n continue;\n }\n\n for (let j = 0; j < content.length; j++) {\n const contentItem = content[j];\n if (!isObject(contentItem)) {\n continue;\n }\n\n const type = contentItem.type;\n if (type !== 'file') {\n continue;\n }\n\n const value = contentItem.value;\n if (typeof value !== 'string') {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}].value`,\n message: \"File reference must have a 'value' field with the file path\",\n });\n continue;\n }\n\n // Use the same file resolution logic as yaml-parser at runtime\n const { resolvedPath } = await resolveFileReference(value, searchRoots);\n\n if (!resolvedPath) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Referenced file not found: ${value}`,\n });\n } else {\n // Check that file is not empty\n try {\n const fileContent = await readFile(resolvedPath, 'utf8');\n if (fileContent.trim().length === 0) {\n errors.push({\n severity: 'warning',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Referenced file is empty: ${value}`,\n });\n }\n } catch (error) {\n errors.push({\n severity: 'error',\n filePath,\n location: `${location}[${i}].content[${j}]`,\n message: `Cannot read referenced file: ${value} (${(error as Error).message})`,\n });\n }\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAS,aAAa;AAItB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AASzB,eAAsB,eAAe,UAAqC;AACxE,MAAI;AACF,UAAM,UAAU,MAAM,SAAS,UAAU,MAAM;AAC/C,UAAM,SAAS,MAAM,OA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AAI,QAAQ,QAAQ,KAAK;AACvC,YAAM,cAAc,QAAQ,CAAC;AAC7B,UAAI,CAACA,UAAS,WAAW,GAAG;AAC1B;AAAA,MACF;AAEA,YAAM,OAAO,YAAY;AACzB,UAAI,SAAS,QAAQ;AACnB;AAAA,MACF;AAEA,YAAM,QAAQ,YAAY;AAC1B,UAAI,OAAO,UAAU,UAAU;AAC7B,eAAO,KAAK;AAAA,UACV,UAAU;AAAA,UACV;AAAA,UACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,UACxC,SAAS;AAAA,QACX,CAAC;AACD;AAAA,MACF;AAGA,YAAM,EAAE,aAAa,IAAI,MAAM,qBAAqB,OAAO,WAAW;AAEtE,UAAI,CAAC,cAAc;AACjB,eAAO,KAAK;AAAA,UACV,UAAU;AAAA,UACV;AAAA,UACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,UACxC,SAAS,8BAA8B,KAAK;AAAA,QAC9C,CAAC;AAAA,MACH,OAAO;AAEL,YAAI;AACF,gBAAM,cAAc,MAAME,UAAS,cAAc,MAAM;AACvD,cAAI,YAAY,KAAK,EAAE,WAAW,GAAG;AACnC,mBAAO,KAAK;AAAA,cACV,UAAU;AAAA,cACV;AAAA,cACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,cACxC,SAAS,6BAA6B,KAAK;AAAA,YAC7C,CAAC;AAAA,UACH;AAAA,QACF,SAAS,OAAO;AACd,iBAAO,KAAK;AAAA,YACV,UAAU;AAAA,YACV;AAAA,YACA,UAAU,GAAG,QAAQ,IAAI,CAAC,aAAa,CAAC;AAAA,YACxC,SAAS,gCAAgC,KAAK,KAAM,MAAgB,OAAO;AAAA,UAC7E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["readFile","path","parse","readFile","path","parse","isObject","path","readFile","parse","absolutePath","errors","readFile","parse","SCHEMA_CONFIG_V2","readFile","path","parse","isObject","path","readFile","parse"]}
|
package/dist/index.cjs
CHANGED
|
@@ -32,7 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
CodeEvaluator: () => CodeEvaluator,
|
|
34
34
|
CompositeEvaluator: () => CompositeEvaluator,
|
|
35
|
-
|
|
35
|
+
ExpectedToolCallsEvaluator: () => ExpectedToolCallsEvaluator,
|
|
36
36
|
LlmJudgeEvaluator: () => LlmJudgeEvaluator,
|
|
37
37
|
TEST_MESSAGE_ROLES: () => TEST_MESSAGE_ROLES,
|
|
38
38
|
ToolTrajectoryEvaluator: () => ToolTrajectoryEvaluator,
|
|
@@ -121,7 +121,7 @@ var EVALUATOR_KIND_VALUES = [
|
|
|
121
121
|
"rubric",
|
|
122
122
|
"composite",
|
|
123
123
|
"tool_trajectory",
|
|
124
|
-
"
|
|
124
|
+
"expected_tool_calls"
|
|
125
125
|
];
|
|
126
126
|
var EVALUATOR_KIND_SET = new Set(EVALUATOR_KIND_VALUES);
|
|
127
127
|
function isEvaluatorKind(value) {
|
|
@@ -518,6 +518,7 @@ async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId
|
|
|
518
518
|
logWarning2(`Skipping code_judge evaluator '${name}' in '${evalId}': missing script`);
|
|
519
519
|
continue;
|
|
520
520
|
}
|
|
521
|
+
const weight2 = validateWeight(rawEvaluator.weight, name, evalId);
|
|
521
522
|
const cwd = asString2(rawEvaluator.cwd);
|
|
522
523
|
let resolvedCwd;
|
|
523
524
|
if (cwd) {
|
|
@@ -538,7 +539,8 @@ async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId
|
|
|
538
539
|
type: "code",
|
|
539
540
|
script,
|
|
540
541
|
cwd,
|
|
541
|
-
resolvedCwd
|
|
542
|
+
resolvedCwd,
|
|
543
|
+
...weight2 !== void 0 ? { weight: weight2 } : {}
|
|
542
544
|
});
|
|
543
545
|
continue;
|
|
544
546
|
}
|
|
@@ -633,18 +635,22 @@ async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId
|
|
|
633
635
|
...promptPath2 ? { promptPath: promptPath2 } : {}
|
|
634
636
|
};
|
|
635
637
|
}
|
|
638
|
+
const weight2 = validateWeight(rawEvaluator.weight, name, evalId);
|
|
636
639
|
evaluators.push({
|
|
637
640
|
name,
|
|
638
641
|
type: "composite",
|
|
639
642
|
evaluators: memberEvaluators,
|
|
640
|
-
aggregator
|
|
643
|
+
aggregator,
|
|
644
|
+
...weight2 !== void 0 ? { weight: weight2 } : {}
|
|
641
645
|
});
|
|
642
646
|
continue;
|
|
643
647
|
}
|
|
644
|
-
if (typeValue === "
|
|
648
|
+
if (typeValue === "expected_tool_calls") {
|
|
649
|
+
const weight2 = validateWeight(rawEvaluator.weight, name, evalId);
|
|
645
650
|
evaluators.push({
|
|
646
651
|
name,
|
|
647
|
-
type: "
|
|
652
|
+
type: "expected_tool_calls",
|
|
653
|
+
...weight2 !== void 0 ? { weight: weight2 } : {}
|
|
648
654
|
});
|
|
649
655
|
continue;
|
|
650
656
|
}
|
|
@@ -700,12 +706,14 @@ async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId
|
|
|
700
706
|
);
|
|
701
707
|
continue;
|
|
702
708
|
}
|
|
709
|
+
const weight2 = validateWeight(rawEvaluator.weight, name, evalId);
|
|
703
710
|
const config = {
|
|
704
711
|
name,
|
|
705
712
|
type: "tool_trajectory",
|
|
706
713
|
mode,
|
|
707
714
|
...minimums ? { minimums } : {},
|
|
708
|
-
...expected ? { expected } : {}
|
|
715
|
+
...expected ? { expected } : {},
|
|
716
|
+
...weight2 !== void 0 ? { weight: weight2 } : {}
|
|
709
717
|
};
|
|
710
718
|
evaluators.push(config);
|
|
711
719
|
continue;
|
|
@@ -746,19 +754,23 @@ async function parseEvaluators(rawEvalCase, globalExecution, searchRoots, evalId
|
|
|
746
754
|
logWarning2(`Skipping rubric evaluator '${name}' in '${evalId}': no valid rubrics found`);
|
|
747
755
|
continue;
|
|
748
756
|
}
|
|
757
|
+
const weight2 = validateWeight(rawEvaluator.weight, name, evalId);
|
|
749
758
|
evaluators.push({
|
|
750
759
|
name,
|
|
751
760
|
type: "llm_judge",
|
|
752
|
-
rubrics: parsedRubrics
|
|
761
|
+
rubrics: parsedRubrics,
|
|
762
|
+
...weight2 !== void 0 ? { weight: weight2 } : {}
|
|
753
763
|
});
|
|
754
764
|
continue;
|
|
755
765
|
}
|
|
766
|
+
const weight = validateWeight(rawEvaluator.weight, name, evalId);
|
|
756
767
|
evaluators.push({
|
|
757
768
|
name,
|
|
758
769
|
type: "llm_judge",
|
|
759
770
|
prompt,
|
|
760
771
|
promptPath,
|
|
761
|
-
...parsedRubrics && parsedRubrics.length > 0 ? { rubrics: parsedRubrics } : {}
|
|
772
|
+
...parsedRubrics && parsedRubrics.length > 0 ? { rubrics: parsedRubrics } : {},
|
|
773
|
+
...weight !== void 0 ? { weight } : {}
|
|
762
774
|
});
|
|
763
775
|
}
|
|
764
776
|
return evaluators.length > 0 ? evaluators : void 0;
|
|
@@ -788,6 +800,27 @@ ${detailBlock}${ANSI_RESET3}`);
|
|
|
788
800
|
console.warn(`${ANSI_YELLOW3}Warning: ${message}${ANSI_RESET3}`);
|
|
789
801
|
}
|
|
790
802
|
}
|
|
803
|
+
function validateWeight(rawWeight, evaluatorName, evalId) {
|
|
804
|
+
if (rawWeight === void 0) {
|
|
805
|
+
return void 0;
|
|
806
|
+
}
|
|
807
|
+
if (typeof rawWeight !== "number") {
|
|
808
|
+
throw new Error(
|
|
809
|
+
`Invalid weight for evaluator '${evaluatorName}' in '${evalId}': must be a number`
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
if (!Number.isFinite(rawWeight)) {
|
|
813
|
+
throw new Error(
|
|
814
|
+
`Invalid weight for evaluator '${evaluatorName}' in '${evalId}': must be finite (got ${rawWeight})`
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
if (rawWeight < 0) {
|
|
818
|
+
throw new Error(
|
|
819
|
+
`Invalid weight for evaluator '${evaluatorName}' in '${evalId}': must be non-negative (got ${rawWeight})`
|
|
820
|
+
);
|
|
821
|
+
}
|
|
822
|
+
return rawWeight;
|
|
823
|
+
}
|
|
791
824
|
|
|
792
825
|
// src/evaluation/loaders/message-processor.ts
|
|
793
826
|
var import_promises4 = require("fs/promises");
|
|
@@ -3180,7 +3213,10 @@ function resolveAzureConfig(target, env) {
|
|
|
3180
3213
|
const apiKey = resolveString(apiKeySource, env, `${target.name} api key`);
|
|
3181
3214
|
const deploymentName = resolveString(deploymentSource, env, `${target.name} deployment`);
|
|
3182
3215
|
const version = normalizeAzureApiVersion(
|
|
3183
|
-
resolveOptionalString(versionSource, env, `${target.name} api version
|
|
3216
|
+
resolveOptionalString(versionSource, env, `${target.name} api version`, {
|
|
3217
|
+
allowLiteral: true,
|
|
3218
|
+
optionalEnv: true
|
|
3219
|
+
})
|
|
3184
3220
|
);
|
|
3185
3221
|
const temperature = resolveOptionalNumber(temperatureSource, `${target.name} temperature`);
|
|
3186
3222
|
const maxOutputTokens = resolveOptionalNumber(
|
|
@@ -4216,9 +4252,11 @@ var CodeEvaluator = class {
|
|
|
4216
4252
|
expected_outcome: context.evalCase.expected_outcome,
|
|
4217
4253
|
reference_answer: context.evalCase.reference_answer,
|
|
4218
4254
|
candidate_answer: context.candidate,
|
|
4219
|
-
|
|
4220
|
-
input_files: context.evalCase.file_paths
|
|
4221
|
-
|
|
4255
|
+
guideline_files: context.evalCase.guideline_paths,
|
|
4256
|
+
input_files: context.evalCase.file_paths.filter(
|
|
4257
|
+
(path15) => !context.evalCase.guideline_paths.includes(path15)
|
|
4258
|
+
),
|
|
4259
|
+
input_messages: context.evalCase.input_messages
|
|
4222
4260
|
},
|
|
4223
4261
|
null,
|
|
4224
4262
|
2
|
|
@@ -4484,8 +4522,8 @@ var ToolTrajectoryEvaluator = class {
|
|
|
4484
4522
|
};
|
|
4485
4523
|
}
|
|
4486
4524
|
};
|
|
4487
|
-
var
|
|
4488
|
-
kind = "
|
|
4525
|
+
var ExpectedToolCallsEvaluator = class {
|
|
4526
|
+
kind = "expected_tool_calls";
|
|
4489
4527
|
evaluate(context) {
|
|
4490
4528
|
const { candidateTrace, evalCase } = context;
|
|
4491
4529
|
const expectedSegments = evalCase.expected_segments;
|
|
@@ -5401,14 +5439,12 @@ async function evaluateCandidate(options) {
|
|
|
5401
5439
|
} else {
|
|
5402
5440
|
if (promptInputs.chatPrompt) {
|
|
5403
5441
|
lmProviderRequest = {
|
|
5404
|
-
chat_prompt: promptInputs.chatPrompt
|
|
5405
|
-
guideline_paths: evalCase.guideline_paths
|
|
5442
|
+
chat_prompt: promptInputs.chatPrompt
|
|
5406
5443
|
};
|
|
5407
5444
|
} else {
|
|
5408
5445
|
lmProviderRequest = {
|
|
5409
5446
|
question: promptInputs.question,
|
|
5410
|
-
guidelines: promptInputs.guidelines
|
|
5411
|
-
guideline_paths: evalCase.guideline_paths
|
|
5447
|
+
guidelines: promptInputs.guidelines
|
|
5412
5448
|
};
|
|
5413
5449
|
}
|
|
5414
5450
|
}
|
|
@@ -5515,11 +5551,13 @@ async function runEvaluatorList(options) {
|
|
|
5515
5551
|
now,
|
|
5516
5552
|
judgeProvider
|
|
5517
5553
|
});
|
|
5518
|
-
|
|
5554
|
+
const weight = evaluator.weight ?? 1;
|
|
5555
|
+
scored.push({ score: score2, name: evaluator.name, type: evaluator.type, weight });
|
|
5519
5556
|
evaluatorResults.push({
|
|
5520
5557
|
name: evaluator.name,
|
|
5521
5558
|
type: evaluator.type,
|
|
5522
5559
|
score: score2.score,
|
|
5560
|
+
weight,
|
|
5523
5561
|
verdict: score2.verdict,
|
|
5524
5562
|
hits: score2.hits,
|
|
5525
5563
|
misses: score2.misses,
|
|
@@ -5542,11 +5580,13 @@ async function runEvaluatorList(options) {
|
|
|
5542
5580
|
promptInputs,
|
|
5543
5581
|
now
|
|
5544
5582
|
});
|
|
5545
|
-
|
|
5583
|
+
const weight = evaluator.weight ?? 1;
|
|
5584
|
+
scored.push({ score: score2, name: evaluator.name, type: "code_judge", weight });
|
|
5546
5585
|
evaluatorResults.push({
|
|
5547
5586
|
name: evaluator.name,
|
|
5548
5587
|
type: "code_judge",
|
|
5549
5588
|
score: score2.score,
|
|
5589
|
+
weight,
|
|
5550
5590
|
verdict: score2.verdict,
|
|
5551
5591
|
hits: score2.hits,
|
|
5552
5592
|
misses: score2.misses,
|
|
@@ -5576,8 +5616,8 @@ async function runEvaluatorList(options) {
|
|
|
5576
5616
|
return new ToolTrajectoryEvaluator({
|
|
5577
5617
|
config: memberConfig
|
|
5578
5618
|
});
|
|
5579
|
-
case "
|
|
5580
|
-
return new
|
|
5619
|
+
case "expected_tool_calls":
|
|
5620
|
+
return new ExpectedToolCallsEvaluator();
|
|
5581
5621
|
default: {
|
|
5582
5622
|
const unknownConfig = memberConfig;
|
|
5583
5623
|
throw new Error(`Unsupported evaluator type in composite: ${unknownConfig.type}`);
|
|
@@ -5599,11 +5639,13 @@ async function runEvaluatorList(options) {
|
|
|
5599
5639
|
now,
|
|
5600
5640
|
judgeProvider
|
|
5601
5641
|
});
|
|
5602
|
-
|
|
5642
|
+
const weight = evaluator.weight ?? 1;
|
|
5643
|
+
scored.push({ score: score2, name: evaluator.name, type: evaluator.type, weight });
|
|
5603
5644
|
evaluatorResults.push({
|
|
5604
5645
|
name: evaluator.name,
|
|
5605
5646
|
type: evaluator.type,
|
|
5606
5647
|
score: score2.score,
|
|
5648
|
+
weight,
|
|
5607
5649
|
verdict: score2.verdict,
|
|
5608
5650
|
hits: score2.hits,
|
|
5609
5651
|
misses: score2.misses,
|
|
@@ -5627,20 +5669,22 @@ async function runEvaluatorList(options) {
|
|
|
5627
5669
|
candidateTrace,
|
|
5628
5670
|
candidateTraceSummary
|
|
5629
5671
|
});
|
|
5630
|
-
|
|
5672
|
+
const weight = evaluator.weight ?? 1;
|
|
5673
|
+
scored.push({ score: score2, name: evaluator.name, type: evaluator.type, weight });
|
|
5631
5674
|
evaluatorResults.push({
|
|
5632
5675
|
name: evaluator.name,
|
|
5633
5676
|
type: evaluator.type,
|
|
5634
5677
|
score: score2.score,
|
|
5678
|
+
weight,
|
|
5635
5679
|
verdict: score2.verdict,
|
|
5636
5680
|
hits: score2.hits,
|
|
5637
5681
|
misses: score2.misses,
|
|
5638
5682
|
reasoning: score2.reasoning
|
|
5639
5683
|
});
|
|
5640
5684
|
}
|
|
5641
|
-
if (evaluator.type === "
|
|
5642
|
-
const
|
|
5643
|
-
const score2 =
|
|
5685
|
+
if (evaluator.type === "expected_tool_calls") {
|
|
5686
|
+
const expectedToolCallsEvaluator = new ExpectedToolCallsEvaluator();
|
|
5687
|
+
const score2 = expectedToolCallsEvaluator.evaluate({
|
|
5644
5688
|
evalCase,
|
|
5645
5689
|
candidate,
|
|
5646
5690
|
target,
|
|
@@ -5651,11 +5695,13 @@ async function runEvaluatorList(options) {
|
|
|
5651
5695
|
candidateTrace,
|
|
5652
5696
|
candidateTraceSummary
|
|
5653
5697
|
});
|
|
5654
|
-
|
|
5698
|
+
const weight = evaluator.weight ?? 1;
|
|
5699
|
+
scored.push({ score: score2, name: evaluator.name, type: evaluator.type, weight });
|
|
5655
5700
|
evaluatorResults.push({
|
|
5656
5701
|
name: evaluator.name,
|
|
5657
5702
|
type: evaluator.type,
|
|
5658
5703
|
score: score2.score,
|
|
5704
|
+
weight,
|
|
5659
5705
|
verdict: score2.verdict,
|
|
5660
5706
|
hits: score2.hits,
|
|
5661
5707
|
misses: score2.misses,
|
|
@@ -5673,15 +5719,18 @@ async function runEvaluatorList(options) {
|
|
|
5673
5719
|
reasoning: message
|
|
5674
5720
|
};
|
|
5675
5721
|
const resultType = evaluator.type === "code" ? "code_judge" : evaluator.type;
|
|
5722
|
+
const weight = evaluator.weight ?? 1;
|
|
5676
5723
|
scored.push({
|
|
5677
5724
|
score: fallbackScore,
|
|
5678
5725
|
name: evaluator.name ?? "unknown",
|
|
5679
|
-
type: resultType ?? "llm_judge"
|
|
5726
|
+
type: resultType ?? "llm_judge",
|
|
5727
|
+
weight
|
|
5680
5728
|
});
|
|
5681
5729
|
evaluatorResults.push({
|
|
5682
5730
|
name: evaluator.name ?? "unknown",
|
|
5683
5731
|
type: resultType ?? "llm_judge",
|
|
5684
5732
|
score: 0,
|
|
5733
|
+
weight,
|
|
5685
5734
|
verdict: "fail",
|
|
5686
5735
|
hits: [],
|
|
5687
5736
|
misses: [`Evaluator '${evaluator.name ?? "unknown"}' failed: ${message}`],
|
|
@@ -5689,7 +5738,9 @@ async function runEvaluatorList(options) {
|
|
|
5689
5738
|
});
|
|
5690
5739
|
}
|
|
5691
5740
|
}
|
|
5692
|
-
const aggregateScore = scored.length > 0 ?
|
|
5741
|
+
const aggregateScore = scored.length > 0 ? computeWeightedMean(
|
|
5742
|
+
scored.map((entry) => ({ score: entry.score.score, weight: entry.weight }))
|
|
5743
|
+
) : 0;
|
|
5693
5744
|
const hits = scored.flatMap((entry) => entry.score.hits);
|
|
5694
5745
|
const misses = scored.flatMap((entry) => entry.score.misses);
|
|
5695
5746
|
const expectedAspectCount = scored.reduce(
|
|
@@ -5915,6 +5966,16 @@ function mapChildResults(children) {
|
|
|
5915
5966
|
evaluator_results: mapChildResults(child.evaluatorResults)
|
|
5916
5967
|
}));
|
|
5917
5968
|
}
|
|
5969
|
+
function computeWeightedMean(entries) {
|
|
5970
|
+
let totalWeight = 0;
|
|
5971
|
+
let weightedSum = 0;
|
|
5972
|
+
for (const entry of entries) {
|
|
5973
|
+
const weight = entry.weight ?? 1;
|
|
5974
|
+
totalWeight += weight;
|
|
5975
|
+
weightedSum += entry.score * weight;
|
|
5976
|
+
}
|
|
5977
|
+
return totalWeight > 0 ? weightedSum / totalWeight : 0;
|
|
5978
|
+
}
|
|
5918
5979
|
|
|
5919
5980
|
// src/evaluation/generators/rubric-generator.ts
|
|
5920
5981
|
var import_ai3 = require("ai");
|
|
@@ -6004,7 +6065,7 @@ function createAgentKernel() {
|
|
|
6004
6065
|
0 && (module.exports = {
|
|
6005
6066
|
CodeEvaluator,
|
|
6006
6067
|
CompositeEvaluator,
|
|
6007
|
-
|
|
6068
|
+
ExpectedToolCallsEvaluator,
|
|
6008
6069
|
LlmJudgeEvaluator,
|
|
6009
6070
|
TEST_MESSAGE_ROLES,
|
|
6010
6071
|
ToolTrajectoryEvaluator,
|