@agentv/core 2.18.4 → 3.0.0-next.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/agentv-provider-5CJVBBGG.js +7 -0
- package/dist/agentv-provider-5CJVBBGG.js.map +1 -0
- package/dist/{chunk-V42NUK73.js → chunk-CASGWWOU.js} +56 -20
- package/dist/chunk-CASGWWOU.js.map +1 -0
- package/dist/chunk-XBGLLO22.js +65 -0
- package/dist/chunk-XBGLLO22.js.map +1 -0
- package/dist/evaluation/validation/index.cjs +31 -14
- package/dist/evaluation/validation/index.cjs.map +1 -1
- package/dist/evaluation/validation/index.js +19 -10
- package/dist/evaluation/validation/index.js.map +1 -1
- package/dist/index.cjs +5188 -3879
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +377 -137
- package/dist/index.d.ts +377 -137
- package/dist/index.js +6974 -5780
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/dist/chunk-V42NUK73.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/evaluation/providers/agentv-provider.ts
|
|
2
|
+
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
3
|
+
import { createAzure } from "@ai-sdk/azure";
|
|
4
|
+
import { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
5
|
+
import { createOpenAI } from "@ai-sdk/openai";
|
|
6
|
+
function parseModelString(model) {
|
|
7
|
+
const colonIndex = model.indexOf(":");
|
|
8
|
+
if (colonIndex === -1) {
|
|
9
|
+
throw new Error(
|
|
10
|
+
`Invalid model string "${model}". Expected format "provider:model" (e.g., "openai:gpt-5-mini")`
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
provider: model.slice(0, colonIndex),
|
|
15
|
+
modelName: model.slice(colonIndex + 1)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function createLanguageModel(modelString) {
|
|
19
|
+
const { provider, modelName } = parseModelString(modelString);
|
|
20
|
+
switch (provider) {
|
|
21
|
+
case "openai":
|
|
22
|
+
return createOpenAI()(modelName);
|
|
23
|
+
case "anthropic":
|
|
24
|
+
return createAnthropic()(modelName);
|
|
25
|
+
case "azure":
|
|
26
|
+
return createAzure()(modelName);
|
|
27
|
+
case "google":
|
|
28
|
+
return createGoogleGenerativeAI()(modelName);
|
|
29
|
+
default:
|
|
30
|
+
throw new Error(
|
|
31
|
+
`Unsupported AI SDK provider "${provider}" in model string "${modelString}". Supported providers: openai, anthropic, azure, google`
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
var AgentvProvider = class {
|
|
36
|
+
id;
|
|
37
|
+
kind = "agentv";
|
|
38
|
+
targetName;
|
|
39
|
+
model;
|
|
40
|
+
constructor(targetName, config) {
|
|
41
|
+
this.id = `agentv:${targetName}`;
|
|
42
|
+
this.targetName = targetName;
|
|
43
|
+
this.model = createLanguageModel(config.model);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Direct invoke is not supported for the agentv provider.
|
|
47
|
+
* Use asLanguageModel() with generateText() instead.
|
|
48
|
+
*/
|
|
49
|
+
async invoke(_request) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
"AgentvProvider does not support direct invoke(). Use asLanguageModel() with generateText() instead."
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the resolved AI SDK LanguageModel for use with generateText/generateObject.
|
|
56
|
+
*/
|
|
57
|
+
asLanguageModel() {
|
|
58
|
+
return this.model;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
AgentvProvider
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=chunk-XBGLLO22.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/evaluation/providers/agentv-provider.ts"],"sourcesContent":["import { createAnthropic } from '@ai-sdk/anthropic';\nimport { createAzure } from '@ai-sdk/azure';\nimport { createGoogleGenerativeAI } from '@ai-sdk/google';\nimport { createOpenAI } from '@ai-sdk/openai';\nimport type { LanguageModel } from 'ai';\n\nimport type { AgentVResolvedConfig } from './targets.js';\nimport type { Provider, ProviderRequest, ProviderResponse } from './types.js';\n\n/**\n * Parse a model string like \"openai:gpt-5-mini\" into provider prefix and model name.\n */\nfunction parseModelString(model: string): { provider: string; modelName: string } {\n const colonIndex = model.indexOf(':');\n if (colonIndex === -1) {\n throw new Error(\n `Invalid model string \"${model}\". Expected format \"provider:model\" (e.g., \"openai:gpt-5-mini\")`,\n );\n }\n return {\n provider: model.slice(0, colonIndex),\n modelName: model.slice(colonIndex + 1),\n };\n}\n\n/**\n * Create a LanguageModel from a model string using the appropriate AI SDK provider.\n */\nfunction createLanguageModel(modelString: string): LanguageModel {\n const { provider, modelName } = parseModelString(modelString);\n\n switch (provider) {\n case 'openai':\n // Cast: @ai-sdk/openai may return LanguageModelV3 while the rest of the\n // codebase uses LanguageModelV2. The runtime API is compatible.\n return createOpenAI()(modelName) as unknown as LanguageModel;\n case 'anthropic':\n return createAnthropic()(modelName);\n case 'azure':\n return createAzure()(modelName);\n case 'google':\n return createGoogleGenerativeAI()(modelName);\n default:\n throw new Error(\n `Unsupported AI SDK provider \"${provider}\" in model string \"${modelString}\". Supported providers: openai, anthropic, azure, google`,\n );\n }\n}\n\n/**\n * AgentV built-in provider for LLM grader evaluation.\n *\n * Resolves an AI SDK model string (e.g., \"openai:gpt-5-mini\", \"anthropic:claude-sonnet-4-20250514\")\n * to a Vercel AI SDK LanguageModel by parsing the provider prefix and creating the appropriate\n * AI SDK provider directly. This provider is used exclusively for grader evaluation — it does not\n * support direct agent invocation.\n *\n * Usage: `--grader-target agentv --model openai:gpt-5-mini`\n */\nexport class AgentvProvider implements Provider {\n readonly id: string;\n readonly kind = 'agentv' as const;\n readonly targetName: string;\n\n private readonly model: LanguageModel;\n\n constructor(targetName: string, config: AgentVResolvedConfig) {\n this.id = `agentv:${targetName}`;\n this.targetName = targetName;\n this.model = createLanguageModel(config.model);\n }\n\n /**\n * Direct invoke is not supported for the agentv provider.\n * Use asLanguageModel() with generateText() instead.\n */\n async invoke(_request: ProviderRequest): Promise<ProviderResponse> {\n throw new Error(\n 'AgentvProvider does not support direct invoke(). Use asLanguageModel() with generateText() instead.',\n );\n }\n\n /**\n * Returns the resolved AI SDK LanguageModel for use with generateText/generateObject.\n */\n asLanguageModel(): LanguageModel {\n return this.model;\n }\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,gCAAgC;AACzC,SAAS,oBAAoB;AAS7B,SAAS,iBAAiB,OAAwD;AAChF,QAAM,aAAa,MAAM,QAAQ,GAAG;AACpC,MAAI,eAAe,IAAI;AACrB,UAAM,IAAI;AAAA,MACR,yBAAyB,KAAK;AAAA,IAChC;AAAA,EACF;AACA,SAAO;AAAA,IACL,UAAU,MAAM,MAAM,GAAG,UAAU;AAAA,IACnC,WAAW,MAAM,MAAM,aAAa,CAAC;AAAA,EACvC;AACF;AAKA,SAAS,oBAAoB,aAAoC;AAC/D,QAAM,EAAE,UAAU,UAAU,IAAI,iBAAiB,WAAW;AAE5D,UAAQ,UAAU;AAAA,IAChB,KAAK;AAGH,aAAO,aAAa,EAAE,SAAS;AAAA,IACjC,KAAK;AACH,aAAO,gBAAgB,EAAE,SAAS;AAAA,IACpC,KAAK;AACH,aAAO,YAAY,EAAE,SAAS;AAAA,IAChC,KAAK;AACH,aAAO,yBAAyB,EAAE,SAAS;AAAA,IAC7C;AACE,YAAM,IAAI;AAAA,QACR,gCAAgC,QAAQ,sBAAsB,WAAW;AAAA,MAC3E;AAAA,EACJ;AACF;AAYO,IAAM,iBAAN,MAAyC;AAAA,EACrC;AAAA,EACA,OAAO;AAAA,EACP;AAAA,EAEQ;AAAA,EAEjB,YAAY,YAAoB,QAA8B;AAC5D,SAAK,KAAK,UAAU,UAAU;AAC9B,SAAK,aAAa;AAClB,SAAK,QAAQ,oBAAoB,OAAO,KAAK;AAAA,EAC/C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,UAAsD;AACjE,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,kBAAiC;AAC/B,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
|
@@ -111,6 +111,8 @@ var import_yaml2 = require("yaml");
|
|
|
111
111
|
var TEST_MESSAGE_ROLE_VALUES = ["system", "user", "assistant", "tool"];
|
|
112
112
|
var TEST_MESSAGE_ROLE_SET = new Set(TEST_MESSAGE_ROLE_VALUES);
|
|
113
113
|
var EVALUATOR_KIND_VALUES = [
|
|
114
|
+
"code-grader",
|
|
115
|
+
"llm-grader",
|
|
114
116
|
"code-judge",
|
|
115
117
|
"llm-judge",
|
|
116
118
|
"rubric",
|
|
@@ -121,7 +123,7 @@ var EVALUATOR_KIND_VALUES = [
|
|
|
121
123
|
"cost",
|
|
122
124
|
"token-usage",
|
|
123
125
|
"execution-metrics",
|
|
124
|
-
"
|
|
126
|
+
"skill-trigger",
|
|
125
127
|
"contains",
|
|
126
128
|
"contains-any",
|
|
127
129
|
"contains-all",
|
|
@@ -133,7 +135,8 @@ var EVALUATOR_KIND_VALUES = [
|
|
|
133
135
|
"regex",
|
|
134
136
|
"is-json",
|
|
135
137
|
"equals",
|
|
136
|
-
"rubrics"
|
|
138
|
+
"rubrics",
|
|
139
|
+
"inline-assert"
|
|
137
140
|
];
|
|
138
141
|
var EVALUATOR_KIND_SET = new Set(EVALUATOR_KIND_VALUES);
|
|
139
142
|
function isEvaluatorKind(value) {
|
|
@@ -332,7 +335,7 @@ async function validateEvalFile(filePath) {
|
|
|
332
335
|
});
|
|
333
336
|
}
|
|
334
337
|
}
|
|
335
|
-
const assertField = evalCase.assert;
|
|
338
|
+
const assertField = evalCase.assertions ?? evalCase.assert;
|
|
336
339
|
if (assertField !== void 0) {
|
|
337
340
|
validateAssertArray(assertField, location, absolutePath, errors);
|
|
338
341
|
}
|
|
@@ -503,14 +506,14 @@ function validateAssertArray(assertField, parentLocation, filePath, errors) {
|
|
|
503
506
|
errors.push({
|
|
504
507
|
severity: "warning",
|
|
505
508
|
filePath,
|
|
506
|
-
location: `${parentLocation}.
|
|
507
|
-
message: "'
|
|
509
|
+
location: `${parentLocation}.assertions`,
|
|
510
|
+
message: "'assertions' must be an array of assertion objects."
|
|
508
511
|
});
|
|
509
512
|
return;
|
|
510
513
|
}
|
|
511
514
|
for (let i = 0; i < assertField.length; i++) {
|
|
512
515
|
const item = assertField[i];
|
|
513
|
-
const location = `${parentLocation}.
|
|
516
|
+
const location = `${parentLocation}.assertions[${i}]`;
|
|
514
517
|
if (!isObject(item)) {
|
|
515
518
|
errors.push({
|
|
516
519
|
severity: "warning",
|
|
@@ -671,7 +674,9 @@ var CliTargetInputSchema = import_zod.z.object({
|
|
|
671
674
|
keep_output_files: import_zod.z.boolean().optional(),
|
|
672
675
|
keepOutputFiles: import_zod.z.boolean().optional(),
|
|
673
676
|
// Common target fields
|
|
677
|
+
grader_target: import_zod.z.string().optional(),
|
|
674
678
|
judge_target: import_zod.z.string().optional(),
|
|
679
|
+
// backward compat
|
|
675
680
|
workers: import_zod.z.number().int().min(1).optional(),
|
|
676
681
|
provider_batching: import_zod.z.boolean().optional(),
|
|
677
682
|
providerBatching: import_zod.z.boolean().optional()
|
|
@@ -711,7 +716,9 @@ var CLI_PLACEHOLDERS = /* @__PURE__ */ new Set([
|
|
|
711
716
|
var BASE_TARGET_SCHEMA = import_zod.z.object({
|
|
712
717
|
name: import_zod.z.string().min(1, "target name is required"),
|
|
713
718
|
provider: import_zod.z.string().min(1, "provider is required"),
|
|
719
|
+
grader_target: import_zod.z.string().optional(),
|
|
714
720
|
judge_target: import_zod.z.string().optional(),
|
|
721
|
+
// backward compat
|
|
715
722
|
workers: import_zod.z.number().int().min(1).optional(),
|
|
716
723
|
workspace_template: import_zod.z.string().optional(),
|
|
717
724
|
workspaceTemplate: import_zod.z.string().optional()
|
|
@@ -728,10 +735,13 @@ var KNOWN_PROVIDERS = [
|
|
|
728
735
|
"pi-coding-agent",
|
|
729
736
|
"pi-agent-sdk",
|
|
730
737
|
"claude",
|
|
738
|
+
"claude-cli",
|
|
739
|
+
"claude-sdk",
|
|
731
740
|
"cli",
|
|
732
741
|
"mock",
|
|
733
742
|
"vscode",
|
|
734
|
-
"vscode-insiders"
|
|
743
|
+
"vscode-insiders",
|
|
744
|
+
"agentv"
|
|
735
745
|
];
|
|
736
746
|
var PROVIDER_ALIASES = [
|
|
737
747
|
"azure-openai",
|
|
@@ -750,8 +760,6 @@ var PROVIDER_ALIASES = [
|
|
|
750
760
|
// alias for "pi-coding-agent"
|
|
751
761
|
"claude-code",
|
|
752
762
|
// alias for "claude" (legacy)
|
|
753
|
-
"claude-sdk",
|
|
754
|
-
// alias for "claude"
|
|
755
763
|
"openai",
|
|
756
764
|
// legacy/future support
|
|
757
765
|
"bedrock",
|
|
@@ -953,6 +961,7 @@ function getKnownSettings(provider) {
|
|
|
953
961
|
return COPILOT_CLI_SETTINGS;
|
|
954
962
|
case "claude":
|
|
955
963
|
case "claude-code":
|
|
964
|
+
case "claude-cli":
|
|
956
965
|
case "claude-sdk":
|
|
957
966
|
return CLAUDE_SETTINGS;
|
|
958
967
|
case "vscode":
|
|
@@ -972,7 +981,15 @@ function validateUnknownSettings(target, provider, absolutePath, location, error
|
|
|
972
981
|
if (!knownSettings) {
|
|
973
982
|
return;
|
|
974
983
|
}
|
|
975
|
-
const baseFields = /* @__PURE__ */ new Set([
|
|
984
|
+
const baseFields = /* @__PURE__ */ new Set([
|
|
985
|
+
"name",
|
|
986
|
+
"provider",
|
|
987
|
+
"grader_target",
|
|
988
|
+
"judge_target",
|
|
989
|
+
"workers",
|
|
990
|
+
"$schema",
|
|
991
|
+
"targets"
|
|
992
|
+
]);
|
|
976
993
|
for (const key of Object.keys(target)) {
|
|
977
994
|
if (removedTargetFields.has(key)) {
|
|
978
995
|
errors.push({
|
|
@@ -1179,13 +1196,13 @@ async function validateTargetsFile(filePath) {
|
|
|
1179
1196
|
if (typeof provider === "string") {
|
|
1180
1197
|
validateUnknownSettings(target, provider, absolutePath, location, errors);
|
|
1181
1198
|
}
|
|
1182
|
-
const
|
|
1183
|
-
if (
|
|
1199
|
+
const graderTarget = target.grader_target ?? target.judge_target;
|
|
1200
|
+
if (graderTarget !== void 0 && typeof graderTarget !== "string") {
|
|
1184
1201
|
errors.push({
|
|
1185
1202
|
severity: "error",
|
|
1186
1203
|
filePath: absolutePath,
|
|
1187
|
-
location: `${location}.
|
|
1188
|
-
message: "Invalid '
|
|
1204
|
+
location: `${location}.grader_target`,
|
|
1205
|
+
message: "Invalid 'grader_target' field (must be a string)"
|
|
1189
1206
|
});
|
|
1190
1207
|
}
|
|
1191
1208
|
}
|