@agentv/core 4.25.3-next.1 → 4.25.5-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
@@ -8714,11 +8714,12 @@ async function invokePiAi(options) {
8714
8714
  const aggregateUsage = { input: 0, output: 0, cacheRead: 0, cost: 0 };
8715
8715
  let stepCount = 0;
8716
8716
  let toolCallCount = 0;
8717
- let result = await withRetry(
8718
- () => (0, import_pi_ai.complete)(model, ctx, callOptions),
8719
- retryConfig,
8720
- request.signal
8721
- );
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);
8722
8723
  ctx.messages.push(result);
8723
8724
  stepCount = 1;
8724
8725
  accumulateUsage(aggregateUsage, result.usage);
@@ -8753,11 +8754,7 @@ async function invokePiAi(options) {
8753
8754
  timestamp: Date.now()
8754
8755
  });
8755
8756
  }
8756
- result = await withRetry(
8757
- () => (0, import_pi_ai.complete)(model, ctx, callOptions),
8758
- retryConfig,
8759
- request.signal
8760
- );
8757
+ result = await withRetry(callPi, retryConfig, request.signal);
8761
8758
  ctx.messages.push(result);
8762
8759
  stepCount += 1;
8763
8760
  accumulateUsage(aggregateUsage, result.usage);
@@ -9020,6 +9017,18 @@ function calculateRetryDelay(attempt, config) {
9020
9017
  async function sleep(ms) {
9021
9018
  return new Promise((resolve) => setTimeout(resolve, ms));
9022
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
+ }
9023
9032
  async function withRetry(fn, retryConfig, signal) {
9024
9033
  const config = {
9025
9034
  maxRetries: retryConfig?.maxRetries ?? 3,
@@ -14901,17 +14910,16 @@ function findDeprecatedCamelCaseTargetWarnings(target, location) {
14901
14910
  );
14902
14911
  return warnings;
14903
14912
  }
14904
- function normalizeAzureApiVersion(value, apiFormat) {
14905
- const defaultVersion = apiFormat === "responses" ? DEFAULT_AZURE_RESPONSES_API_VERSION : DEFAULT_AZURE_API_VERSION;
14913
+ function normalizeAzureApiVersion(value) {
14906
14914
  if (!value) {
14907
- return defaultVersion;
14915
+ return DEFAULT_AZURE_API_VERSION;
14908
14916
  }
14909
14917
  const trimmed = value.trim();
14910
14918
  if (trimmed.length === 0) {
14911
- return defaultVersion;
14919
+ return DEFAULT_AZURE_API_VERSION;
14912
14920
  }
14913
14921
  const withoutPrefix = trimmed.replace(/^api[-_]?version\s*=\s*/i, "").trim();
14914
- return withoutPrefix.length > 0 ? withoutPrefix : defaultVersion;
14922
+ return withoutPrefix.length > 0 ? withoutPrefix : DEFAULT_AZURE_API_VERSION;
14915
14923
  }
14916
14924
  function resolveRetryConfig(target) {
14917
14925
  const maxRetries = resolveOptionalNumber(target.max_retries, `${target.name} max retries`);
@@ -15168,6 +15176,11 @@ function normalizeOpenAIBaseUrl(value) {
15168
15176
  return trimmed.endsWith("/v1") ? trimmed : `${trimmed}/v1`;
15169
15177
  }
15170
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
+ }
15171
15184
  const endpointSource = target.endpoint ?? target.resource;
15172
15185
  const apiKeySource = target.api_key;
15173
15186
  const deploymentSource = target.deployment ?? target.model;
@@ -15177,13 +15190,11 @@ function resolveAzureConfig(target, env) {
15177
15190
  const resourceName = resolveString(endpointSource, env, `${target.name} endpoint`);
15178
15191
  const apiKey = resolveString(apiKeySource, env, `${target.name} api key`);
15179
15192
  const deploymentName = resolveString(deploymentSource, env, `${target.name} deployment`);
15180
- const apiFormat = resolveApiFormat(target, env, target.name);
15181
15193
  const version = normalizeAzureApiVersion(
15182
15194
  resolveOptionalString(versionSource, env, `${target.name} api version`, {
15183
15195
  allowLiteral: true,
15184
15196
  optionalEnv: true
15185
- }),
15186
- apiFormat
15197
+ })
15187
15198
  );
15188
15199
  const temperature = resolveOptionalNumber(temperatureSource, `${target.name} temperature`);
15189
15200
  const maxOutputTokens = resolveOptionalNumber(
@@ -15196,7 +15207,6 @@ function resolveAzureConfig(target, env) {
15196
15207
  deploymentName,
15197
15208
  apiKey,
15198
15209
  version,
15199
- apiFormat,
15200
15210
  temperature,
15201
15211
  maxOutputTokens,
15202
15212
  retry
@@ -16062,7 +16072,7 @@ function resolveOptionalNumberArray(source, description) {
16062
16072
  }
16063
16073
  return resolved.length > 0 ? resolved : void 0;
16064
16074
  }
16065
- 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;
16066
16076
  var init_targets = __esm({
16067
16077
  "src/evaluation/providers/targets.ts"() {
16068
16078
  "use strict";
@@ -16197,8 +16207,7 @@ var init_targets = __esm({
16197
16207
  subagent_mode_allowed: import_zod4.z.boolean().optional(),
16198
16208
  fallback_targets: import_zod4.z.array(import_zod4.z.string().min(1)).optional()
16199
16209
  }).passthrough();
16200
- DEFAULT_AZURE_API_VERSION = "2024-12-01-preview";
16201
- DEFAULT_AZURE_RESPONSES_API_VERSION = "v1";
16210
+ DEFAULT_AZURE_API_VERSION = "v1";
16202
16211
  DEFAULT_OPENAI_BASE_URL = "https://api.openai.com/v1";
16203
16212
  cliErrorMap = (issue, ctx) => {
16204
16213
  if (issue.code === import_zod4.z.ZodIssueCode.unrecognized_keys) {