@agentv/core 0.2.8 → 0.5.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-XXNQA4EW.js → chunk-NL7K4CAK.js} +5 -1
- package/dist/chunk-NL7K4CAK.js.map +1 -0
- package/dist/evaluation/validation/index.cjs +186 -1
- package/dist/evaluation/validation/index.cjs.map +1 -1
- package/dist/evaluation/validation/index.js +183 -2
- package/dist/evaluation/validation/index.js.map +1 -1
- package/dist/index.cjs +1701 -324
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +121 -63
- package/dist/index.d.ts +121 -63
- package/dist/index.js +1710 -327
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-XXNQA4EW.js.map +0 -1
|
@@ -107,6 +107,8 @@ var KNOWN_PROVIDERS = [
|
|
|
107
107
|
"azure",
|
|
108
108
|
"anthropic",
|
|
109
109
|
"gemini",
|
|
110
|
+
"codex",
|
|
111
|
+
"cli",
|
|
110
112
|
"mock",
|
|
111
113
|
"vscode",
|
|
112
114
|
"vscode-insiders"
|
|
@@ -118,6 +120,8 @@ var PROVIDER_ALIASES = [
|
|
|
118
120
|
// alias for "gemini"
|
|
119
121
|
"google-gemini",
|
|
120
122
|
// alias for "gemini"
|
|
123
|
+
"codex-cli",
|
|
124
|
+
// alias for "codex"
|
|
121
125
|
"openai",
|
|
122
126
|
// legacy/future support
|
|
123
127
|
"bedrock",
|
|
@@ -137,4 +141,4 @@ export {
|
|
|
137
141
|
PROVIDER_ALIASES,
|
|
138
142
|
TARGETS_SCHEMA_V2
|
|
139
143
|
};
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
144
|
+
//# sourceMappingURL=chunk-NL7K4CAK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/evaluation/file-utils.ts","../src/evaluation/providers/types.ts"],"sourcesContent":["import { constants } from \"node:fs\";\r\nimport { access } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\n\r\nexport async function fileExists(filePath: string): Promise<boolean> {\r\n try {\r\n await access(filePath, constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Find git repository root by walking up the directory tree.\r\n */\r\nexport async function findGitRoot(startPath: string): Promise<string | null> {\r\n let currentDir = path.dirname(path.resolve(startPath));\r\n const root = path.parse(currentDir).root;\r\n\r\n while (currentDir !== root) {\r\n const gitPath = path.join(currentDir, \".git\");\r\n if (await fileExists(gitPath)) {\r\n return currentDir;\r\n }\r\n\r\n const parentDir = path.dirname(currentDir);\r\n if (parentDir === currentDir) {\r\n break;\r\n }\r\n currentDir = parentDir;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Build a chain of directories walking from a file's location up to repo root.\r\n * Used for discovering configuration files like targets.yaml or config.yaml.\r\n */\r\nexport function buildDirectoryChain(filePath: string, repoRoot: string): readonly string[] {\r\n const directories: string[] = [];\r\n const seen = new Set<string>();\r\n const boundary = path.resolve(repoRoot);\r\n let current: string | undefined = path.resolve(path.dirname(filePath));\r\n\r\n while (current !== undefined) {\r\n if (!seen.has(current)) {\r\n directories.push(current);\r\n seen.add(current);\r\n }\r\n if (current === boundary) {\r\n break;\r\n }\r\n const parent = path.dirname(current);\r\n if (parent === current) {\r\n break;\r\n }\r\n current = parent;\r\n }\r\n\r\n if (!seen.has(boundary)) {\r\n directories.push(boundary);\r\n }\r\n\r\n return directories;\r\n}\r\n\r\n/**\r\n * Build search roots for file resolution, matching yaml-parser behavior.\r\n * Searches from eval file directory up to repo root.\r\n */\r\nexport function buildSearchRoots(evalPath: string, repoRoot: string): readonly string[] {\r\n const uniqueRoots: string[] = [];\r\n const addRoot = (root: string): void => {\r\n const normalized = path.resolve(root);\r\n if (!uniqueRoots.includes(normalized)) {\r\n uniqueRoots.push(normalized);\r\n }\r\n };\r\n\r\n let currentDir = path.dirname(evalPath);\r\n let reachedBoundary = false;\r\n while (!reachedBoundary) {\r\n addRoot(currentDir);\r\n const parentDir = path.dirname(currentDir);\r\n if (currentDir === repoRoot || parentDir === currentDir) {\r\n reachedBoundary = true;\r\n } else {\r\n currentDir = parentDir;\r\n }\r\n }\r\n\r\n addRoot(repoRoot);\r\n addRoot(process.cwd());\r\n return uniqueRoots;\r\n}\r\n\r\n/**\r\n * Trim leading path separators for display.\r\n */\r\nfunction trimLeadingSeparators(value: string): string {\r\n const trimmed = value.replace(/^[/\\\\]+/, \"\");\r\n return trimmed.length > 0 ? trimmed : value;\r\n}\r\n\r\n/**\r\n * Resolve a file reference using search roots, matching yaml-parser behavior.\r\n */\r\nexport async function resolveFileReference(\r\n rawValue: string,\r\n searchRoots: readonly string[],\r\n): Promise<{\r\n readonly displayPath: string;\r\n readonly resolvedPath?: string;\r\n readonly attempted: readonly string[];\r\n}> {\r\n const displayPath = trimLeadingSeparators(rawValue);\r\n const potentialPaths: string[] = [];\r\n\r\n if (path.isAbsolute(rawValue)) {\r\n potentialPaths.push(path.normalize(rawValue));\r\n }\r\n\r\n for (const base of searchRoots) {\r\n potentialPaths.push(path.resolve(base, displayPath));\r\n }\r\n\r\n const attempted: string[] = [];\r\n const seen = new Set<string>();\r\n for (const candidate of potentialPaths) {\r\n const absoluteCandidate = path.resolve(candidate);\r\n if (seen.has(absoluteCandidate)) {\r\n continue;\r\n }\r\n seen.add(absoluteCandidate);\r\n attempted.push(absoluteCandidate);\r\n if (await fileExists(absoluteCandidate)) {\r\n return { displayPath, resolvedPath: absoluteCandidate, attempted };\r\n }\r\n }\r\n\r\n return { displayPath, attempted };\r\n}\r\n","import type { AxChatRequest } from \"@ax-llm/ax\";\r\n\r\nimport type { JsonObject } from \"../types.js\";\r\n\r\ntype ChatPrompt = AxChatRequest[\"chatPrompt\"];\r\n\r\nexport type ProviderKind =\r\n | \"azure\"\r\n | \"anthropic\"\r\n | \"gemini\"\r\n | \"codex\"\r\n | \"cli\"\r\n | \"mock\"\r\n | \"vscode\"\r\n | \"vscode-insiders\";\r\n\r\n/**\r\n * List of all supported provider kinds.\r\n * This is the source of truth for provider validation.\r\n */\r\nexport const KNOWN_PROVIDERS: readonly ProviderKind[] = [\r\n \"azure\",\r\n \"anthropic\",\r\n \"gemini\",\r\n \"codex\",\r\n \"cli\",\r\n \"mock\",\r\n \"vscode\",\r\n \"vscode-insiders\",\r\n] as const;\r\n\r\n/**\r\n * Provider aliases that are accepted in target definitions.\r\n * These map to the canonical ProviderKind values.\r\n */\r\nexport const PROVIDER_ALIASES: readonly string[] = [\r\n \"azure-openai\", // alias for \"azure\"\r\n \"google\", // alias for \"gemini\"\r\n \"google-gemini\", // alias for \"gemini\"\r\n \"codex-cli\", // alias for \"codex\"\r\n \"openai\", // legacy/future support\r\n \"bedrock\", // legacy/future support\r\n \"vertex\", // legacy/future support\r\n] as const;\r\n\r\n/**\r\n * Schema identifier for targets.yaml files (version 2).\r\n */\r\nexport const TARGETS_SCHEMA_V2 = \"agentv-targets-v2\";\r\n\r\nexport interface ProviderRequest {\r\n readonly prompt: string;\r\n readonly guidelines?: string;\r\n readonly guideline_patterns?: readonly string[];\r\n readonly chatPrompt?: ChatPrompt;\r\n readonly inputFiles?: readonly string[];\r\n readonly evalCaseId?: string;\r\n readonly attempt?: number;\r\n readonly maxOutputTokens?: number;\r\n readonly temperature?: number;\r\n readonly metadata?: JsonObject;\r\n readonly signal?: AbortSignal;\r\n}\r\n\r\nexport interface ProviderResponse {\r\n readonly text: string;\r\n readonly reasoning?: string;\r\n readonly raw?: unknown;\r\n readonly usage?: JsonObject;\r\n}\r\n\r\nexport interface Provider {\r\n readonly id: string;\r\n readonly kind: ProviderKind;\r\n readonly targetName: string;\r\n invoke(request: ProviderRequest): Promise<ProviderResponse>;\r\n /**\r\n * Optional capability marker for provider-managed batching (single session handling multiple requests).\r\n */\r\n readonly supportsBatch?: boolean;\r\n /**\r\n * Optional batch invocation hook. When defined alongside supportsBatch=true,\r\n * the orchestrator may send multiple requests in a single provider session.\r\n */\r\n invokeBatch?(requests: readonly ProviderRequest[]): Promise<readonly ProviderResponse[]>;\r\n}\r\n\r\nexport type EnvLookup = Readonly<Record<string, string | undefined>>;\r\n\r\nexport interface TargetDefinition {\r\n readonly name: string;\r\n readonly provider: ProviderKind | string;\r\n readonly settings?: Record<string, unknown> | undefined;\r\n readonly judge_target?: string | undefined;\r\n readonly workers?: number | undefined;\r\n}\r\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,cAAc;AACvB,OAAO,UAAU;AAEjB,eAAsB,WAAW,UAAoC;AACnE,MAAI;AACF,UAAM,OAAO,UAAU,UAAU,IAAI;AACrC,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAKA,eAAsB,YAAY,WAA2C;AAC3E,MAAI,aAAa,KAAK,QAAQ,KAAK,QAAQ,SAAS,CAAC;AACrD,QAAM,OAAO,KAAK,MAAM,UAAU,EAAE;AAEpC,SAAO,eAAe,MAAM;AAC1B,UAAM,UAAU,KAAK,KAAK,YAAY,MAAM;AAC5C,QAAI,MAAM,WAAW,OAAO,GAAG;AAC7B,aAAO;AAAA,IACT;AAEA,UAAM,YAAY,KAAK,QAAQ,UAAU;AACzC,QAAI,cAAc,YAAY;AAC5B;AAAA,IACF;AACA,iBAAa;AAAA,EACf;AAEA,SAAO;AACT;AAMO,SAAS,oBAAoB,UAAkB,UAAqC;AACzF,QAAM,cAAwB,CAAC;AAC/B,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,WAAW,KAAK,QAAQ,QAAQ;AACtC,MAAI,UAA8B,KAAK,QAAQ,KAAK,QAAQ,QAAQ,CAAC;AAErE,SAAO,YAAY,QAAW;AAC5B,QAAI,CAAC,KAAK,IAAI,OAAO,GAAG;AACtB,kBAAY,KAAK,OAAO;AACxB,WAAK,IAAI,OAAO;AAAA,IAClB;AACA,QAAI,YAAY,UAAU;AACxB;AAAA,IACF;AACA,UAAM,SAAS,KAAK,QAAQ,OAAO;AACnC,QAAI,WAAW,SAAS;AACtB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AAAA,IACF;AACA,SAAK,IAAI,iBAAiB;AAC1B,cAAU,KAAK,iBAAiB;AAChC,QAAI,MAAM,WAAW,iBAAiB,GAAG;AACvC,aAAO,EAAE,aAAa,cAAc,mBAAmB,UAAU;AAAA,IACnE;AAAA,EACF;AAEA,SAAO,EAAE,aAAa,UAAU;AAClC;;;AC3HO,IAAM,kBAA2C;AAAA,EACtD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAMO,IAAM,mBAAsC;AAAA,EACjD;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AAAA,EACA;AAAA;AACF;AAKO,IAAM,oBAAoB;","names":[]}
|
|
@@ -295,6 +295,8 @@ var KNOWN_PROVIDERS = [
|
|
|
295
295
|
"azure",
|
|
296
296
|
"anthropic",
|
|
297
297
|
"gemini",
|
|
298
|
+
"codex",
|
|
299
|
+
"cli",
|
|
298
300
|
"mock",
|
|
299
301
|
"vscode",
|
|
300
302
|
"vscode-insiders"
|
|
@@ -306,6 +308,8 @@ var PROVIDER_ALIASES = [
|
|
|
306
308
|
// alias for "gemini"
|
|
307
309
|
"google-gemini",
|
|
308
310
|
// alias for "gemini"
|
|
311
|
+
"codex-cli",
|
|
312
|
+
// alias for "codex"
|
|
309
313
|
"openai",
|
|
310
314
|
// legacy/future support
|
|
311
315
|
"bedrock",
|
|
@@ -319,6 +323,7 @@ var TARGETS_SCHEMA_V2 = "agentv-targets-v2";
|
|
|
319
323
|
function isObject2(value) {
|
|
320
324
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
321
325
|
}
|
|
326
|
+
var CLI_PLACEHOLDERS = /* @__PURE__ */ new Set(["PROMPT", "GUIDELINES", "EVAL_ID", "ATTEMPT", "FILES"]);
|
|
322
327
|
async function validateTargetsFile(filePath) {
|
|
323
328
|
const errors = [];
|
|
324
329
|
const absolutePath = import_node_path2.default.resolve(filePath);
|
|
@@ -339,6 +344,182 @@ async function validateTargetsFile(filePath) {
|
|
|
339
344
|
errors
|
|
340
345
|
};
|
|
341
346
|
}
|
|
347
|
+
function validateCliSettings(settings, absolutePath2, location, errors2) {
|
|
348
|
+
if (!isObject2(settings)) {
|
|
349
|
+
errors2.push({
|
|
350
|
+
severity: "error",
|
|
351
|
+
filePath: absolutePath2,
|
|
352
|
+
location,
|
|
353
|
+
message: "CLI provider requires a 'settings' object"
|
|
354
|
+
});
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
const commandTemplate = settings["command_template"] ?? settings["commandTemplate"];
|
|
358
|
+
if (typeof commandTemplate !== "string" || commandTemplate.trim().length === 0) {
|
|
359
|
+
errors2.push({
|
|
360
|
+
severity: "error",
|
|
361
|
+
filePath: absolutePath2,
|
|
362
|
+
location: `${location}.commandTemplate`,
|
|
363
|
+
message: "CLI provider requires 'commandTemplate' as a non-empty string"
|
|
364
|
+
});
|
|
365
|
+
} else {
|
|
366
|
+
recordUnknownPlaceholders(commandTemplate, absolutePath2, `${location}.commandTemplate`, errors2);
|
|
367
|
+
}
|
|
368
|
+
const attachmentsFormat = settings["attachments_format"] ?? settings["attachmentsFormat"];
|
|
369
|
+
if (attachmentsFormat !== void 0 && typeof attachmentsFormat !== "string") {
|
|
370
|
+
errors2.push({
|
|
371
|
+
severity: "error",
|
|
372
|
+
filePath: absolutePath2,
|
|
373
|
+
location: `${location}.attachmentsFormat`,
|
|
374
|
+
message: "'attachmentsFormat' must be a string when provided"
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
const filesFormat = settings["files_format"] ?? settings["filesFormat"];
|
|
378
|
+
if (filesFormat !== void 0 && typeof filesFormat !== "string") {
|
|
379
|
+
errors2.push({
|
|
380
|
+
severity: "error",
|
|
381
|
+
filePath: absolutePath2,
|
|
382
|
+
location: `${location}.filesFormat`,
|
|
383
|
+
message: "'filesFormat' must be a string when provided"
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
const cwd = settings["cwd"];
|
|
387
|
+
if (cwd !== void 0 && typeof cwd !== "string") {
|
|
388
|
+
errors2.push({
|
|
389
|
+
severity: "error",
|
|
390
|
+
filePath: absolutePath2,
|
|
391
|
+
location: `${location}.cwd`,
|
|
392
|
+
message: "'cwd' must be a string when provided"
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
const timeoutSeconds = settings["timeout_seconds"] ?? settings["timeoutSeconds"];
|
|
396
|
+
if (timeoutSeconds !== void 0) {
|
|
397
|
+
const numericTimeout = Number(timeoutSeconds);
|
|
398
|
+
if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {
|
|
399
|
+
errors2.push({
|
|
400
|
+
severity: "error",
|
|
401
|
+
filePath: absolutePath2,
|
|
402
|
+
location: `${location}.timeoutSeconds`,
|
|
403
|
+
message: "'timeoutSeconds' must be a positive number when provided"
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
const envOverrides = settings["env"];
|
|
408
|
+
if (envOverrides !== void 0) {
|
|
409
|
+
if (!isObject2(envOverrides)) {
|
|
410
|
+
errors2.push({
|
|
411
|
+
severity: "error",
|
|
412
|
+
filePath: absolutePath2,
|
|
413
|
+
location: `${location}.env`,
|
|
414
|
+
message: "'env' must be an object with string values"
|
|
415
|
+
});
|
|
416
|
+
} else {
|
|
417
|
+
for (const [key, value] of Object.entries(envOverrides)) {
|
|
418
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
419
|
+
errors2.push({
|
|
420
|
+
severity: "error",
|
|
421
|
+
filePath: absolutePath2,
|
|
422
|
+
location: `${location}.env.${key}`,
|
|
423
|
+
message: `Environment override '${key}' must be a non-empty string`
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
const healthcheck = settings["healthcheck"];
|
|
430
|
+
if (healthcheck !== void 0) {
|
|
431
|
+
validateCliHealthcheck(healthcheck, absolutePath2, `${location}.healthcheck`, errors2);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
function validateCliHealthcheck(healthcheck, absolutePath2, location, errors2) {
|
|
435
|
+
if (!isObject2(healthcheck)) {
|
|
436
|
+
errors2.push({
|
|
437
|
+
severity: "error",
|
|
438
|
+
filePath: absolutePath2,
|
|
439
|
+
location,
|
|
440
|
+
message: "'healthcheck' must be an object when provided"
|
|
441
|
+
});
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
const type = healthcheck["type"];
|
|
445
|
+
if (type !== "http" && type !== "command") {
|
|
446
|
+
errors2.push({
|
|
447
|
+
severity: "error",
|
|
448
|
+
filePath: absolutePath2,
|
|
449
|
+
location: `${location}.type`,
|
|
450
|
+
message: "healthcheck.type must be either 'http' or 'command'"
|
|
451
|
+
});
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
const timeoutSeconds = healthcheck["timeout_seconds"] ?? healthcheck["timeoutSeconds"];
|
|
455
|
+
if (timeoutSeconds !== void 0) {
|
|
456
|
+
const numericTimeout = Number(timeoutSeconds);
|
|
457
|
+
if (!Number.isFinite(numericTimeout) || numericTimeout <= 0) {
|
|
458
|
+
errors2.push({
|
|
459
|
+
severity: "error",
|
|
460
|
+
filePath: absolutePath2,
|
|
461
|
+
location: `${location}.timeoutSeconds`,
|
|
462
|
+
message: "healthcheck.timeoutSeconds must be a positive number when provided"
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (type === "http") {
|
|
467
|
+
const url = healthcheck["url"];
|
|
468
|
+
if (typeof url !== "string" || url.trim().length === 0) {
|
|
469
|
+
errors2.push({
|
|
470
|
+
severity: "error",
|
|
471
|
+
filePath: absolutePath2,
|
|
472
|
+
location: `${location}.url`,
|
|
473
|
+
message: "healthcheck.url must be a non-empty string for http checks"
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
const commandTemplate = healthcheck["command_template"] ?? healthcheck["commandTemplate"];
|
|
479
|
+
if (typeof commandTemplate !== "string" || commandTemplate.trim().length === 0) {
|
|
480
|
+
errors2.push({
|
|
481
|
+
severity: "error",
|
|
482
|
+
filePath: absolutePath2,
|
|
483
|
+
location: `${location}.commandTemplate`,
|
|
484
|
+
message: "healthcheck.commandTemplate must be a non-empty string for command checks"
|
|
485
|
+
});
|
|
486
|
+
} else {
|
|
487
|
+
recordUnknownPlaceholders(commandTemplate, absolutePath2, `${location}.commandTemplate`, errors2);
|
|
488
|
+
}
|
|
489
|
+
const cwd = healthcheck["cwd"];
|
|
490
|
+
if (cwd !== void 0 && typeof cwd !== "string") {
|
|
491
|
+
errors2.push({
|
|
492
|
+
severity: "error",
|
|
493
|
+
filePath: absolutePath2,
|
|
494
|
+
location: `${location}.cwd`,
|
|
495
|
+
message: "healthcheck.cwd must be a string when provided"
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
function recordUnknownPlaceholders(template, absolutePath2, location, errors2) {
|
|
500
|
+
const placeholders = extractPlaceholders(template);
|
|
501
|
+
for (const placeholder of placeholders) {
|
|
502
|
+
if (!CLI_PLACEHOLDERS.has(placeholder)) {
|
|
503
|
+
errors2.push({
|
|
504
|
+
severity: "error",
|
|
505
|
+
filePath: absolutePath2,
|
|
506
|
+
location,
|
|
507
|
+
message: `Unknown CLI placeholder '{${placeholder}}'. Supported placeholders: ${Array.from(CLI_PLACEHOLDERS).join(", ")}`
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
function extractPlaceholders(template) {
|
|
513
|
+
const matches = template.matchAll(/\{([A-Z_]+)\}/g);
|
|
514
|
+
const result = [];
|
|
515
|
+
for (const match of matches) {
|
|
516
|
+
const placeholder = match[1];
|
|
517
|
+
if (placeholder) {
|
|
518
|
+
result.push(placeholder);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
return result;
|
|
522
|
+
}
|
|
342
523
|
if (!isObject2(parsed)) {
|
|
343
524
|
errors.push({
|
|
344
525
|
severity: "error",
|
|
@@ -400,6 +581,7 @@ async function validateTargetsFile(filePath) {
|
|
|
400
581
|
});
|
|
401
582
|
}
|
|
402
583
|
const provider = target["provider"];
|
|
584
|
+
const providerValue = typeof provider === "string" ? provider.trim().toLowerCase() : void 0;
|
|
403
585
|
if (typeof provider !== "string" || provider.trim().length === 0) {
|
|
404
586
|
errors.push({
|
|
405
587
|
severity: "error",
|
|
@@ -416,7 +598,7 @@ async function validateTargetsFile(filePath) {
|
|
|
416
598
|
});
|
|
417
599
|
}
|
|
418
600
|
const settings = target["settings"];
|
|
419
|
-
if (settings !== void 0 && !isObject2(settings)) {
|
|
601
|
+
if (providerValue !== "cli" && settings !== void 0 && !isObject2(settings)) {
|
|
420
602
|
errors.push({
|
|
421
603
|
severity: "error",
|
|
422
604
|
filePath: absolutePath,
|
|
@@ -424,6 +606,9 @@ async function validateTargetsFile(filePath) {
|
|
|
424
606
|
message: "Invalid 'settings' field (must be an object)"
|
|
425
607
|
});
|
|
426
608
|
}
|
|
609
|
+
if (providerValue === "cli") {
|
|
610
|
+
validateCliSettings(settings, absolutePath, `${location}.settings`, errors);
|
|
611
|
+
}
|
|
427
612
|
const judgeTarget = target["judge_target"];
|
|
428
613
|
if (judgeTarget !== void 0 && typeof judgeTarget !== "string") {
|
|
429
614
|
errors.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/evaluation/validation/index.ts","../../../src/evaluation/validation/file-type.ts","../../../src/evaluation/validation/eval-validator.ts","../../../src/evaluation/validation/targets-validator.ts","../../../src/evaluation/providers/types.ts","../../../src/evaluation/validation/config-validator.ts","../../../src/evaluation/validation/file-reference-validator.ts","../../../src/evaluation/file-utils.ts"],"sourcesContent":["/**\r\n * Validation module for AgentV eval and targets files.\r\n */\r\n\r\nexport { detectFileType, isValidSchema, getExpectedSchema } from \"./file-type.js\";\r\nexport { validateEvalFile } from \"./eval-validator.js\";\r\nexport { validateTargetsFile } from \"./targets-validator.js\";\r\nexport { validateConfigFile } from \"./config-validator.js\";\r\nexport { validateFileReferences } from \"./file-reference-validator.js\";\r\nexport type {\r\n FileType,\r\n ValidationSeverity,\r\n ValidationError,\r\n ValidationResult,\r\n ValidationSummary,\r\n} from \"./types.js\";\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { parse } from \"yaml\";\r\n\r\nimport type { FileType } from \"./types.js\";\r\n\r\nconst SCHEMA_EVAL_V2 = \"agentv-eval-v2\";\r\nconst SCHEMA_TARGETS_V2 = \"agentv-targets-v2\";\r\nconst SCHEMA_CONFIG_V2 = \"agentv-config-v2\";\r\n\r\n/**\r\n * Detect file type by reading $schema field from YAML file.\r\n * Returns \"unknown\" if file cannot be read or $schema is missing/invalid.\r\n */\r\nexport async function detectFileType(filePath: string): Promise<FileType> {\r\n try {\r\n const content = await readFile(filePath, \"utf8\");\r\n const parsed = parse(content) as unknown;\r\n\r\n if (typeof parsed !== \"object\" || parsed === null) {\r\n return \"unknown\";\r\n }\r\n\r\n const record = parsed as Record<string, unknown>;\r\n const schema = record[\"$schema\"];\r\n\r\n if (typeof schema !== \"string\") {\r\n return \"unknown\";\r\n }\r\n\r\n switch (schema) {\r\n case SCHEMA_EVAL_V2:\r\n return \"eval\";\r\n case SCHEMA_TARGETS_V2:\r\n return \"targets\";\r\n case SCHEMA_CONFIG_V2:\r\n return \"config\";\r\n default:\r\n return \"unknown\";\r\n }\r\n } catch {\r\n return \"unknown\";\r\n }\r\n}\r\n\r\n/**\r\n * Check if a schema value is a valid AgentV schema identifier.\r\n */\r\nexport function isValidSchema(schema: unknown): boolean {\r\n return schema === SCHEMA_EVAL_V2 || schema === SCHEMA_TARGETS_V2 || schema === SCHEMA_CONFIG_V2;\r\n}\r\n\r\n/**\r\n * Get the expected schema for a file type.\r\n */\r\nexport function getExpectedSchema(fileType: FileType): string | undefined {\r\n switch (fileType) {\r\n case \"eval\":\r\n return SCHEMA_EVAL_V2;\r\n case \"targets\":\r\n return SCHEMA_TARGETS_V2;\r\n case \"config\":\r\n return SCHEMA_CONFIG_V2;\r\n default:\r\n return undefined;\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 type { ValidationError, ValidationResult } from \"./types.js\";\r\n\r\nconst SCHEMA_EVAL_V2 = \"agentv-eval-v2\";\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(\r\n filePath: string,\r\n): 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 $schema field\r\n const schema = parsed[\"$schema\"];\r\n if (schema !== SCHEMA_EVAL_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${SCHEMA_EVAL_V2}'`\r\n : `Missing required field '$schema'. Expected '${SCHEMA_EVAL_V2}'`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: \"$schema\",\r\n message,\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, outcome, 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 const outcome = evalCase[\"outcome\"];\r\n if (typeof outcome !== \"string\" || outcome.trim().length === 0) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.outcome`,\r\n message: \"Missing or invalid 'outcome' field (must be a non-empty string)\",\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 const expectedMessages = evalCase[\"expected_messages\"];\r\n if (!Array.isArray(expectedMessages)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.expected_messages`,\r\n message: \"Missing or invalid 'expected_messages' field (must be an array)\",\r\n });\r\n } else {\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 content field (can be string or array)\r\n const content = message[\"content\"];\r\n if (typeof content === \"string\") {\r\n // String content is valid\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 // String in array is valid\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 }\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","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\nimport { KNOWN_PROVIDERS, PROVIDER_ALIASES, TARGETS_SCHEMA_V2 } from \"../providers/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 a targets file (agentv-targets-v2 schema).\r\n */\r\nexport async function validateTargetsFile(\r\n filePath: string,\r\n): 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 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 $schema field\r\n const schema = parsed[\"$schema\"];\r\n if (schema !== TARGETS_SCHEMA_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${TARGETS_SCHEMA_V2}'`\r\n : `Missing required field '$schema'. Expected '${TARGETS_SCHEMA_V2}'`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: \"$schema\",\r\n message,\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 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 // Optional field: settings (must be object if present)\r\n const settings = target[\"settings\"];\r\n if (settings !== undefined && !isObject(settings)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.settings`,\r\n message: \"Invalid 'settings' field (must be an object)\",\r\n });\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 type { AxChatRequest } from \"@ax-llm/ax\";\r\n\r\nimport type { JsonObject } from \"../types.js\";\r\n\r\ntype ChatPrompt = AxChatRequest[\"chatPrompt\"];\r\n\r\nexport type ProviderKind =\r\n | \"azure\"\r\n | \"anthropic\"\r\n | \"gemini\"\r\n | \"mock\"\r\n | \"vscode\"\r\n | \"vscode-insiders\";\r\n\r\n/**\r\n * List of all supported provider kinds.\r\n * This is the source of truth for provider validation.\r\n */\r\nexport const KNOWN_PROVIDERS: readonly ProviderKind[] = [\r\n \"azure\",\r\n \"anthropic\",\r\n \"gemini\",\r\n \"mock\",\r\n \"vscode\",\r\n \"vscode-insiders\",\r\n] as const;\r\n\r\n/**\r\n * Provider aliases that are accepted in target definitions.\r\n * These map to the canonical ProviderKind values.\r\n */\r\nexport const PROVIDER_ALIASES: readonly string[] = [\r\n \"azure-openai\", // alias for \"azure\"\r\n \"google\", // alias for \"gemini\"\r\n \"google-gemini\", // alias for \"gemini\"\r\n \"openai\", // legacy/future support\r\n \"bedrock\", // legacy/future support\r\n \"vertex\", // legacy/future support\r\n] as const;\r\n\r\n/**\r\n * Schema identifier for targets.yaml files (version 2).\r\n */\r\nexport const TARGETS_SCHEMA_V2 = \"agentv-targets-v2\";\r\n\r\nexport interface ProviderRequest {\r\n readonly prompt: string;\r\n readonly guidelines?: string;\r\n readonly guideline_patterns?: readonly string[];\r\n readonly chatPrompt?: ChatPrompt;\r\n readonly attachments?: readonly string[];\r\n readonly evalCaseId?: string;\r\n readonly attempt?: number;\r\n readonly maxOutputTokens?: number;\r\n readonly temperature?: number;\r\n readonly metadata?: JsonObject;\r\n readonly signal?: AbortSignal;\r\n}\r\n\r\nexport interface ProviderResponse {\r\n readonly text: string;\r\n readonly reasoning?: string;\r\n readonly raw?: unknown;\r\n readonly usage?: JsonObject;\r\n}\r\n\r\nexport interface Provider {\r\n readonly id: string;\r\n readonly kind: ProviderKind;\r\n readonly targetName: string;\r\n invoke(request: ProviderRequest): Promise<ProviderResponse>;\r\n}\r\n\r\nexport type EnvLookup = Readonly<Record<string, string | undefined>>;\r\n\r\nexport interface TargetDefinition {\r\n readonly name: string;\r\n readonly provider: ProviderKind | string;\r\n readonly settings?: Record<string, unknown> | undefined;\r\n readonly judge_target?: string | undefined;\r\n readonly workers?: number | undefined;\r\n}\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { parse } from \"yaml\";\r\n\r\nimport type { ValidationError, ValidationResult } from \"./types.js\";\r\n\r\nconst SCHEMA_CONFIG_V2 = \"agentv-config-v2\";\r\n\r\n/**\r\n * Validate a config.yaml file for schema compliance and structural correctness.\r\n */\r\nexport async function validateConfigFile(filePath: string): Promise<ValidationResult> {\r\n const errors: ValidationError[] = [];\r\n\r\n try {\r\n const content = await readFile(filePath, \"utf8\");\r\n const parsed = parse(content) as unknown;\r\n\r\n // Check if parsed content is an object\r\n if (typeof parsed !== \"object\" || parsed === null) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n message: \"Config file must contain a valid YAML object\",\r\n });\r\n return { valid: false, filePath, fileType: \"config\", errors };\r\n }\r\n\r\n const config = parsed as Record<string, unknown>;\r\n\r\n // Validate $schema field\r\n const schema = config[\"$schema\"];\r\n if (schema !== SCHEMA_CONFIG_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${SCHEMA_CONFIG_V2}'`\r\n : `Missing required field '$schema'. Please add '$schema: ${SCHEMA_CONFIG_V2}' at the top of the file.`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"$schema\",\r\n message,\r\n });\r\n }\r\n\r\n // Validate guideline_patterns if present\r\n const guidelinePatterns = config[\"guideline_patterns\"];\r\n if (guidelinePatterns !== undefined) {\r\n if (!Array.isArray(guidelinePatterns)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"Field 'guideline_patterns' must be an array\",\r\n });\r\n } else if (!guidelinePatterns.every((p) => typeof p === \"string\")) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"All entries in 'guideline_patterns' must be strings\",\r\n });\r\n } else if (guidelinePatterns.length === 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"Field 'guideline_patterns' is empty. Consider removing it or adding patterns.\",\r\n });\r\n }\r\n }\r\n\r\n // Check for unexpected fields\r\n const allowedFields = new Set([\"$schema\", \"guideline_patterns\"]);\r\n const unexpectedFields = Object.keys(config).filter((key) => !allowedFields.has(key));\r\n \r\n if (unexpectedFields.length > 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n message: `Unexpected fields: ${unexpectedFields.join(\", \")}`,\r\n });\r\n }\r\n\r\n return {\r\n valid: errors.filter((e) => e.severity === \"error\").length === 0,\r\n filePath,\r\n fileType: \"config\",\r\n errors,\r\n };\r\n } catch (error) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n message: `Failed to parse config file: ${(error as Error).message}`,\r\n });\r\n return { valid: false, filePath, fileType: \"config\", errors };\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 type { ValidationError } from \"./types.js\";\r\nimport { buildSearchRoots, findGitRoot, resolveFileReference } from \"../file-utils.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 that file references in eval file content exist.\r\n * Checks content blocks with type: \"file\" and validates the referenced file exists.\r\n * Also checks that referenced files are not empty.\r\n */\r\nexport async function validateFileReferences(\r\n evalFilePath: string,\r\n): Promise<readonly ValidationError[]> {\r\n const errors: ValidationError[] = [];\r\n const absolutePath = path.resolve(evalFilePath);\r\n\r\n // Find git root and build search roots (same as yaml-parser does at runtime)\r\n const gitRoot = await findGitRoot(absolutePath);\r\n if (!gitRoot) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n message: \"Cannot validate file references: git repository root not found\",\r\n });\r\n return errors;\r\n }\r\n\r\n const searchRoots = buildSearchRoots(absolutePath, gitRoot);\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 {\r\n // Parse errors are already caught by eval-validator\r\n return errors;\r\n }\r\n\r\n if (!isObject(parsed)) {\r\n return errors;\r\n }\r\n\r\n const evalcases = parsed[\"evalcases\"];\r\n if (!Array.isArray(evalcases)) {\r\n return errors;\r\n }\r\n\r\n for (let i = 0; i < evalcases.length; i++) {\r\n const evalCase = evalcases[i];\r\n if (!isObject(evalCase)) {\r\n continue;\r\n }\r\n\r\n // Check input_messages\r\n const inputMessages = evalCase[\"input_messages\"];\r\n if (Array.isArray(inputMessages)) {\r\n await validateMessagesFileRefs(inputMessages, `evalcases[${i}].input_messages`, searchRoots, absolutePath, errors);\r\n }\r\n\r\n // Check expected_messages\r\n const expectedMessages = evalCase[\"expected_messages\"];\r\n if (Array.isArray(expectedMessages)) {\r\n await validateMessagesFileRefs(expectedMessages, `evalcases[${i}].expected_messages`, searchRoots, absolutePath, errors);\r\n }\r\n }\r\n\r\n return errors;\r\n}\r\n\r\nasync function validateMessagesFileRefs(\r\n messages: JsonArray,\r\n location: string,\r\n searchRoots: readonly string[],\r\n filePath: string,\r\n errors: ValidationError[],\r\n): Promise<void> {\r\n for (let i = 0; i < messages.length; i++) {\r\n const message = messages[i];\r\n if (!isObject(message)) {\r\n continue;\r\n }\r\n\r\n const content = message[\"content\"];\r\n if (typeof content === \"string\") {\r\n continue;\r\n }\r\n\r\n if (!Array.isArray(content)) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < content.length; j++) {\r\n const contentItem = content[j];\r\n if (!isObject(contentItem)) {\r\n continue;\r\n }\r\n\r\n const type = contentItem[\"type\"];\r\n if (type !== \"file\") {\r\n continue;\r\n }\r\n\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: `${location}[${i}].content[${j}].value`,\r\n message: \"File reference must have a 'value' field with the file path\",\r\n });\r\n continue;\r\n }\r\n\r\n // Use the same file resolution logic as yaml-parser at runtime\r\n const { resolvedPath } = await resolveFileReference(value, searchRoots);\r\n\r\n if (!resolvedPath) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Referenced file not found: ${value}`,\r\n });\r\n } else {\r\n // Check that file is not empty\r\n try {\r\n const fileContent = await readFile(resolvedPath, \"utf8\");\r\n if (fileContent.trim().length === 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Referenced file is empty: ${value}`,\r\n });\r\n }\r\n } catch (error) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Cannot read referenced file: ${value} (${(error as Error).message})`,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","import { constants } from \"node:fs\";\r\nimport { access } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\n\r\nexport async function fileExists(filePath: string): Promise<boolean> {\r\n try {\r\n await access(filePath, constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Find git repository root by walking up the directory tree.\r\n */\r\nexport async function findGitRoot(startPath: string): Promise<string | null> {\r\n let currentDir = path.dirname(path.resolve(startPath));\r\n const root = path.parse(currentDir).root;\r\n\r\n while (currentDir !== root) {\r\n const gitPath = path.join(currentDir, \".git\");\r\n if (await fileExists(gitPath)) {\r\n return currentDir;\r\n }\r\n\r\n const parentDir = path.dirname(currentDir);\r\n if (parentDir === currentDir) {\r\n break;\r\n }\r\n currentDir = parentDir;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Build a chain of directories walking from a file's location up to repo root.\r\n * Used for discovering configuration files like targets.yaml or config.yaml.\r\n */\r\nexport function buildDirectoryChain(filePath: string, repoRoot: string): readonly string[] {\r\n const directories: string[] = [];\r\n const seen = new Set<string>();\r\n const boundary = path.resolve(repoRoot);\r\n let current: string | undefined = path.resolve(path.dirname(filePath));\r\n\r\n while (current !== undefined) {\r\n if (!seen.has(current)) {\r\n directories.push(current);\r\n seen.add(current);\r\n }\r\n if (current === boundary) {\r\n break;\r\n }\r\n const parent = path.dirname(current);\r\n if (parent === current) {\r\n break;\r\n }\r\n current = parent;\r\n }\r\n\r\n if (!seen.has(boundary)) {\r\n directories.push(boundary);\r\n }\r\n\r\n return directories;\r\n}\r\n\r\n/**\r\n * Build search roots for file resolution, matching yaml-parser behavior.\r\n * Searches from eval file directory up to repo root.\r\n */\r\nexport function buildSearchRoots(evalPath: string, repoRoot: string): readonly string[] {\r\n const uniqueRoots: string[] = [];\r\n const addRoot = (root: string): void => {\r\n const normalized = path.resolve(root);\r\n if (!uniqueRoots.includes(normalized)) {\r\n uniqueRoots.push(normalized);\r\n }\r\n };\r\n\r\n let currentDir = path.dirname(evalPath);\r\n let reachedBoundary = false;\r\n while (!reachedBoundary) {\r\n addRoot(currentDir);\r\n const parentDir = path.dirname(currentDir);\r\n if (currentDir === repoRoot || parentDir === currentDir) {\r\n reachedBoundary = true;\r\n } else {\r\n currentDir = parentDir;\r\n }\r\n }\r\n\r\n addRoot(repoRoot);\r\n addRoot(process.cwd());\r\n return uniqueRoots;\r\n}\r\n\r\n/**\r\n * Trim leading path separators for display.\r\n */\r\nfunction trimLeadingSeparators(value: string): string {\r\n const trimmed = value.replace(/^[/\\\\]+/, \"\");\r\n return trimmed.length > 0 ? trimmed : value;\r\n}\r\n\r\n/**\r\n * Resolve a file reference using search roots, matching yaml-parser behavior.\r\n */\r\nexport async function resolveFileReference(\r\n rawValue: string,\r\n searchRoots: readonly string[],\r\n): Promise<{\r\n readonly displayPath: string;\r\n readonly resolvedPath?: string;\r\n readonly attempted: readonly string[];\r\n}> {\r\n const displayPath = trimLeadingSeparators(rawValue);\r\n const potentialPaths: string[] = [];\r\n\r\n if (path.isAbsolute(rawValue)) {\r\n potentialPaths.push(path.normalize(rawValue));\r\n }\r\n\r\n for (const base of searchRoots) {\r\n potentialPaths.push(path.resolve(base, displayPath));\r\n }\r\n\r\n const attempted: string[] = [];\r\n const seen = new Set<string>();\r\n for (const candidate of potentialPaths) {\r\n const absoluteCandidate = path.resolve(candidate);\r\n if (seen.has(absoluteCandidate)) {\r\n continue;\r\n }\r\n seen.add(absoluteCandidate);\r\n attempted.push(absoluteCandidate);\r\n if (await fileExists(absoluteCandidate)) {\r\n return { displayPath, resolvedPath: absoluteCandidate, attempted };\r\n }\r\n }\r\n\r\n return { displayPath, attempted };\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;A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,KAAM,MAAgB,OAAO;AAAA,UAC7E,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;","names":["import_promises","import_yaml","SCHEMA_EVAL_V2","path","import_promises","import_node_path","import_yaml","isObject","path","import_promises","import_yaml","SCHEMA_CONFIG_V2","import_promises","import_node_path","import_yaml","import_promises","import_node_path","path","path","isObject","path"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/evaluation/validation/index.ts","../../../src/evaluation/validation/file-type.ts","../../../src/evaluation/validation/eval-validator.ts","../../../src/evaluation/validation/targets-validator.ts","../../../src/evaluation/providers/types.ts","../../../src/evaluation/validation/config-validator.ts","../../../src/evaluation/validation/file-reference-validator.ts","../../../src/evaluation/file-utils.ts"],"sourcesContent":["/**\r\n * Validation module for AgentV eval and targets files.\r\n */\r\n\r\nexport { detectFileType, isValidSchema, getExpectedSchema } from \"./file-type.js\";\r\nexport { validateEvalFile } from \"./eval-validator.js\";\r\nexport { validateTargetsFile } from \"./targets-validator.js\";\r\nexport { validateConfigFile } from \"./config-validator.js\";\r\nexport { validateFileReferences } from \"./file-reference-validator.js\";\r\nexport type {\r\n FileType,\r\n ValidationSeverity,\r\n ValidationError,\r\n ValidationResult,\r\n ValidationSummary,\r\n} from \"./types.js\";\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { parse } from \"yaml\";\r\n\r\nimport type { FileType } from \"./types.js\";\r\n\r\nconst SCHEMA_EVAL_V2 = \"agentv-eval-v2\";\r\nconst SCHEMA_TARGETS_V2 = \"agentv-targets-v2\";\r\nconst SCHEMA_CONFIG_V2 = \"agentv-config-v2\";\r\n\r\n/**\r\n * Detect file type by reading $schema field from YAML file.\r\n * Returns \"unknown\" if file cannot be read or $schema is missing/invalid.\r\n */\r\nexport async function detectFileType(filePath: string): Promise<FileType> {\r\n try {\r\n const content = await readFile(filePath, \"utf8\");\r\n const parsed = parse(content) as unknown;\r\n\r\n if (typeof parsed !== \"object\" || parsed === null) {\r\n return \"unknown\";\r\n }\r\n\r\n const record = parsed as Record<string, unknown>;\r\n const schema = record[\"$schema\"];\r\n\r\n if (typeof schema !== \"string\") {\r\n return \"unknown\";\r\n }\r\n\r\n switch (schema) {\r\n case SCHEMA_EVAL_V2:\r\n return \"eval\";\r\n case SCHEMA_TARGETS_V2:\r\n return \"targets\";\r\n case SCHEMA_CONFIG_V2:\r\n return \"config\";\r\n default:\r\n return \"unknown\";\r\n }\r\n } catch {\r\n return \"unknown\";\r\n }\r\n}\r\n\r\n/**\r\n * Check if a schema value is a valid AgentV schema identifier.\r\n */\r\nexport function isValidSchema(schema: unknown): boolean {\r\n return schema === SCHEMA_EVAL_V2 || schema === SCHEMA_TARGETS_V2 || schema === SCHEMA_CONFIG_V2;\r\n}\r\n\r\n/**\r\n * Get the expected schema for a file type.\r\n */\r\nexport function getExpectedSchema(fileType: FileType): string | undefined {\r\n switch (fileType) {\r\n case \"eval\":\r\n return SCHEMA_EVAL_V2;\r\n case \"targets\":\r\n return SCHEMA_TARGETS_V2;\r\n case \"config\":\r\n return SCHEMA_CONFIG_V2;\r\n default:\r\n return undefined;\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 type { ValidationError, ValidationResult } from \"./types.js\";\r\n\r\nconst SCHEMA_EVAL_V2 = \"agentv-eval-v2\";\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(\r\n filePath: string,\r\n): 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 $schema field\r\n const schema = parsed[\"$schema\"];\r\n if (schema !== SCHEMA_EVAL_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${SCHEMA_EVAL_V2}'`\r\n : `Missing required field '$schema'. Expected '${SCHEMA_EVAL_V2}'`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: \"$schema\",\r\n message,\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, outcome, 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 const outcome = evalCase[\"outcome\"];\r\n if (typeof outcome !== \"string\" || outcome.trim().length === 0) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.outcome`,\r\n message: \"Missing or invalid 'outcome' field (must be a non-empty string)\",\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 const expectedMessages = evalCase[\"expected_messages\"];\r\n if (!Array.isArray(expectedMessages)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.expected_messages`,\r\n message: \"Missing or invalid 'expected_messages' field (must be an array)\",\r\n });\r\n } else {\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 content field (can be string or array)\r\n const content = message[\"content\"];\r\n if (typeof content === \"string\") {\r\n // String content is valid\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 // String in array is valid\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 }\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","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\nimport { KNOWN_PROVIDERS, PROVIDER_ALIASES, TARGETS_SCHEMA_V2 } from \"../providers/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\nconst CLI_PLACEHOLDERS = new Set([\"PROMPT\", \"GUIDELINES\", \"EVAL_ID\", \"ATTEMPT\", \"FILES\"]);\r\n\r\n/**\r\n * Validate a targets file (agentv-targets-v2 schema).\r\n */\r\nexport async function validateTargetsFile(\r\n filePath: string,\r\n): 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\nfunction validateCliSettings(\r\n settings: unknown,\r\n absolutePath: string,\r\n location: string,\r\n errors: ValidationError[],\r\n): void {\r\n if (!isObject(settings)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location,\r\n message: \"CLI provider requires a 'settings' object\",\r\n });\r\n return;\r\n }\r\n\r\n const commandTemplate = settings[\"command_template\"] ?? settings[\"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(commandTemplate, absolutePath, `${location}.commandTemplate`, errors);\r\n }\r\n\r\n const attachmentsFormat = settings[\"attachments_format\"] ?? settings[\"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 = settings[\"files_format\"] ?? settings[\"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 = settings[\"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 = settings[\"timeout_seconds\"] ?? settings[\"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 envOverrides = settings[\"env\"];\r\n if (envOverrides !== undefined) {\r\n if (!isObject(envOverrides)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.env`,\r\n message: \"'env' must be an object with string values\",\r\n });\r\n } else {\r\n for (const [key, value] of Object.entries(envOverrides)) {\r\n if (typeof value !== \"string\" || value.trim().length === 0) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.env.${key}`,\r\n message: `Environment override '${key}' must be a non-empty string`,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n\r\n const healthcheck = settings[\"healthcheck\"];\r\n if (healthcheck !== undefined) {\r\n validateCliHealthcheck(healthcheck, absolutePath, `${location}.healthcheck`, errors);\r\n }\r\n}\r\n\r\nfunction 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(commandTemplate, absolutePath, `${location}.commandTemplate`, errors);\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\nfunction 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\nfunction 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 $schema field\r\n const schema = parsed[\"$schema\"];\r\n if (schema !== TARGETS_SCHEMA_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${TARGETS_SCHEMA_V2}'`\r\n : `Missing required field '$schema'. Expected '${TARGETS_SCHEMA_V2}'`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: \"$schema\",\r\n message,\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 // Optional field: settings (must be object if present)\r\n const settings = target[\"settings\"];\r\n if (providerValue !== \"cli\" && settings !== undefined && !isObject(settings)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n location: `${location}.settings`,\r\n message: \"Invalid 'settings' field (must be an object)\",\r\n });\r\n }\r\n\r\n if (providerValue === \"cli\") {\r\n validateCliSettings(settings, absolutePath, `${location}.settings`, 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 type { AxChatRequest } from \"@ax-llm/ax\";\r\n\r\nimport type { JsonObject } from \"../types.js\";\r\n\r\ntype ChatPrompt = AxChatRequest[\"chatPrompt\"];\r\n\r\nexport type ProviderKind =\r\n | \"azure\"\r\n | \"anthropic\"\r\n | \"gemini\"\r\n | \"codex\"\r\n | \"cli\"\r\n | \"mock\"\r\n | \"vscode\"\r\n | \"vscode-insiders\";\r\n\r\n/**\r\n * List of all supported provider kinds.\r\n * This is the source of truth for provider validation.\r\n */\r\nexport const KNOWN_PROVIDERS: readonly ProviderKind[] = [\r\n \"azure\",\r\n \"anthropic\",\r\n \"gemini\",\r\n \"codex\",\r\n \"cli\",\r\n \"mock\",\r\n \"vscode\",\r\n \"vscode-insiders\",\r\n] as const;\r\n\r\n/**\r\n * Provider aliases that are accepted in target definitions.\r\n * These map to the canonical ProviderKind values.\r\n */\r\nexport const PROVIDER_ALIASES: readonly string[] = [\r\n \"azure-openai\", // alias for \"azure\"\r\n \"google\", // alias for \"gemini\"\r\n \"google-gemini\", // alias for \"gemini\"\r\n \"codex-cli\", // alias for \"codex\"\r\n \"openai\", // legacy/future support\r\n \"bedrock\", // legacy/future support\r\n \"vertex\", // legacy/future support\r\n] as const;\r\n\r\n/**\r\n * Schema identifier for targets.yaml files (version 2).\r\n */\r\nexport const TARGETS_SCHEMA_V2 = \"agentv-targets-v2\";\r\n\r\nexport interface ProviderRequest {\r\n readonly prompt: string;\r\n readonly guidelines?: string;\r\n readonly guideline_patterns?: readonly string[];\r\n readonly chatPrompt?: ChatPrompt;\r\n readonly inputFiles?: readonly string[];\r\n readonly evalCaseId?: string;\r\n readonly attempt?: number;\r\n readonly maxOutputTokens?: number;\r\n readonly temperature?: number;\r\n readonly metadata?: JsonObject;\r\n readonly signal?: AbortSignal;\r\n}\r\n\r\nexport interface ProviderResponse {\r\n readonly text: string;\r\n readonly reasoning?: string;\r\n readonly raw?: unknown;\r\n readonly usage?: JsonObject;\r\n}\r\n\r\nexport interface Provider {\r\n readonly id: string;\r\n readonly kind: ProviderKind;\r\n readonly targetName: string;\r\n invoke(request: ProviderRequest): Promise<ProviderResponse>;\r\n /**\r\n * Optional capability marker for provider-managed batching (single session handling multiple requests).\r\n */\r\n readonly supportsBatch?: boolean;\r\n /**\r\n * Optional batch invocation hook. When defined alongside supportsBatch=true,\r\n * the orchestrator may send multiple requests in a single provider session.\r\n */\r\n invokeBatch?(requests: readonly ProviderRequest[]): Promise<readonly ProviderResponse[]>;\r\n}\r\n\r\nexport type EnvLookup = Readonly<Record<string, string | undefined>>;\r\n\r\nexport interface TargetDefinition {\r\n readonly name: string;\r\n readonly provider: ProviderKind | string;\r\n readonly settings?: Record<string, unknown> | undefined;\r\n readonly judge_target?: string | undefined;\r\n readonly workers?: number | undefined;\r\n}\r\n","import { readFile } from \"node:fs/promises\";\r\nimport { parse } from \"yaml\";\r\n\r\nimport type { ValidationError, ValidationResult } from \"./types.js\";\r\n\r\nconst SCHEMA_CONFIG_V2 = \"agentv-config-v2\";\r\n\r\n/**\r\n * Validate a config.yaml file for schema compliance and structural correctness.\r\n */\r\nexport async function validateConfigFile(filePath: string): Promise<ValidationResult> {\r\n const errors: ValidationError[] = [];\r\n\r\n try {\r\n const content = await readFile(filePath, \"utf8\");\r\n const parsed = parse(content) as unknown;\r\n\r\n // Check if parsed content is an object\r\n if (typeof parsed !== \"object\" || parsed === null) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n message: \"Config file must contain a valid YAML object\",\r\n });\r\n return { valid: false, filePath, fileType: \"config\", errors };\r\n }\r\n\r\n const config = parsed as Record<string, unknown>;\r\n\r\n // Validate $schema field\r\n const schema = config[\"$schema\"];\r\n if (schema !== SCHEMA_CONFIG_V2) {\r\n const message =\r\n typeof schema === \"string\"\r\n ? `Invalid $schema value '${schema}'. Expected '${SCHEMA_CONFIG_V2}'`\r\n : `Missing required field '$schema'. Please add '$schema: ${SCHEMA_CONFIG_V2}' at the top of the file.`;\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"$schema\",\r\n message,\r\n });\r\n }\r\n\r\n // Validate guideline_patterns if present\r\n const guidelinePatterns = config[\"guideline_patterns\"];\r\n if (guidelinePatterns !== undefined) {\r\n if (!Array.isArray(guidelinePatterns)) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"Field 'guideline_patterns' must be an array\",\r\n });\r\n } else if (!guidelinePatterns.every((p) => typeof p === \"string\")) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"All entries in 'guideline_patterns' must be strings\",\r\n });\r\n } else if (guidelinePatterns.length === 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n location: \"guideline_patterns\",\r\n message: \"Field 'guideline_patterns' is empty. Consider removing it or adding patterns.\",\r\n });\r\n }\r\n }\r\n\r\n // Check for unexpected fields\r\n const allowedFields = new Set([\"$schema\", \"guideline_patterns\"]);\r\n const unexpectedFields = Object.keys(config).filter((key) => !allowedFields.has(key));\r\n \r\n if (unexpectedFields.length > 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n message: `Unexpected fields: ${unexpectedFields.join(\", \")}`,\r\n });\r\n }\r\n\r\n return {\r\n valid: errors.filter((e) => e.severity === \"error\").length === 0,\r\n filePath,\r\n fileType: \"config\",\r\n errors,\r\n };\r\n } catch (error) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n message: `Failed to parse config file: ${(error as Error).message}`,\r\n });\r\n return { valid: false, filePath, fileType: \"config\", errors };\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 type { ValidationError } from \"./types.js\";\r\nimport { buildSearchRoots, findGitRoot, resolveFileReference } from \"../file-utils.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 that file references in eval file content exist.\r\n * Checks content blocks with type: \"file\" and validates the referenced file exists.\r\n * Also checks that referenced files are not empty.\r\n */\r\nexport async function validateFileReferences(\r\n evalFilePath: string,\r\n): Promise<readonly ValidationError[]> {\r\n const errors: ValidationError[] = [];\r\n const absolutePath = path.resolve(evalFilePath);\r\n\r\n // Find git root and build search roots (same as yaml-parser does at runtime)\r\n const gitRoot = await findGitRoot(absolutePath);\r\n if (!gitRoot) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath: absolutePath,\r\n message: \"Cannot validate file references: git repository root not found\",\r\n });\r\n return errors;\r\n }\r\n\r\n const searchRoots = buildSearchRoots(absolutePath, gitRoot);\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 {\r\n // Parse errors are already caught by eval-validator\r\n return errors;\r\n }\r\n\r\n if (!isObject(parsed)) {\r\n return errors;\r\n }\r\n\r\n const evalcases = parsed[\"evalcases\"];\r\n if (!Array.isArray(evalcases)) {\r\n return errors;\r\n }\r\n\r\n for (let i = 0; i < evalcases.length; i++) {\r\n const evalCase = evalcases[i];\r\n if (!isObject(evalCase)) {\r\n continue;\r\n }\r\n\r\n // Check input_messages\r\n const inputMessages = evalCase[\"input_messages\"];\r\n if (Array.isArray(inputMessages)) {\r\n await validateMessagesFileRefs(inputMessages, `evalcases[${i}].input_messages`, searchRoots, absolutePath, errors);\r\n }\r\n\r\n // Check expected_messages\r\n const expectedMessages = evalCase[\"expected_messages\"];\r\n if (Array.isArray(expectedMessages)) {\r\n await validateMessagesFileRefs(expectedMessages, `evalcases[${i}].expected_messages`, searchRoots, absolutePath, errors);\r\n }\r\n }\r\n\r\n return errors;\r\n}\r\n\r\nasync function validateMessagesFileRefs(\r\n messages: JsonArray,\r\n location: string,\r\n searchRoots: readonly string[],\r\n filePath: string,\r\n errors: ValidationError[],\r\n): Promise<void> {\r\n for (let i = 0; i < messages.length; i++) {\r\n const message = messages[i];\r\n if (!isObject(message)) {\r\n continue;\r\n }\r\n\r\n const content = message[\"content\"];\r\n if (typeof content === \"string\") {\r\n continue;\r\n }\r\n\r\n if (!Array.isArray(content)) {\r\n continue;\r\n }\r\n\r\n for (let j = 0; j < content.length; j++) {\r\n const contentItem = content[j];\r\n if (!isObject(contentItem)) {\r\n continue;\r\n }\r\n\r\n const type = contentItem[\"type\"];\r\n if (type !== \"file\") {\r\n continue;\r\n }\r\n\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: `${location}[${i}].content[${j}].value`,\r\n message: \"File reference must have a 'value' field with the file path\",\r\n });\r\n continue;\r\n }\r\n\r\n // Use the same file resolution logic as yaml-parser at runtime\r\n const { resolvedPath } = await resolveFileReference(value, searchRoots);\r\n\r\n if (!resolvedPath) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Referenced file not found: ${value}`,\r\n });\r\n } else {\r\n // Check that file is not empty\r\n try {\r\n const fileContent = await readFile(resolvedPath, \"utf8\");\r\n if (fileContent.trim().length === 0) {\r\n errors.push({\r\n severity: \"warning\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Referenced file is empty: ${value}`,\r\n });\r\n }\r\n } catch (error) {\r\n errors.push({\r\n severity: \"error\",\r\n filePath,\r\n location: `${location}[${i}].content[${j}]`,\r\n message: `Cannot read referenced file: ${value} (${(error as Error).message})`,\r\n });\r\n }\r\n }\r\n }\r\n }\r\n}\r\n","import { constants } from \"node:fs\";\r\nimport { access } from \"node:fs/promises\";\r\nimport path from \"node:path\";\r\n\r\nexport async function fileExists(filePath: string): Promise<boolean> {\r\n try {\r\n await access(filePath, constants.F_OK);\r\n return true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\n/**\r\n * Find git repository root by walking up the directory tree.\r\n */\r\nexport async function findGitRoot(startPath: string): Promise<string | null> {\r\n let currentDir = path.dirname(path.resolve(startPath));\r\n const root = path.parse(currentDir).root;\r\n\r\n while (currentDir !== root) {\r\n const gitPath = path.join(currentDir, \".git\");\r\n if (await fileExists(gitPath)) {\r\n return currentDir;\r\n }\r\n\r\n const parentDir = path.dirname(currentDir);\r\n if (parentDir === currentDir) {\r\n break;\r\n }\r\n currentDir = parentDir;\r\n }\r\n\r\n return null;\r\n}\r\n\r\n/**\r\n * Build a chain of directories walking from a file's location up to repo root.\r\n * Used for discovering configuration files like targets.yaml or config.yaml.\r\n */\r\nexport function buildDirectoryChain(filePath: string, repoRoot: string): readonly string[] {\r\n const directories: string[] = [];\r\n const seen = new Set<string>();\r\n const boundary = path.resolve(repoRoot);\r\n let current: string | undefined = path.resolve(path.dirname(filePath));\r\n\r\n while (current !== undefined) {\r\n if (!seen.has(current)) {\r\n directories.push(current);\r\n seen.add(current);\r\n }\r\n if (current === boundary) {\r\n break;\r\n }\r\n const parent = path.dirname(current);\r\n if (parent === current) {\r\n break;\r\n }\r\n current = parent;\r\n }\r\n\r\n if (!seen.has(boundary)) {\r\n directories.push(boundary);\r\n }\r\n\r\n return directories;\r\n}\r\n\r\n/**\r\n * Build search roots for file resolution, matching yaml-parser behavior.\r\n * Searches from eval file directory up to repo root.\r\n */\r\nexport function buildSearchRoots(evalPath: string, repoRoot: string): readonly string[] {\r\n const uniqueRoots: string[] = [];\r\n const addRoot = (root: string): void => {\r\n const normalized = path.resolve(root);\r\n if (!uniqueRoots.includes(normalized)) {\r\n uniqueRoots.push(normalized);\r\n }\r\n };\r\n\r\n let currentDir = path.dirname(evalPath);\r\n let reachedBoundary = false;\r\n while (!reachedBoundary) {\r\n addRoot(currentDir);\r\n const parentDir = path.dirname(currentDir);\r\n if (currentDir === repoRoot || parentDir === currentDir) {\r\n reachedBoundary = true;\r\n } else {\r\n currentDir = parentDir;\r\n }\r\n }\r\n\r\n addRoot(repoRoot);\r\n addRoot(process.cwd());\r\n return uniqueRoots;\r\n}\r\n\r\n/**\r\n * Trim leading path separators for display.\r\n */\r\nfunction trimLeadingSeparators(value: string): string {\r\n const trimmed = value.replace(/^[/\\\\]+/, \"\");\r\n return trimmed.length > 0 ? trimmed : value;\r\n}\r\n\r\n/**\r\n * Resolve a file reference using search roots, matching yaml-parser behavior.\r\n */\r\nexport async function resolveFileReference(\r\n rawValue: string,\r\n searchRoots: readonly string[],\r\n): Promise<{\r\n readonly displayPath: string;\r\n readonly resolvedPath?: string;\r\n readonly attempted: readonly string[];\r\n}> {\r\n const displayPath = trimLeadingSeparators(rawValue);\r\n const potentialPaths: string[] = [];\r\n\r\n if (path.isAbsolute(rawValue)) {\r\n potentialPaths.push(path.normalize(rawValue));\r\n }\r\n\r\n for (const base of searchRoots) {\r\n potentialPaths.push(path.resolve(base, displayPath));\r\n }\r\n\r\n const attempted: string[] = [];\r\n const seen = new Set<string>();\r\n for (const candidate of potentialPaths) {\r\n const absoluteCandidate = path.resolve(candidate);\r\n if (seen.has(absoluteCandidate)) {\r\n continue;\r\n }\r\n seen.add(absoluteCandidate);\r\n attempted.push(absoluteCandidate);\r\n if (await fileExists(absoluteCandidate)) {\r\n return { displayPath, resolvedPath: absoluteCandidate, attempted };\r\n }\r\n }\r\n\r\n return { displayPath, attempted };\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,sBAAyB;AACzB,kBAAsB;AAItB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;AAC1B,IAAM,mBAAmB;AAMzB,eAAsB,eAAe,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,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,UAAM,2BAAS,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":["import_promises","import_yaml","SCHEMA_EVAL_V2","path","import_promises","import_node_path","import_yaml","isObject","path","absolutePath","errors","import_promises","import_yaml","SCHEMA_CONFIG_V2","import_promises","import_node_path","import_yaml","import_promises","import_node_path","path","path","isObject","path"]}
|