@agentv/core 1.5.0 → 2.0.1

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/index.d.cts CHANGED
@@ -201,17 +201,19 @@ declare function isJsonValue(value: unknown): value is JsonValue;
201
201
  * - Either content (string or array of objects) OR tool_calls (for assistant messages)
202
202
  */
203
203
  declare function isTestMessage(value: unknown): value is TestMessage;
204
- declare const EVALUATOR_KIND_VALUES: readonly ["code_judge", "llm_judge", "rubric", "composite", "tool_trajectory"];
204
+ declare const EVALUATOR_KIND_VALUES: readonly ["code_judge", "llm_judge", "rubric", "composite", "tool_trajectory", "field_accuracy", "latency", "cost", "token_usage"];
205
205
  type EvaluatorKind = (typeof EVALUATOR_KIND_VALUES)[number];
206
206
  declare function isEvaluatorKind(value: unknown): value is EvaluatorKind;
207
207
  type CodeEvaluatorConfig = {
208
208
  readonly name: string;
209
209
  readonly type: 'code';
210
- readonly script: string;
210
+ readonly script: readonly string[];
211
211
  readonly resolvedScriptPath?: string;
212
212
  readonly cwd?: string;
213
213
  readonly resolvedCwd?: string;
214
214
  readonly weight?: number;
215
+ /** Pass-through configuration for the code_judge script (any unrecognized YAML properties) */
216
+ readonly config?: JsonObject;
215
217
  };
