@agentv/core 4.25.2-next.1 → 4.25.4-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/index.cjs CHANGED
@@ -5351,7 +5351,6 @@ var init_code_grader = __esm({
5351
5351
  const rawParsed = parseJsonSafe(stdout);
5352
5352
  const parsed = rawParsed != null && typeof rawParsed === "object" && !Array.isArray(rawParsed) ? rawParsed : void 0;
5353
5353
  const passed = exitCode === 0;
5354
- const score = parsed != null ? clampScore(typeof parsed.score === "number" ? parsed.score : 0) : passed ? 1 : 0;
5355
5354
  const assertions = parsed != null && Array.isArray(parsed?.assertions) ? parsed.assertions.filter(
5356
5355
  (a) => typeof a === "object" && a !== null && typeof a.text === "string"
5357
5356
  ).map((a) => ({
@@ -5359,6 +5358,9 @@ var init_code_grader = __esm({
5359
5358
  passed: Boolean(a.passed),
5360
5359
  ...typeof a.evidence === "string" ? { evidence: a.evidence } : {}
5361
5360
  })) : parsed == null ? [{ text: stdout.trim() || (passed ? "exit 0" : `exit ${exitCode}`), passed }] : [];
5361
+ const score = parsed != null ? clampScore(
5362
+ typeof parsed.score === "number" ? parsed.score : assertions.length > 0 ? assertions.filter((a) => a.passed).length / assertions.length : 0
5363
+ ) : passed ? 1 : 0;
5362
5364
  const details = parsed?.details && typeof parsed.details === "object" && !Array.isArray(parsed.details) ? parsed.details : void 0;
5363
5365
  const proxyUsage = getProxyUsage?.();
5364
5366
  const graderRawRequest = {
@@ -8712,11 +8714,12 @@ async function invokePiAi(options) {
8712
8714
  const aggregateUsage = { input: 0, output: 0, cacheRead: 0, cost: 0 };
8713
8715
  let stepCount = 0;
8714
8716
  let toolCallCount = 0;
8715
- let result = await withRetry(
8716
- () => (0, import_pi_ai.complete)(model, ctx, callOptions),
8717
- retryConfig,
8718
- request.signal
8719
- );
8717
+ const callPi = async () => {
8718
+ const r = await (0, import_pi_ai.complete)(model, ctx, callOptions);
8719
+ if (r.stopReason === "error") throw piErrorFromResult(r);
8720
+ return r;
8721
+ };
8722
+ let result = await withRetry(callPi, retryConfig, request.signal);
8720
8723
  ctx.messages.push(result);
8721
8724
  stepCount = 1;
8722
8725
  accumulateUsage(aggregateUsage, result.usage);
@@ -8751,11 +8754,7 @@ async function invokePiAi(options) {
8751
8754
  timestamp: Date.now()
8752
8755
  });
8753
8756
  }
8754
- result = await withRetry(
8755
- () => (0, import_pi_ai.complete)(model, ctx, callOptions),
8756
- retryConfig,
8757
- request.signal
8758
- );
8757
+ result = await withRetry(callPi, retryConfig, request.signal);
8759
8758
  ctx.messages.push(result);
8760
8759
  stepCount += 1;
8761
8760
  accumulateUsage(aggregateUsage, result.usage);
@@ -9018,6 +9017,18 @@ function calculateRetryDelay(attempt, config) {
9018
9017
  async function sleep(ms) {
9019
9018
  return new Promise((resolve) => setTimeout(resolve, ms));
9020
9019
  }
9020
+ function piErrorFromResult(r) {
9021
+ const raw = r.errorMessage ?? "pi-ai call failed with no error message";
9022
+ const statusMatch = raw.match(/^(\d{3})\b\s*(.*)$/);
9023
+ if (statusMatch) {
9024
+ const status = statusMatch[1];
9025
+ const rest = statusMatch[2] || raw;
9026
+ const err = new Error(`pi-ai call failed: HTTP ${status} ${rest}`);
9027
+ err.status = Number.parseInt(status, 10);
9028
+ return err;
9029
+ }
9030
+ return new Error(`pi-ai call failed: ${raw}`);
9031
+ }
9021
9032
  async function withRetry(fn, retryConfig, signal) {
9022
9033
  const config = {
9023
9034
  maxRetries: retryConfig?.maxRetries ?? 3,
@@ -14899,17 +14910,16 @@ function findDeprecatedCamelCaseTargetWarnings(target, location) {
14899
14910
  );
14900
14911
  return warnings;
14901
14912
  }
14902
- function normalizeAzureApiVersion(value, apiFormat) {
14903
- const defaultVersion = apiFormat === "responses" ? DEFAULT_AZURE_RESPONSES_API_VERSION : DEFAULT_AZURE_API_VERSION;
14913
+ function normalizeAzureApiVersion(value) {
14904
14914
  if (!value) {
14905
- return defaultVersion;
14915
+ return DEFAULT_AZURE_API_VERSION;
14906
14916
  }
14907
14917
  const trimmed = value.trim();
14908
14918
  if (trimmed.length === 0) {
14909
- return defaultVersion;
14919
+ return DEFAULT_AZURE_API_VERSION;
14910
14920
  }
14911
14921
  const withoutPrefix = trimmed.replace(/^api[-_]?version\s*=\s*/i, "").trim();
14912
- return withoutPrefix.length > 0 ? withoutPrefix : defaultVersion;
14922
+ return withoutPrefix.length > 0 ? withoutPrefix : DEFAULT_AZURE_API_VERSION;
14913
14923
  }
14914
14924
  function resolveRetryConfig(target) {
14915
14925
  const maxRetries = resolveOptionalNumber(target.max_retries, `${target.name} max retries`);
@@ -15166,6 +15176,11 @@ function normalizeOpenAIBaseUrl(value) {
15166
15176
  return trimmed.endsWith("/v1") ? trimmed : `${trimmed}/v1`;
15167
15177
  }
15168
15178
  function resolveAzureConfig(target, env) {
15179
+ if (target.api_format !== void 0) {
15180
+ throw new Error(
15181
+ `The 'api_format' field is no longer supported on Azure targets ('${target.name}'). AgentV always uses Azure's Responses API. If your deployment only exposes /chat/completions, use 'provider: openai' with a deployment-scoped 'base_url' instead. See docs/targets/llm-providers for details.`
15182
+ );
15183
+ }
15169
15184
  const endpointSource = target.endpoint ?? target.resource;
15170
15185
  const apiKeySource = target.api_key;
15171
15186
  const deploymentSource = target.deployment ?? target.model;
@@ -15175,13 +15190,11 @@ function resolveAzureConfig(target, env) {
15175
15190
  const resourceName = resolveString(endpointSource, env, `${target.name} endpoint`);
15176
15191
  const apiKey = resolveString(apiKeySource, env, `${target.name} api key`);
15177
15192
  const deploymentName = resolveString(deploymentSource, env, `${target.name} deployment`);
15178
- const apiFormat = resolveApiFormat(target, env, target.name);
15179
15193
  const version = normalizeAzureApiVersion(
15180
15194
  resolveOptionalString(versionSource, env, `${target.name} api version`, {
15181
15195
  allowLiteral: true,
15182
15196
  optionalEnv: true
15183
- }),
15184
- apiFormat
15197
+ })
15185
15198
  );
15186
15199
  const temperature = resolveOptionalNumber(temperatureSource, `${target.name} temperature`);
15187
15200
  const maxOutputTokens = resolveOptionalNumber(
@@ -15194,7 +15207,6 @@ function resolveAzureConfig(target, env) {
15194
15207
  deploymentName,
15195
15208
  apiKey,
15196
15209
  version,
15197
- apiFormat,
15198
15210
  temperature,
15199
15211
  maxOutputTokens,
15200
15212
  retry
@@ -16060,7 +16072,7 @@ function resolveOptionalNumberArray(source, description) {
16060
16072
  }
16061
16073
  return resolved.length > 0 ? resolved : void 0;
16062
16074
  }
16063
- var import_node_fs11, import_node_os9, import_node_path26, import_zod4, CliHealthcheckHttpInputSchema, CliHealthcheckCommandInputSchema, CliHealthcheckInputSchema, CliTargetInputSchema, CliHealthcheckHttpSchema, CliHealthcheckCommandSchema, CliHealthcheckSchema, CliTargetConfigSchema, CLI_PLACEHOLDERS, DEPRECATED_TARGET_CAMEL_CASE_FIELDS, DEPRECATED_HEALTHCHECK_CAMEL_CASE_FIELDS, COMMON_TARGET_SETTINGS, USE_TARGET_ENV_PATTERN, BASE_TARGET_SCHEMA, DEFAULT_AZURE_API_VERSION, DEFAULT_AZURE_RESPONSES_API_VERSION, DEFAULT_OPENAI_BASE_URL, cliErrorMap;
16075
+ var import_node_fs11, import_node_os9, import_node_path26, import_zod4, CliHealthcheckHttpInputSchema, CliHealthcheckCommandInputSchema, CliHealthcheckInputSchema, CliTargetInputSchema, CliHealthcheckHttpSchema, CliHealthcheckCommandSchema, CliHealthcheckSchema, CliTargetConfigSchema, CLI_PLACEHOLDERS, DEPRECATED_TARGET_CAMEL_CASE_FIELDS, DEPRECATED_HEALTHCHECK_CAMEL_CASE_FIELDS, COMMON_TARGET_SETTINGS, USE_TARGET_ENV_PATTERN, BASE_TARGET_SCHEMA, DEFAULT_AZURE_API_VERSION, DEFAULT_OPENAI_BASE_URL, cliErrorMap;
16064
16076
  var init_targets = __esm({
16065
16077
  "src/evaluation/providers/targets.ts"() {
16066
16078
  "use strict";
@@ -16195,8 +16207,7 @@ var init_targets = __esm({
16195
16207
  subagent_mode_allowed: import_zod4.z.boolean().optional(),
16196
16208
  fallback_targets: import_zod4.z.array(import_zod4.z.string().min(1)).optional()
16197
16209
  }).passthrough();
16198
- DEFAULT_AZURE_API_VERSION = "2024-12-01-preview";
16199
- DEFAULT_AZURE_RESPONSES_API_VERSION = "v1";
16210
+ DEFAULT_AZURE_API_VERSION = "v1";
16200
16211
  DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
16201
16212
  cliErrorMap = (issue, ctx) => {
16202
16213
  if (issue.code === import_zod4.z.ZodIssueCode.unrecognized_keys) {