@agentv/core 4.6.0 → 4.6.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/{chunk-AIQ5FO4G.js → chunk-ZK4GG7PR.js} +61 -1
- package/dist/chunk-ZK4GG7PR.js.map +1 -0
- package/dist/evaluation/validation/index.cjs.map +1 -1
- package/dist/evaluation/validation/index.js +1 -1
- package/dist/index.cjs +225 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +174 -69
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-AIQ5FO4G.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1561,6 +1561,7 @@ __export(index_exports, {
|
|
|
1561
1561
|
readTranscriptFile: () => readTranscriptFile,
|
|
1562
1562
|
removeProject: () => removeProject,
|
|
1563
1563
|
resolveAndCreateProvider: () => resolveAndCreateProvider,
|
|
1564
|
+
resolveDelegatedTargetDefinition: () => resolveDelegatedTargetDefinition,
|
|
1564
1565
|
resolveFileReference: () => resolveFileReference3,
|
|
1565
1566
|
resolveTargetDefinition: () => resolveTargetDefinition,
|
|
1566
1567
|
resolveWorkspaceTemplate: () => resolveWorkspaceTemplate,
|
|
@@ -7169,15 +7170,16 @@ var CliProvider = class {
|
|
|
7169
7170
|
outputFilePath
|
|
7170
7171
|
);
|
|
7171
7172
|
const renderedCommand = renderTemplate(this.config.command, templateValues);
|
|
7173
|
+
const effectiveCwd = requests[0]?.cwd ?? this.config.cwd;
|
|
7172
7174
|
if (this.verbose) {
|
|
7173
7175
|
console.log(
|
|
7174
|
-
`[cli-provider:${this.targetName}] (batch size=${requests.length}) cwd=${
|
|
7176
|
+
`[cli-provider:${this.targetName}] (batch size=${requests.length}) cwd=${effectiveCwd ?? ""} command=${renderedCommand}`
|
|
7175
7177
|
);
|
|
7176
7178
|
}
|
|
7177
7179
|
try {
|
|
7178
7180
|
const startTime = Date.now();
|
|
7179
7181
|
const result = await this.runCommand(renderedCommand, {
|
|
7180
|
-
cwd:
|
|
7182
|
+
cwd: effectiveCwd,
|
|
7181
7183
|
env: process.env,
|
|
7182
7184
|
timeoutMs: this.config.timeoutMs,
|
|
7183
7185
|
signal: controller.signal
|
|
@@ -7210,7 +7212,7 @@ var CliProvider = class {
|
|
|
7210
7212
|
command: renderedCommand,
|
|
7211
7213
|
stderr: result.stderr,
|
|
7212
7214
|
exitCode: result.exitCode ?? 0,
|
|
7213
|
-
cwd:
|
|
7215
|
+
cwd: effectiveCwd,
|
|
7214
7216
|
outputFile: outputFilePath
|
|
7215
7217
|
}
|
|
7216
7218
|
};
|
|
@@ -7228,7 +7230,7 @@ var CliProvider = class {
|
|
|
7228
7230
|
command: renderedCommand,
|
|
7229
7231
|
stderr: result.stderr,
|
|
7230
7232
|
exitCode: result.exitCode ?? 0,
|
|
7231
|
-
cwd:
|
|
7233
|
+
cwd: effectiveCwd,
|
|
7232
7234
|
outputFile: outputFilePath,
|
|
7233
7235
|
error: errorMessage
|
|
7234
7236
|
}
|
|
@@ -7243,7 +7245,7 @@ var CliProvider = class {
|
|
|
7243
7245
|
command: renderedCommand,
|
|
7244
7246
|
stderr: result.stderr,
|
|
7245
7247
|
exitCode: result.exitCode ?? 0,
|
|
7246
|
-
cwd:
|
|
7248
|
+
cwd: effectiveCwd,
|
|
7247
7249
|
outputFile: outputFilePath,
|
|
7248
7250
|
recordId: evalCaseId
|
|
7249
7251
|
}
|
|
@@ -9267,6 +9269,60 @@ function subscribeToPiLogEntries(listener) {
|
|
|
9267
9269
|
};
|
|
9268
9270
|
}
|
|
9269
9271
|
|
|
9272
|
+
// src/evaluation/providers/pi-provider-aliases.ts
|
|
9273
|
+
init_cjs_shims();
|
|
9274
|
+
var SUBPROVIDER_ALIASES = {
|
|
9275
|
+
azure: "azure-openai-responses"
|
|
9276
|
+
};
|
|
9277
|
+
var SUBPROVIDER_ALIASES_WITH_BASE_URL = {
|
|
9278
|
+
// Azure v1 endpoints are OpenAI-compatible; use the standard client
|
|
9279
|
+
// to avoid AzureOpenAI adding api-version query params.
|
|
9280
|
+
azure: "openai-responses"
|
|
9281
|
+
};
|
|
9282
|
+
var ENV_KEY_MAP = {
|
|
9283
|
+
google: "GEMINI_API_KEY",
|
|
9284
|
+
gemini: "GEMINI_API_KEY",
|
|
9285
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
9286
|
+
openai: "OPENAI_API_KEY",
|
|
9287
|
+
groq: "GROQ_API_KEY",
|
|
9288
|
+
xai: "XAI_API_KEY",
|
|
9289
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
9290
|
+
azure: "AZURE_OPENAI_API_KEY"
|
|
9291
|
+
};
|
|
9292
|
+
var ENV_BASE_URL_MAP = {
|
|
9293
|
+
openai: "OPENAI_BASE_URL",
|
|
9294
|
+
azure: "AZURE_OPENAI_BASE_URL",
|
|
9295
|
+
openrouter: "OPENROUTER_BASE_URL"
|
|
9296
|
+
};
|
|
9297
|
+
function resolveSubprovider(name, hasBaseUrl = false) {
|
|
9298
|
+
const lower = name.toLowerCase();
|
|
9299
|
+
if (hasBaseUrl) {
|
|
9300
|
+
const alias = SUBPROVIDER_ALIASES_WITH_BASE_URL[lower];
|
|
9301
|
+
if (alias) return alias;
|
|
9302
|
+
}
|
|
9303
|
+
return SUBPROVIDER_ALIASES[lower] ?? name;
|
|
9304
|
+
}
|
|
9305
|
+
function resolveCliProvider(name) {
|
|
9306
|
+
const lower = name.toLowerCase();
|
|
9307
|
+
if (lower === "azure") return "azure-openai-responses";
|
|
9308
|
+
return name;
|
|
9309
|
+
}
|
|
9310
|
+
function resolveEnvKeyName(provider, hasBaseUrl = false) {
|
|
9311
|
+
const lower = provider.toLowerCase();
|
|
9312
|
+
if (hasBaseUrl && lower === "azure") return "OPENAI_API_KEY";
|
|
9313
|
+
return ENV_KEY_MAP[lower];
|
|
9314
|
+
}
|
|
9315
|
+
function resolveEnvBaseUrlName(provider, hasBaseUrl = false) {
|
|
9316
|
+
const lower = provider.toLowerCase();
|
|
9317
|
+
if (hasBaseUrl && lower === "azure") return "OPENAI_BASE_URL";
|
|
9318
|
+
return ENV_BASE_URL_MAP[lower];
|
|
9319
|
+
}
|
|
9320
|
+
function extractAzureResourceName(baseUrl) {
|
|
9321
|
+
const urlMatch = baseUrl.match(/^https?:\/\/([^./]+)/);
|
|
9322
|
+
if (urlMatch) return urlMatch[1];
|
|
9323
|
+
return baseUrl;
|
|
9324
|
+
}
|
|
9325
|
+
|
|
9270
9326
|
// src/evaluation/providers/pi-utils.ts
|
|
9271
9327
|
init_cjs_shims();
|
|
9272
9328
|
function extractPiTextContent(content) {
|
|
@@ -9426,12 +9482,12 @@ var PiCliProvider = class {
|
|
|
9426
9482
|
buildPiArgs(prompt, inputFiles) {
|
|
9427
9483
|
const args = [];
|
|
9428
9484
|
if (this.config.subprovider) {
|
|
9429
|
-
args.push("--provider", this.config.subprovider);
|
|
9485
|
+
args.push("--provider", resolveCliProvider(this.config.subprovider));
|
|
9430
9486
|
}
|
|
9431
9487
|
if (this.config.model) {
|
|
9432
9488
|
args.push("--model", this.config.model);
|
|
9433
9489
|
}
|
|
9434
|
-
if (this.config.apiKey) {
|
|
9490
|
+
if (this.config.apiKey && this.config.subprovider?.toLowerCase() !== "azure") {
|
|
9435
9491
|
args.push("--api-key", this.config.apiKey);
|
|
9436
9492
|
}
|
|
9437
9493
|
args.push("--mode", "json");
|
|
@@ -9483,35 +9539,35 @@ ${prompt}` : prompt;
|
|
|
9483
9539
|
}
|
|
9484
9540
|
buildEnv() {
|
|
9485
9541
|
const env = { ...process.env };
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9542
|
+
const provider = this.config.subprovider?.toLowerCase() ?? "google";
|
|
9543
|
+
if (provider === "azure") {
|
|
9544
|
+
if (this.config.apiKey) {
|
|
9545
|
+
env.AZURE_OPENAI_API_KEY = this.config.apiKey;
|
|
9546
|
+
}
|
|
9547
|
+
if (this.config.baseUrl) {
|
|
9548
|
+
env.AZURE_OPENAI_RESOURCE_NAME = extractAzureResourceName(this.config.baseUrl);
|
|
9549
|
+
}
|
|
9550
|
+
} else {
|
|
9551
|
+
if (this.config.apiKey) {
|
|
9552
|
+
const envKey = resolveEnvKeyName(provider);
|
|
9553
|
+
if (envKey) {
|
|
9554
|
+
env[envKey] = this.config.apiKey;
|
|
9555
|
+
}
|
|
9500
9556
|
}
|
|
9501
9557
|
}
|
|
9502
9558
|
if (this.config.subprovider) {
|
|
9503
|
-
const
|
|
9559
|
+
const resolvedProvider = resolveCliProvider(this.config.subprovider);
|
|
9504
9560
|
const PROVIDER_OWN_PREFIXES = {
|
|
9505
9561
|
openrouter: ["OPENROUTER_"],
|
|
9506
9562
|
anthropic: ["ANTHROPIC_"],
|
|
9507
9563
|
openai: ["OPENAI_"],
|
|
9508
|
-
azure: ["AZURE_OPENAI_"],
|
|
9564
|
+
"azure-openai-responses": ["AZURE_OPENAI_"],
|
|
9509
9565
|
google: ["GEMINI_", "GOOGLE_GENERATIVE_AI_"],
|
|
9510
9566
|
gemini: ["GEMINI_", "GOOGLE_GENERATIVE_AI_"],
|
|
9511
9567
|
groq: ["GROQ_"],
|
|
9512
9568
|
xai: ["XAI_"]
|
|
9513
9569
|
};
|
|
9514
|
-
const ownPrefixes = PROVIDER_OWN_PREFIXES[
|
|
9570
|
+
const ownPrefixes = PROVIDER_OWN_PREFIXES[resolvedProvider] ?? [];
|
|
9515
9571
|
const allOtherPrefixes = Object.entries(PROVIDER_OWN_PREFIXES).filter(([key]) => key !== provider).flatMap(([, prefixes]) => prefixes);
|
|
9516
9572
|
for (const key of Object.keys(env)) {
|
|
9517
9573
|
if (allOtherPrefixes.some((prefix) => key.startsWith(prefix)) && !ownPrefixes.some((prefix) => key.startsWith(prefix))) {
|
|
@@ -9802,6 +9858,24 @@ function extractMessages(events) {
|
|
|
9802
9858
|
}
|
|
9803
9859
|
}
|
|
9804
9860
|
}
|
|
9861
|
+
if (messages) {
|
|
9862
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
9863
|
+
if (messages[i].role === "assistant" && !messages[i].content) {
|
|
9864
|
+
for (let j = events.length - 1; j >= 0; j--) {
|
|
9865
|
+
const evt = events[j];
|
|
9866
|
+
if (!evt || evt.type !== "message_end") continue;
|
|
9867
|
+
const msg = evt.message;
|
|
9868
|
+
if (msg?.role !== "assistant") continue;
|
|
9869
|
+
const text = extractPiTextContent(msg.content);
|
|
9870
|
+
if (text) {
|
|
9871
|
+
messages[i] = { ...messages[i], content: text };
|
|
9872
|
+
break;
|
|
9873
|
+
}
|
|
9874
|
+
}
|
|
9875
|
+
break;
|
|
9876
|
+
}
|
|
9877
|
+
}
|
|
9878
|
+
}
|
|
9805
9879
|
const eventToolCalls = extractToolCallsFromEvents(events);
|
|
9806
9880
|
if (eventToolCalls.length > 0) {
|
|
9807
9881
|
injectEventToolCalls(messages, eventToolCalls);
|
|
@@ -9986,17 +10060,43 @@ function formatTimeoutSuffix3(timeoutMs) {
|
|
|
9986
10060
|
if (!timeoutMs || timeoutMs <= 0) return "";
|
|
9987
10061
|
return ` after ${Math.ceil(timeoutMs / 1e3)}s`;
|
|
9988
10062
|
}
|
|
10063
|
+
function resolveWindowsCmd(executable) {
|
|
10064
|
+
if (process.platform !== "win32") return [executable, []];
|
|
10065
|
+
const lower = executable.toLowerCase();
|
|
10066
|
+
if (lower.endsWith(".js") || lower.endsWith(".exe")) return [executable, []];
|
|
10067
|
+
let fullPath;
|
|
10068
|
+
try {
|
|
10069
|
+
fullPath = (0, import_node_child_process4.execSync)(`where ${executable}`, { encoding: "utf-8" }).trim().split(/\r?\n/)[0].trim();
|
|
10070
|
+
} catch {
|
|
10071
|
+
return [executable, []];
|
|
10072
|
+
}
|
|
10073
|
+
const cmdPath = fullPath.endsWith(".cmd") ? fullPath : `${fullPath}.cmd`;
|
|
10074
|
+
try {
|
|
10075
|
+
const content = (0, import_node_fs9.readFileSync)(cmdPath, "utf-8");
|
|
10076
|
+
const match = content.match(/"?%_prog%"?\s+"([^"]+\.js)"/);
|
|
10077
|
+
if (match) {
|
|
10078
|
+
const dp0 = import_node_path21.default.dirname(import_node_path21.default.resolve(cmdPath));
|
|
10079
|
+
const scriptPath = match[1].replace(/%dp0%[/\\]?/gi, `${dp0}${import_node_path21.default.sep}`);
|
|
10080
|
+
try {
|
|
10081
|
+
(0, import_node_fs9.accessSync)(scriptPath);
|
|
10082
|
+
return ["node", [scriptPath]];
|
|
10083
|
+
} catch {
|
|
10084
|
+
}
|
|
10085
|
+
}
|
|
10086
|
+
} catch {
|
|
10087
|
+
}
|
|
10088
|
+
return [executable, []];
|
|
10089
|
+
}
|
|
9989
10090
|
async function defaultPiRunner(options) {
|
|
9990
10091
|
return await new Promise((resolve, reject) => {
|
|
9991
10092
|
const parts = options.executable.split(/\s+/);
|
|
9992
|
-
const
|
|
9993
|
-
const executableArgs = parts.slice(1);
|
|
10093
|
+
const [resolvedExe, prefixArgs] = resolveWindowsCmd(parts[0]);
|
|
10094
|
+
const executableArgs = [...prefixArgs, ...parts.slice(1)];
|
|
9994
10095
|
const allArgs = [...executableArgs, ...options.args];
|
|
9995
|
-
const child = (0, import_node_child_process4.spawn)(
|
|
10096
|
+
const child = (0, import_node_child_process4.spawn)(resolvedExe, allArgs, {
|
|
9996
10097
|
cwd: options.cwd,
|
|
9997
10098
|
env: options.env,
|
|
9998
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
9999
|
-
shell: false
|
|
10099
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
10000
10100
|
});
|
|
10001
10101
|
let stdout = "";
|
|
10002
10102
|
let stderr = "";
|
|
@@ -10143,7 +10243,9 @@ async function loadSdkModules() {
|
|
|
10143
10243
|
codingTools: piSdk.codingTools,
|
|
10144
10244
|
toolMap,
|
|
10145
10245
|
SessionManager: piSdk.SessionManager,
|
|
10146
|
-
getModel: piAi.getModel
|
|
10246
|
+
getModel: piAi.getModel,
|
|
10247
|
+
// biome-ignore lint/suspicious/noExplicitAny: registerBuiltInApiProviders exists at runtime but not in type defs
|
|
10248
|
+
registerBuiltInApiProviders: piAi.registerBuiltInApiProviders
|
|
10147
10249
|
};
|
|
10148
10250
|
}
|
|
10149
10251
|
var PiCodingAgentProvider = class {
|
|
@@ -10165,17 +10267,31 @@ var PiCodingAgentProvider = class {
|
|
|
10165
10267
|
const startTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
10166
10268
|
const startMs = Date.now();
|
|
10167
10269
|
const sdk = await loadSdkModules();
|
|
10270
|
+
sdk.registerBuiltInApiProviders();
|
|
10168
10271
|
const logger = await this.createStreamLogger(request).catch(() => void 0);
|
|
10169
10272
|
try {
|
|
10170
10273
|
const cwd = this.resolveCwd(request.cwd);
|
|
10171
|
-
const
|
|
10274
|
+
const rawProvider = this.config.subprovider ?? "google";
|
|
10275
|
+
const hasBaseUrl = !!this.config.baseUrl;
|
|
10276
|
+
const providerName = resolveSubprovider(rawProvider, hasBaseUrl);
|
|
10172
10277
|
const modelId = this.config.model ?? "gemini-2.5-flash";
|
|
10173
|
-
this.setApiKeyEnv(
|
|
10174
|
-
|
|
10278
|
+
this.setApiKeyEnv(rawProvider, hasBaseUrl);
|
|
10279
|
+
this.setBaseUrlEnv(rawProvider, hasBaseUrl);
|
|
10280
|
+
let model = sdk.getModel(providerName, modelId);
|
|
10175
10281
|
if (!model) {
|
|
10176
|
-
|
|
10177
|
-
|
|
10178
|
-
|
|
10282
|
+
const envProvider = providerName.replace(/-responses$/, "");
|
|
10283
|
+
model = {
|
|
10284
|
+
id: modelId,
|
|
10285
|
+
name: modelId,
|
|
10286
|
+
api: providerName,
|
|
10287
|
+
provider: envProvider,
|
|
10288
|
+
baseUrl: this.config.baseUrl ?? "",
|
|
10289
|
+
reasoning: false,
|
|
10290
|
+
input: ["text"],
|
|
10291
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
10292
|
+
contextWindow: 128e3,
|
|
10293
|
+
maxTokens: 16384
|
|
10294
|
+
};
|
|
10179
10295
|
}
|
|
10180
10296
|
const tools = this.resolveTools(sdk);
|
|
10181
10297
|
const { session } = await sdk.createAgentSession({
|
|
@@ -10328,22 +10444,21 @@ ${fileList}`;
|
|
|
10328
10444
|
}
|
|
10329
10445
|
}
|
|
10330
10446
|
/** Maps config apiKey to the provider-specific env var the SDK reads. */
|
|
10331
|
-
setApiKeyEnv(providerName) {
|
|
10447
|
+
setApiKeyEnv(providerName, hasBaseUrl = false) {
|
|
10332
10448
|
if (!this.config.apiKey) return;
|
|
10333
|
-
const
|
|
10334
|
-
google: "GEMINI_API_KEY",
|
|
10335
|
-
gemini: "GEMINI_API_KEY",
|
|
10336
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
10337
|
-
openai: "OPENAI_API_KEY",
|
|
10338
|
-
groq: "GROQ_API_KEY",
|
|
10339
|
-
xai: "XAI_API_KEY",
|
|
10340
|
-
openrouter: "OPENROUTER_API_KEY"
|
|
10341
|
-
};
|
|
10342
|
-
const envKey = ENV_KEY_MAP[providerName.toLowerCase()];
|
|
10449
|
+
const envKey = resolveEnvKeyName(providerName, hasBaseUrl);
|
|
10343
10450
|
if (envKey) {
|
|
10344
10451
|
process.env[envKey] = this.config.apiKey;
|
|
10345
10452
|
}
|
|
10346
10453
|
}
|
|
10454
|
+
/** Maps config baseUrl to the provider-specific env var the SDK reads. */
|
|
10455
|
+
setBaseUrlEnv(providerName, hasBaseUrl = false) {
|
|
10456
|
+
if (!this.config.baseUrl) return;
|
|
10457
|
+
const envKey = resolveEnvBaseUrlName(providerName, hasBaseUrl);
|
|
10458
|
+
if (envKey) {
|
|
10459
|
+
process.env[envKey] = this.config.baseUrl;
|
|
10460
|
+
}
|
|
10461
|
+
}
|
|
10347
10462
|
resolveCwd(cwdOverride) {
|
|
10348
10463
|
if (cwdOverride) {
|
|
10349
10464
|
return import_node_path22.default.resolve(cwdOverride);
|
|
@@ -10776,6 +10891,7 @@ var COMMON_TARGET_SETTINGS = [
|
|
|
10776
10891
|
"fallback_targets",
|
|
10777
10892
|
"fallbackTargets"
|
|
10778
10893
|
];
|
|
10894
|
+
var USE_TARGET_ENV_PATTERN = /^\$\{\{\s*([A-Z0-9_]+)\s*\}\}$/i;
|
|
10779
10895
|
var BASE_TARGET_SCHEMA = import_zod3.z.object({
|
|
10780
10896
|
name: import_zod3.z.string().min(1, "target name is required"),
|
|
10781
10897
|
provider: import_zod3.z.string().optional(),
|
|
@@ -10835,6 +10951,52 @@ function resolveRetryConfig(target) {
|
|
|
10835
10951
|
retryableStatusCodes
|
|
10836
10952
|
};
|
|
10837
10953
|
}
|
|
10954
|
+
function resolveDelegatedTargetDefinition(name, definitions, env = process.env) {
|
|
10955
|
+
let definition = definitions.get(name);
|
|
10956
|
+
if (!definition) {
|
|
10957
|
+
return void 0;
|
|
10958
|
+
}
|
|
10959
|
+
const visited = [definition.name];
|
|
10960
|
+
for (let depth = 0; depth < 10; depth++) {
|
|
10961
|
+
const rawUseTarget = typeof definition.use_target === "string" ? definition.use_target.trim() : void 0;
|
|
10962
|
+
if (!rawUseTarget) {
|
|
10963
|
+
return definition;
|
|
10964
|
+
}
|
|
10965
|
+
const envMatch = rawUseTarget.match(USE_TARGET_ENV_PATTERN);
|
|
10966
|
+
const envVarName = envMatch?.[1];
|
|
10967
|
+
const resolvedName = envVarName ? env[envVarName]?.trim() ?? "" : rawUseTarget;
|
|
10968
|
+
if (resolvedName.length === 0) {
|
|
10969
|
+
if (envVarName) {
|
|
10970
|
+
throw new Error(
|
|
10971
|
+
`Target "${definition.name}" uses use_target: \${{ ${envVarName} }}, but ${envVarName} is not set. Set ${envVarName} to the name of a concrete target (for example, "azure") before running the eval.`
|
|
10972
|
+
);
|
|
10973
|
+
}
|
|
10974
|
+
throw new Error(
|
|
10975
|
+
`Target "${definition.name}" has an empty use_target value. Point it at a concrete target name before running the eval.`
|
|
10976
|
+
);
|
|
10977
|
+
}
|
|
10978
|
+
const next = definitions.get(resolvedName);
|
|
10979
|
+
if (!next) {
|
|
10980
|
+
if (envVarName) {
|
|
10981
|
+
throw new Error(
|
|
10982
|
+
`Target "${definition.name}" uses use_target: \${{ ${envVarName} }}, which resolved to "${resolvedName}", but no target named "${resolvedName}" exists.`
|
|
10983
|
+
);
|
|
10984
|
+
}
|
|
10985
|
+
throw new Error(
|
|
10986
|
+
`Target "${definition.name}" uses use_target: "${resolvedName}", but no target named "${resolvedName}" exists.`
|
|
10987
|
+
);
|
|
10988
|
+
}
|
|
10989
|
+
if (visited.includes(next.name)) {
|
|
10990
|
+
const chain = [...visited, next.name].join(" -> ");
|
|
10991
|
+
throw new Error(`Circular use_target reference detected: ${chain}`);
|
|
10992
|
+
}
|
|
10993
|
+
definition = next;
|
|
10994
|
+
visited.push(definition.name);
|
|
10995
|
+
}
|
|
10996
|
+
throw new Error(
|
|
10997
|
+
`Target "${name}" exceeded the maximum use_target resolution depth (10). Check for a delegation loop or overly deep alias chain.`
|
|
10998
|
+
);
|
|
10999
|
+
}
|
|
10838
11000
|
function resolveTargetDefinition(definition, env = process.env, evalFilePath) {
|
|
10839
11001
|
const parsed = BASE_TARGET_SCHEMA.parse(definition);
|
|
10840
11002
|
if (parsed.workspace_template !== void 0 || parsed.workspaceTemplate !== void 0) {
|
|
@@ -11374,6 +11536,11 @@ function resolvePiCodingAgentConfig(target, env, evalFilePath) {
|
|
|
11374
11536
|
allowLiteral: false,
|
|
11375
11537
|
optionalEnv: true
|
|
11376
11538
|
});
|
|
11539
|
+
const baseUrlSource = target.base_url ?? target.baseUrl ?? target.endpoint;
|
|
11540
|
+
const baseUrl = resolveOptionalString(baseUrlSource, env, `${target.name} pi base url`, {
|
|
11541
|
+
allowLiteral: true,
|
|
11542
|
+
optionalEnv: true
|
|
11543
|
+
});
|
|
11377
11544
|
const tools = resolveOptionalString(toolsSource, env, `${target.name} pi tools`, {
|
|
11378
11545
|
allowLiteral: true,
|
|
11379
11546
|
optionalEnv: true
|
|
@@ -11414,6 +11581,7 @@ function resolvePiCodingAgentConfig(target, env, evalFilePath) {
|
|
|
11414
11581
|
subprovider,
|
|
11415
11582
|
model,
|
|
11416
11583
|
apiKey,
|
|
11584
|
+
baseUrl,
|
|
11417
11585
|
tools,
|
|
11418
11586
|
thinking,
|
|
11419
11587
|
cwd,
|
|
@@ -11455,6 +11623,11 @@ function resolvePiCliConfig(target, env, evalFilePath) {
|
|
|
11455
11623
|
allowLiteral: false,
|
|
11456
11624
|
optionalEnv: true
|
|
11457
11625
|
});
|
|
11626
|
+
const baseUrlSource = target.base_url ?? target.baseUrl ?? target.endpoint;
|
|
11627
|
+
const baseUrl = resolveOptionalString(baseUrlSource, env, `${target.name} pi-cli base url`, {
|
|
11628
|
+
allowLiteral: true,
|
|
11629
|
+
optionalEnv: true
|
|
11630
|
+
});
|
|
11458
11631
|
const tools = resolveOptionalString(toolsSource, env, `${target.name} pi-cli tools`, {
|
|
11459
11632
|
allowLiteral: true,
|
|
11460
11633
|
optionalEnv: true
|
|
@@ -11493,6 +11666,7 @@ function resolvePiCliConfig(target, env, evalFilePath) {
|
|
|
11493
11666
|
subprovider,
|
|
11494
11667
|
model,
|
|
11495
11668
|
apiKey,
|
|
11669
|
+
baseUrl,
|
|
11496
11670
|
tools,
|
|
11497
11671
|
thinking,
|
|
11498
11672
|
args,
|
|
@@ -18859,20 +19033,10 @@ async function runEvaluation(options) {
|
|
|
18859
19033
|
if (resolvedTargetsByName.has(name)) {
|
|
18860
19034
|
return resolvedTargetsByName.get(name);
|
|
18861
19035
|
}
|
|
18862
|
-
|
|
19036
|
+
const definition = resolveDelegatedTargetDefinition(name, targetDefinitions, envLookup);
|
|
18863
19037
|
if (!definition) {
|
|
18864
19038
|
return void 0;
|
|
18865
19039
|
}
|
|
18866
|
-
for (let depth = 0; depth < 5; depth++) {
|
|
18867
|
-
const useTarget = definition.use_target;
|
|
18868
|
-
if (typeof useTarget !== "string" || useTarget.trim().length === 0) break;
|
|
18869
|
-
const envMatch = useTarget.trim().match(/^\$\{\{\s*([A-Z0-9_]+)\s*\}\}$/i);
|
|
18870
|
-
const resolvedName = envMatch ? envLookup[envMatch[1]] ?? "" : useTarget.trim();
|
|
18871
|
-
if (resolvedName.length === 0) break;
|
|
18872
|
-
const next = targetDefinitions.get(resolvedName);
|
|
18873
|
-
if (!next) break;
|
|
18874
|
-
definition = next;
|
|
18875
|
-
}
|
|
18876
19040
|
const resolved = resolveTargetDefinition(definition, envLookup, evalFilePath);
|
|
18877
19041
|
resolvedTargetsByName.set(name, resolved);
|
|
18878
19042
|
return resolved;
|
|
@@ -20960,7 +21124,7 @@ async function discoverDefaultTarget(repoRoot) {
|
|
|
20960
21124
|
return null;
|
|
20961
21125
|
}
|
|
20962
21126
|
async function loadEnvHierarchy(repoRoot, startPath) {
|
|
20963
|
-
const { readFileSync:
|
|
21127
|
+
const { readFileSync: readFileSync4 } = await import("fs");
|
|
20964
21128
|
const chain = buildDirectoryChain2(startPath, repoRoot);
|
|
20965
21129
|
const envFiles = [];
|
|
20966
21130
|
for (const dir of chain) {
|
|
@@ -20969,7 +21133,7 @@ async function loadEnvHierarchy(repoRoot, startPath) {
|
|
|
20969
21133
|
}
|
|
20970
21134
|
for (let i = 0; i < envFiles.length; i++) {
|
|
20971
21135
|
try {
|
|
20972
|
-
const content =
|
|
21136
|
+
const content = readFileSync4(envFiles[i], "utf8");
|
|
20973
21137
|
for (const line of content.split("\n")) {
|
|
20974
21138
|
const trimmed = line.trim();
|
|
20975
21139
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -22259,6 +22423,7 @@ function createAgentKernel() {
|
|
|
22259
22423
|
readTranscriptFile,
|
|
22260
22424
|
removeProject,
|
|
22261
22425
|
resolveAndCreateProvider,
|
|
22426
|
+
resolveDelegatedTargetDefinition,
|
|
22262
22427
|
resolveFileReference,
|
|
22263
22428
|
resolveTargetDefinition,
|
|
22264
22429
|
resolveWorkspaceTemplate,
|