216
218
  type LlmJudgeEvaluatorConfig = {
217
219
  readonly name: string;
@@ -247,7 +249,85 @@ type CompositeEvaluatorConfig = {
247
249
  readonly aggregator: CompositeAggregatorConfig;
248
250
  readonly weight?: number;
249
251
  };
250
- type EvaluatorConfig = CodeEvaluatorConfig | LlmJudgeEvaluatorConfig | CompositeEvaluatorConfig | ToolTrajectoryEvaluatorConfig;
252
+ /**
253
+ * Match type for field accuracy evaluation.
254
+ * Note: For fuzzy string matching (Levenshtein, Jaro-Winkler, etc.), use a code_judge evaluator.
255
+ * See examples/features/document-extraction/fuzzy_match.ts for an example.
256
+ */
257
+ type FieldMatchType = 'exact' | 'numeric_tolerance' | 'date';
258
+ /**
259
+ * Aggregation strategy for combining field scores.
260
+ */
261
+ type FieldAggregationType = 'weighted_average' | 'all_or_nothing';
262
+ /**
263
+ * Configuration for a single field to evaluate.
264
+ */
265
+ type FieldConfig = {
266
+ /** Dot-notation path to the field (e.g., "invoice.vendor.name" or "items[0].amount") */
267
+ readonly path: string;
268
+ /** Match strategy for this field */
269
+ readonly match: FieldMatchType;
270
+ /** Whether this field is required (missing required fields count as failures) */
271
+ readonly required?: boolean;
272
+ /** Weight for aggregation (default: 1.0) */
273
+ readonly weight?: number;
274
+ /** Tolerance for numeric matching (absolute value unless relative is true) */
275
+ readonly tolerance?: number;
276
+ /** Whether tolerance is relative (percentage) vs absolute */
277
+ readonly relative?: boolean;
278
+ /** Date formats to try when parsing (default: common formats) */
279
+ readonly formats?: readonly string[];
280
+ };
281
+ /**
282
+ * Configuration for the field_accuracy evaluator.
283
+ */
284
+ type FieldAccuracyEvaluatorConfig = {
285
+ readonly name: string;
286
+ readonly type: 'field_accuracy';
287
+ /** Fields to compare between candidate and expected */
288
+ readonly fields: readonly FieldConfig[];
289
+ /** Strategy for combining field scores (default: weighted_average) */
290
+ readonly aggregation?: FieldAggregationType;
291
+ readonly weight?: number;
292
+ };
293
+ /**
294
+ * Configuration for the latency evaluator.
295
+ * Checks execution duration against a threshold.
296
+ */
297
+ type LatencyEvaluatorConfig = {
298
+ readonly name: string;
299
+ readonly type: 'latency';
300
+ /** Maximum allowed duration in milliseconds */
301
+ readonly threshold: number;
302
+ readonly weight?: number;
303
+ };
304
+ /**
305
+ * Configuration for the cost evaluator.
306
+ * Checks execution cost against a budget.
307
+ */
308
+ type CostEvaluatorConfig = {
309
+ readonly name: string;
310
+ readonly type: 'cost';
311
+ /** Maximum allowed cost in USD */
312
+ readonly budget: number;
313
+ readonly weight?: number;
314
+ };
315
+ /**
316
+ * Configuration for the token_usage evaluator.
317
+ * Checks provider-reported token usage against configured limits.
318
+ */
319
+ type TokenUsageEvaluatorConfig = {
320
+ readonly name: string;
321
+ readonly type: 'token_usage';
322
+ /** Maximum allowed total tokens (input + output + cached, when present) */
323
+ readonly max_total?: number;
324
+ /** Maximum allowed input tokens (prompt) */
325
+ readonly max_input?: number;
326
+ /** Maximum allowed output tokens (completion) */
327
+ readonly max_output?: number;
328
+ readonly weight?: number;
329
+ };
330
+ type EvaluatorConfig = CodeEvaluatorConfig | LlmJudgeEvaluatorConfig | CompositeEvaluatorConfig | ToolTrajectoryEvaluatorConfig | FieldAccuracyEvaluatorConfig | LatencyEvaluatorConfig | CostEvaluatorConfig | TokenUsageEvaluatorConfig;
251
331
  /**
252
332
  * Eval case definition sourced from AgentV specs.
253
333
  */
@@ -282,7 +362,6 @@ interface EvaluationResult {
282
362
  readonly candidateAnswer: string;
283
363
  readonly target: string;
284
364
  readonly reasoning?: string;
285
- readonly rawAspects?: readonly string[];
286
365
  readonly agentProviderRequest?: JsonObject;
287
366
  readonly lmProviderRequest?: JsonObject;
288
367
  readonly evaluatorProviderRequest?: JsonObject;
@@ -317,7 +396,7 @@ interface ChatMessage {
317
396
  readonly name?: string;
318
397
  }
319
398
  type ChatPrompt = readonly ChatMessage[];
320
- type ProviderKind = 'azure' | 'anthropic' | 'gemini' | 'codex' | 'pi-coding-agent' | 'cli' | 'mock' | 'vscode' | 'vscode-insiders';
399
+ type ProviderKind = 'azure' | 'anthropic' | 'gemini' | 'codex' | 'pi-coding-agent' | 'claude-code' | 'cli' | 'mock' | 'vscode' | 'vscode-insiders';
321
400
  interface ProviderRequest {
322
401
  readonly question: string;
323
402
  readonly systemPrompt?: string;
@@ -726,6 +805,16 @@ interface PiCodingAgentResolvedConfig {
726
805
  readonly logFormat?: 'summary' | 'json';
727
806
  readonly systemPrompt?: string;
728
807
  }
808
+ interface ClaudeCodeResolvedConfig {
809
+ readonly executable: string;
810
+ readonly model?: string;
811
+ readonly systemPrompt?: string;
812
+ readonly args?: readonly string[];
813
+ readonly cwd?: string;
814
+ readonly timeoutMs?: number;
815
+ readonly logDir?: string;
816
+ readonly logFormat?: 'summary' | 'json';
817
+ }
729
818
  interface MockResolvedConfig {
730
819
  readonly response?: string;
731
820
  readonly delayMs?: number;
@@ -774,6 +863,13 @@ type ResolvedTarget = {
774
863
  readonly workers?: number;
775
864
  readonly providerBatching?: boolean;
776
865
  readonly config: PiCodingAgentResolvedConfig;
866
+ } | {
867
+ readonly kind: 'claude-code';
868
+ readonly name: string;
869
+ readonly judgeTarget?: string;
870
+ readonly workers?: number;
871
+ readonly providerBatching?: boolean;
872
+ readonly config: ClaudeCodeResolvedConfig;
777
873
  } | {
778
874
  readonly kind: 'mock';
779
875
  readonly name: string;
@@ -839,6 +935,16 @@ type PiLogListener = (entry: PiLogEntry) => void;
839
935
  declare function consumePiLogEntries(): PiLogEntry[];
840
936
  declare function subscribeToPiLogEntries(listener: PiLogListener): () => void;
841
937
 
938
+ type ClaudeCodeLogEntry = {
939
+ readonly filePath: string;
940
+ readonly evalCaseId?: string;
941
+ readonly targetName: string;
942
+ readonly attempt?: number;
943
+ };
944
+ type ClaudeCodeLogListener = (entry: ClaudeCodeLogEntry) => void;
945
+ declare function consumeClaudeCodeLogEntries(): ClaudeCodeLogEntry[];
946
+ declare function subscribeToClaudeCodeLogEntries(listener: ClaudeCodeLogListener): () => void;
947
+
842
948
  declare function createProvider(target: ResolvedTarget): Provider;
843
949
  declare function resolveAndCreateProvider(definition: TargetDefinition, env?: EnvLookup): Provider;
844
950
 
@@ -870,7 +976,6 @@ interface EvaluationScore {
870
976
  readonly misses: readonly string[];
871
977
  readonly expectedAspectCount: number;
872
978
  readonly reasoning?: string;
873
- readonly rawAspects?: readonly string[];
874
979
  readonly evaluatorRawRequest?: JsonObject;
875
980
  readonly evaluatorResults?: readonly ChildEvaluatorResult[];
876
981
  }
@@ -911,15 +1016,18 @@ declare class LlmJudgeEvaluator implements Evaluator {
911
1016
  private runWithRetry;
912
1017
  }
913
1018
  interface CodeEvaluatorOptions {
914
- readonly script: string;
1019
+ readonly script: readonly string[];
915
1020
  readonly cwd?: string;
916
1021
  readonly agentTimeoutMs?: number;
1022
+ /** Pass-through configuration from YAML (any unrecognized properties) */
1023
+ readonly config?: Record<string, unknown>;
917
1024
  }
918
1025
  declare class CodeEvaluator implements Evaluator {
919
1026
  readonly kind = "code";
920
1027
  private readonly script;
921
1028
  private readonly cwd?;
922
1029
  private readonly agentTimeoutMs?;
1030
+ private readonly config?;
923
1031
  constructor(options: CodeEvaluatorOptions);
924
1032
  evaluate(context: EvaluationContext): Promise<EvaluationScore>;
925
1033
  }
@@ -943,6 +1051,44 @@ declare class ToolTrajectoryEvaluator implements Evaluator {
943
1051
  private evaluateInOrder;
944
1052
  private evaluateExact;
945
1053
  }
1054
+ interface FieldAccuracyEvaluatorOptions {
1055
+ readonly config: FieldAccuracyEvaluatorConfig;
1056
+ }
1057
+ /**
1058
+ * FieldAccuracyEvaluator compares extracted structured data against expected values
1059
+ * with configurable matching strategies (exact, fuzzy, numeric_tolerance, date).
1060
+ */
1061
+ declare class FieldAccuracyEvaluator implements Evaluator {
1062
+ readonly kind = "field_accuracy";
1063
+ private readonly config;
1064
+ constructor(options: FieldAccuracyEvaluatorOptions);
1065
+ evaluate(context: EvaluationContext): EvaluationScore;
1066
+ /**
1067
+ * Extract expected data from expected_messages array.
1068
+ * Looks for the last assistant message with content.
1069
+ */
1070
+ private extractExpectedData;
1071
+ /**
1072
+ * Evaluate a single field against the expected value.
1073
+ */
1074
+ private evaluateField;
1075
+ /**
1076
+ * Exact equality comparison.
1077
+ */
1078
+ private compareExact;
1079
+ /**
1080
+ * Numeric comparison with absolute or relative tolerance.
1081
+ */
1082
+ private compareNumericTolerance;
1083
+ /**
1084
+ * Date comparison with format normalization.
1085
+ */
1086
+ private compareDate;
1087
+ /**
1088
+ * Aggregate field results using configured strategy.
1089
+ */
1090
+ private aggregateResults;
1091
+ }
946
1092
  interface EvaluatorFactory {
947
1093
  create(config: EvaluatorConfig, context: EvaluationContext): Evaluator;
948
1094
  }
@@ -963,6 +1109,45 @@ declare class CompositeEvaluator implements Evaluator {
963
1109
  private runCodeAggregator;
964
1110
  private runLlmAggregator;
965
1111
  }
1112
+ interface LatencyEvaluatorOptions {
1113
+ readonly config: LatencyEvaluatorConfig;
1114
+ }
1115
+ /**
1116
+ * Evaluator that checks execution duration against a threshold.
1117
+ * Uses traceSummary.durationMs from the evaluation context.
1118
+ */
1119
+ declare class LatencyEvaluator implements Evaluator {
1120
+ readonly kind = "latency";
1121
+ private readonly config;
1122
+ constructor(options: LatencyEvaluatorOptions);
1123
+ evaluate(context: EvaluationContext): EvaluationScore;
1124
+ }
1125
+ interface CostEvaluatorOptions {
1126
+ readonly config: CostEvaluatorConfig;
1127
+ }
1128
+ /**
1129
+ * Evaluator that checks execution cost against a budget.
1130
+ * Uses traceSummary.costUsd from the evaluation context.
1131
+ */
1132
+ declare class CostEvaluator implements Evaluator {
1133
+ readonly kind = "cost";
1134
+ private readonly config;
1135
+ constructor(options: CostEvaluatorOptions);
1136
+ evaluate(context: EvaluationContext): EvaluationScore;
1137
+ }
1138
+ interface TokenUsageEvaluatorOptions {
1139
+ readonly config: TokenUsageEvaluatorConfig;
1140
+ }
1141
+ /**
1142
+ * Evaluator that checks provider-reported token usage against configured limits.
1143
+ * Uses traceSummary.tokenUsage from the evaluation context.
1144
+ */
1145
+ declare class TokenUsageEvaluator implements Evaluator {
1146
+ readonly kind = "token_usage";
1147
+ private readonly config;
1148
+ constructor(options: TokenUsageEvaluatorOptions);
1149
+ evaluate(context: EvaluationContext): EvaluationScore;
1150
+ }
966
1151
 
967
1152
  type MaybePromise<T> = T | Promise<T>;
968
1153
  interface EvaluationCache {
@@ -979,7 +1164,6 @@ interface RunEvalCaseOptions {
979
1164
  readonly now?: () => Date;
980
1165
  readonly maxRetries?: number;
981
1166
  readonly agentTimeoutMs?: number;
982
- readonly promptDumpDir?: string;
983
1167
  readonly cache?: EvaluationCache;
984
1168
  readonly useCache?: boolean;
985
1169
  readonly signal?: AbortSignal;
@@ -1003,7 +1187,6 @@ interface RunEvaluationOptions {
1003
1187
  readonly evaluators?: Partial<Record<string, Evaluator>>;
1004
1188
  readonly maxRetries?: number;
1005
1189
  readonly agentTimeoutMs?: number;
1006
- readonly promptDumpDir?: string;
1007
1190
  readonly cache?: EvaluationCache;
1008
1191
  readonly useCache?: boolean;
1009
1192
  readonly now?: () => Date;
@@ -1028,9 +1211,37 @@ interface GenerateRubricsOptions {
1028
1211
  */
1029
1212
  declare function generateRubrics(options: GenerateRubricsOptions): Promise<readonly RubricItem[]>;
1030
1213
 
1214
+ /**
1215
+ * Payload received by code judges via stdin.
1216
+ * All properties use camelCase for TypeScript ergonomics.
1217
+ */
1218
+ interface CodeJudgePayload {
1219
+ readonly question: string;
1220
+ readonly expectedOutcome: string;
1221
+ readonly expectedMessages: readonly JsonObject[];
1222
+ readonly referenceAnswer?: string;
1223
+ readonly candidateAnswer: string;
1224
+ readonly outputMessages?: readonly OutputMessage[] | null;
1225
+ readonly guidelineFiles: readonly string[];
1226
+ readonly inputFiles: readonly string[];
1227
+ readonly inputMessages: readonly TestMessage[];
1228
+ readonly traceSummary?: TraceSummary | null;
1229
+ readonly config?: JsonObject | null;
1230
+ }
1231
+ /**
1232
+ * Parse stdin JSON (snake_case) into typed camelCase object.
1233
+ * Use this in TypeScript code judges to get type-safe, idiomatic input.
1234
+ */
1235
+ declare function parseCodeJudgePayload(payload: string): CodeJudgePayload;
1236
+ /**
1237
+ * Convenience helper that reads stdin and parses it.
1238
+ * Equivalent to: parseCodeJudgePayload(readFileSync(0, 'utf8'))
1239
+ */
1240
+ declare function readCodeJudgePayload(): CodeJudgePayload;
1241
+
1031
1242
  type AgentKernel = {
1032
1243
  status: string;
1033
1244
  };
1034
1245
  declare function createAgentKernel(): AgentKernel;
1035
1246
 
1036
- export { type AgentKernel, type AnthropicResolvedConfig, type AssistantTestMessage, type AzureResolvedConfig, type ChildEvaluatorResult, type CliResolvedConfig, CodeEvaluator, type CodeEvaluatorConfig, type CodeEvaluatorOptions, type CompositeAggregatorConfig, CompositeEvaluator, type CompositeEvaluatorConfig, type CompositeEvaluatorOptions, DEFAULT_EXPLORATION_TOOLS, type EnsureSubagentsOptions, type EnsureSubagentsResult, type EnvLookup, type EvalCase, type EvaluationCache, type EvaluationContext, type EvaluationResult, type EvaluationScore, type EvaluationVerdict, type Evaluator, type EvaluatorConfig, type EvaluatorFactory, type EvaluatorKind, type EvaluatorResult, type ExecutionMetrics, type GeminiResolvedConfig, type GenerateRubricsOptions, type JsonObject, type JsonPrimitive, type JsonValue, LlmJudgeEvaluator, type LlmJudgeEvaluatorConfig, type LlmJudgeEvaluatorOptions, type MockResolvedConfig, type PiCodingAgentResolvedConfig, type ProgressEvent, type PromptInputs, type Provider, type ProviderKind, type ProviderRequest, type ProviderResponse, type ProviderTokenUsage, type ResolvedTarget, type RubricItem, type RunEvalCaseOptions, type RunEvaluationOptions, type SystemTestMessage, TEST_MESSAGE_ROLES, type TargetDefinition, type TestMessage, type TestMessageContent, type TestMessageRole, type TokenUsage, type ToolTestMessage, ToolTrajectoryEvaluator, type ToolTrajectoryEvaluatorConfig, type ToolTrajectoryEvaluatorOptions, type ToolTrajectoryExpectedItem, type TraceSummary, type UserTestMessage, type VSCodeResolvedConfig, avgToolDurationMs, buildDirectoryChain, buildPromptInputs, buildSearchRoots, computeTraceSummary, consumeCodexLogEntries, consumePiLogEntries, createAgentKernel, createProvider, ensureVSCodeSubagents, explorationRatio, extractCodeBlocks, fileExists, findGitRoot, generateRubrics, getHitCount, isEvaluatorKind, isGuidelineFile, isJsonObject, isJsonValue, isTestMessage, isTestMessageRole, listTargetNames, loadEvalCases, mergeExecutionMetrics, normalizeLineEndings, readJsonFile, readTargetDefinitions, readTestSuiteMetadata, readTextFile, resolveAndCreateProvider, resolveFileReference, resolveTargetDefinition, runEvalCase, runEvaluation, subscribeToCodexLogEntries, subscribeToPiLogEntries, tokensPerTool };
1247
+ export { type AgentKernel, type AnthropicResolvedConfig, type AssistantTestMessage, type AzureResolvedConfig, type ChildEvaluatorResult, type ClaudeCodeResolvedConfig, type CliResolvedConfig, CodeEvaluator, type CodeEvaluatorConfig, type CodeEvaluatorOptions, type CodeJudgePayload, type CompositeAggregatorConfig, CompositeEvaluator, type CompositeEvaluatorConfig, type CompositeEvaluatorOptions, CostEvaluator, type CostEvaluatorConfig, type CostEvaluatorOptions, DEFAULT_EXPLORATION_TOOLS, type EnsureSubagentsOptions, type EnsureSubagentsResult, type EnvLookup, type EvalCase, type EvaluationCache, type EvaluationContext, type EvaluationResult, type EvaluationScore, type EvaluationVerdict, type Evaluator, type EvaluatorConfig, type EvaluatorFactory, type EvaluatorKind, type EvaluatorResult, type ExecutionMetrics, FieldAccuracyEvaluator, type FieldAccuracyEvaluatorConfig, type FieldAccuracyEvaluatorOptions, type FieldAggregationType, type FieldConfig, type FieldMatchType, type GeminiResolvedConfig, type GenerateRubricsOptions, type JsonObject, type JsonPrimitive, type JsonValue, LatencyEvaluator, type LatencyEvaluatorConfig, type LatencyEvaluatorOptions, LlmJudgeEvaluator, type LlmJudgeEvaluatorConfig, type LlmJudgeEvaluatorOptions, type MockResolvedConfig, type PiCodingAgentResolvedConfig, type ProgressEvent, type PromptInputs, type Provider, type ProviderKind, type ProviderRequest, type ProviderResponse, type ProviderTokenUsage, type ResolvedTarget, type RubricItem, type RunEvalCaseOptions, type RunEvaluationOptions, type SystemTestMessage, TEST_MESSAGE_ROLES, type TargetDefinition, type TestMessage, type TestMessageContent, type TestMessageRole, type TokenUsage, TokenUsageEvaluator, type TokenUsageEvaluatorConfig, type TokenUsageEvaluatorOptions, type ToolTestMessage, ToolTrajectoryEvaluator, type ToolTrajectoryEvaluatorConfig, type ToolTrajectoryEvaluatorOptions, type ToolTrajectoryExpectedItem, type TraceSummary, type UserTestMessage, type VSCodeResolvedConfig, avgToolDurationMs, buildDirectoryChain, buildPromptInputs, buildSearchRoots, computeTraceSummary, consumeClaudeCodeLogEntries, consumeCodexLogEntries, consumePiLogEntries, createAgentKernel, createProvider, ensureVSCodeSubagents, explorationRatio, extractCodeBlocks, fileExists, findGitRoot, generateRubrics, getHitCount, isEvaluatorKind, isGuidelineFile, isJsonObject, isJsonValue, isTestMessage, isTestMessageRole, listTargetNames, loadEvalCases, mergeExecutionMetrics, normalizeLineEndings, parseCodeJudgePayload, readCodeJudgePayload, readJsonFile, readTargetDefinitions, readTestSuiteMetadata, readTextFile, resolveAndCreateProvider, resolveFileReference, resolveTargetDefinition, runEvalCase, runEvaluation, subscribeToClaudeCodeLogEntries, subscribeToCodexLogEntries, subscribeToPiLogEntries, tokensPerTool };