agentv 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/README.md +1 -1
- package/dist/{chunk-5GZJIXTY.js → chunk-MHWYA4CS.js} +4 -4
- package/dist/{chunk-5GZJIXTY.js.map → chunk-MHWYA4CS.js.map} +1 -1
- package/dist/{chunk-U2LSJ6Y4.js → chunk-NSVFUL27.js} +158 -120
- package/dist/chunk-NSVFUL27.js.map +1 -0
- package/dist/{chunk-KQQTEWZF.js → chunk-YXXD27OK.js} +232 -71
- package/dist/chunk-YXXD27OK.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/{dist-FBPCDLOY.js → dist-BN5NUVAB.js} +4 -2
- package/dist/index.js +3 -3
- package/dist/{interactive-6D3ULOMN.js → interactive-DMSVE6CS.js} +3 -3
- package/dist/studio/assets/{index-zWHsVvgi.js → index-C7TnyYee.js} +1 -1
- package/dist/studio/assets/{index-D-gfAa3s.js → index-vn54AYtS.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
- package/dist/chunk-KQQTEWZF.js.map +0 -1
- package/dist/chunk-U2LSJ6Y4.js.map +0 -1
- /package/dist/{dist-FBPCDLOY.js.map → dist-BN5NUVAB.js.map} +0 -0
- /package/dist/{interactive-6D3ULOMN.js.map → interactive-DMSVE6CS.js.map} +0 -0
|
@@ -301,7 +301,7 @@ var require_dist = __commonJS({
|
|
|
301
301
|
}
|
|
302
302
|
});
|
|
303
303
|
|
|
304
|
-
// ../../packages/core/dist/chunk-
|
|
304
|
+
// ../../packages/core/dist/chunk-ZK4GG7PR.js
|
|
305
305
|
import { constants } from "node:fs";
|
|
306
306
|
import { access, readFile } from "node:fs/promises";
|
|
307
307
|
import path from "node:path";
|
|
@@ -419,7 +419,7 @@ __export(external_exports2, {
|
|
|
419
419
|
void: () => voidType
|
|
420
420
|
});
|
|
421
421
|
|
|
422
|
-
// ../../packages/core/dist/chunk-
|
|
422
|
+
// ../../packages/core/dist/chunk-ZK4GG7PR.js
|
|
423
423
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
424
424
|
import path3 from "node:path";
|
|
425
425
|
import fg from "fast-glob";
|
|
@@ -806,6 +806,7 @@ var COMMON_TARGET_SETTINGS = [
|
|
|
806
806
|
"fallback_targets",
|
|
807
807
|
"fallbackTargets"
|
|
808
808
|
];
|
|
809
|
+
var USE_TARGET_ENV_PATTERN = /^\$\{\{\s*([A-Z0-9_]+)\s*\}\}$/i;
|
|
809
810
|
var BASE_TARGET_SCHEMA = external_exports2.object({
|
|
810
811
|
name: external_exports2.string().min(1, "target name is required"),
|
|
811
812
|
provider: external_exports2.string().optional(),
|
|
@@ -865,6 +866,52 @@ function resolveRetryConfig(target) {
|
|
|
865
866
|
retryableStatusCodes
|
|
866
867
|
};
|
|
867
868
|
}
|
|
869
|
+
function resolveDelegatedTargetDefinition(name21, definitions, env = process.env) {
|
|
870
|
+
let definition = definitions.get(name21);
|
|
871
|
+
if (!definition) {
|
|
872
|
+
return void 0;
|
|
873
|
+
}
|
|
874
|
+
const visited = [definition.name];
|
|
875
|
+
for (let depth = 0; depth < 10; depth++) {
|
|
876
|
+
const rawUseTarget = typeof definition.use_target === "string" ? definition.use_target.trim() : void 0;
|
|
877
|
+
if (!rawUseTarget) {
|
|
878
|
+
return definition;
|
|
879
|
+
}
|
|
880
|
+
const envMatch = rawUseTarget.match(USE_TARGET_ENV_PATTERN);
|
|
881
|
+
const envVarName = envMatch?.[1];
|
|
882
|
+
const resolvedName = envVarName ? env[envVarName]?.trim() ?? "" : rawUseTarget;
|
|
883
|
+
if (resolvedName.length === 0) {
|
|
884
|
+
if (envVarName) {
|
|
885
|
+
throw new Error(
|
|
886
|
+
`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.`
|
|
887
|
+
);
|
|
888
|
+
}
|
|
889
|
+
throw new Error(
|
|
890
|
+
`Target "${definition.name}" has an empty use_target value. Point it at a concrete target name before running the eval.`
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
const next = definitions.get(resolvedName);
|
|
894
|
+
if (!next) {
|
|
895
|
+
if (envVarName) {
|
|
896
|
+
throw new Error(
|
|
897
|
+
`Target "${definition.name}" uses use_target: \${{ ${envVarName} }}, which resolved to "${resolvedName}", but no target named "${resolvedName}" exists.`
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
throw new Error(
|
|
901
|
+
`Target "${definition.name}" uses use_target: "${resolvedName}", but no target named "${resolvedName}" exists.`
|
|
902
|
+
);
|
|
903
|
+
}
|
|
904
|
+
if (visited.includes(next.name)) {
|
|
905
|
+
const chain = [...visited, next.name].join(" -> ");
|
|
906
|
+
throw new Error(`Circular use_target reference detected: ${chain}`);
|
|
907
|
+
}
|
|
908
|
+
definition = next;
|
|
909
|
+
visited.push(definition.name);
|
|
910
|
+
}
|
|
911
|
+
throw new Error(
|
|
912
|
+
`Target "${name21}" exceeded the maximum use_target resolution depth (10). Check for a delegation loop or overly deep alias chain.`
|
|
913
|
+
);
|
|
914
|
+
}
|
|
868
915
|
function resolveTargetDefinition(definition, env = process.env, evalFilePath) {
|
|
869
916
|
const parsed = BASE_TARGET_SCHEMA.parse(definition);
|
|
870
917
|
if (parsed.workspace_template !== void 0 || parsed.workspaceTemplate !== void 0) {
|
|
@@ -1404,6 +1451,11 @@ function resolvePiCodingAgentConfig(target, env, evalFilePath) {
|
|
|
1404
1451
|
allowLiteral: false,
|
|
1405
1452
|
optionalEnv: true
|
|
1406
1453
|
});
|
|
1454
|
+
const baseUrlSource = target.base_url ?? target.baseUrl ?? target.endpoint;
|
|
1455
|
+
const baseUrl = resolveOptionalString(baseUrlSource, env, `${target.name} pi base url`, {
|
|
1456
|
+
allowLiteral: true,
|
|
1457
|
+
optionalEnv: true
|
|
1458
|
+
});
|
|
1407
1459
|
const tools = resolveOptionalString(toolsSource, env, `${target.name} pi tools`, {
|
|
1408
1460
|
allowLiteral: true,
|
|
1409
1461
|
optionalEnv: true
|
|
@@ -1444,6 +1496,7 @@ function resolvePiCodingAgentConfig(target, env, evalFilePath) {
|
|
|
1444
1496
|
subprovider,
|
|
1445
1497
|
model,
|
|
1446
1498
|
apiKey,
|
|
1499
|
+
baseUrl,
|
|
1447
1500
|
tools,
|
|
1448
1501
|
thinking,
|
|
1449
1502
|
cwd,
|
|
@@ -1485,6 +1538,11 @@ function resolvePiCliConfig(target, env, evalFilePath) {
|
|
|
1485
1538
|
allowLiteral: false,
|
|
1486
1539
|
optionalEnv: true
|
|
1487
1540
|
});
|
|
1541
|
+
const baseUrlSource = target.base_url ?? target.baseUrl ?? target.endpoint;
|
|
1542
|
+
const baseUrl = resolveOptionalString(baseUrlSource, env, `${target.name} pi-cli base url`, {
|
|
1543
|
+
allowLiteral: true,
|
|
1544
|
+
optionalEnv: true
|
|
1545
|
+
});
|
|
1488
1546
|
const tools = resolveOptionalString(toolsSource, env, `${target.name} pi-cli tools`, {
|
|
1489
1547
|
allowLiteral: true,
|
|
1490
1548
|
optionalEnv: true
|
|
@@ -1523,6 +1581,7 @@ function resolvePiCliConfig(target, env, evalFilePath) {
|
|
|
1523
1581
|
subprovider,
|
|
1524
1582
|
model,
|
|
1525
1583
|
apiKey,
|
|
1584
|
+
baseUrl,
|
|
1526
1585
|
tools,
|
|
1527
1586
|
thinking,
|
|
1528
1587
|
args,
|
|
@@ -14278,15 +14337,15 @@ import { randomUUID as randomUUID6 } from "node:crypto";
|
|
|
14278
14337
|
import { existsSync as existsSync2 } from "node:fs";
|
|
14279
14338
|
import { mkdir as mkdir5 } from "node:fs/promises";
|
|
14280
14339
|
import path18 from "node:path";
|
|
14281
|
-
import { spawn as spawn3 } from "node:child_process";
|
|
14340
|
+
import { execSync, spawn as spawn3 } from "node:child_process";
|
|
14282
14341
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
14283
|
-
import { createWriteStream as createWriteStream5 } from "node:fs";
|
|
14342
|
+
import { accessSync, createWriteStream as createWriteStream5, readFileSync as readFileSync2 } from "node:fs";
|
|
14284
14343
|
import { mkdir as mkdir6, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
14285
14344
|
import { tmpdir } from "node:os";
|
|
14286
14345
|
import path19 from "node:path";
|
|
14287
|
-
import { execSync } from "node:child_process";
|
|
14346
|
+
import { execSync as execSync2 } from "node:child_process";
|
|
14288
14347
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
14289
|
-
import { accessSync, createWriteStream as createWriteStream6 } from "node:fs";
|
|
14348
|
+
import { accessSync as accessSync2, createWriteStream as createWriteStream6 } from "node:fs";
|
|
14290
14349
|
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
14291
14350
|
import path20 from "node:path";
|
|
14292
14351
|
import { createInterface } from "node:readline";
|
|
@@ -14361,7 +14420,7 @@ import { existsSync as existsSync5 } from "node:fs";
|
|
|
14361
14420
|
import path45 from "node:path";
|
|
14362
14421
|
import { mkdir as mkdir15, readFile as readFile13, writeFile as writeFile8 } from "node:fs/promises";
|
|
14363
14422
|
import path46 from "node:path";
|
|
14364
|
-
import { existsSync as existsSync6, mkdirSync, readFileSync as
|
|
14423
|
+
import { existsSync as existsSync6, mkdirSync, readFileSync as readFileSync3, readdirSync as readdirSync3, statSync as statSync2, writeFileSync } from "node:fs";
|
|
14365
14424
|
import path47 from "node:path";
|
|
14366
14425
|
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
14367
14426
|
import { readdir as readdir8, stat as stat9 } from "node:fs/promises";
|
|
@@ -19447,15 +19506,16 @@ var CliProvider = class {
|
|
|
19447
19506
|
outputFilePath
|
|
19448
19507
|
);
|
|
19449
19508
|
const renderedCommand = renderTemplate(this.config.command, templateValues);
|
|
19509
|
+
const effectiveCwd = requests[0]?.cwd ?? this.config.cwd;
|
|
19450
19510
|
if (this.verbose) {
|
|
19451
19511
|
console.log(
|
|
19452
|
-
`[cli-provider:${this.targetName}] (batch size=${requests.length}) cwd=${
|
|
19512
|
+
`[cli-provider:${this.targetName}] (batch size=${requests.length}) cwd=${effectiveCwd ?? ""} command=${renderedCommand}`
|
|
19453
19513
|
);
|
|
19454
19514
|
}
|
|
19455
19515
|
try {
|
|
19456
19516
|
const startTime = Date.now();
|
|
19457
19517
|
const result = await this.runCommand(renderedCommand, {
|
|
19458
|
-
cwd:
|
|
19518
|
+
cwd: effectiveCwd,
|
|
19459
19519
|
env: process.env,
|
|
19460
19520
|
timeoutMs: this.config.timeoutMs,
|
|
19461
19521
|
signal: controller.signal
|
|
@@ -19488,7 +19548,7 @@ var CliProvider = class {
|
|
|
19488
19548
|
command: renderedCommand,
|
|
19489
19549
|
stderr: result.stderr,
|
|
19490
19550
|
exitCode: result.exitCode ?? 0,
|
|
19491
|
-
cwd:
|
|
19551
|
+
cwd: effectiveCwd,
|
|
19492
19552
|
outputFile: outputFilePath
|
|
19493
19553
|
}
|
|
19494
19554
|
};
|
|
@@ -19506,7 +19566,7 @@ var CliProvider = class {
|
|
|
19506
19566
|
command: renderedCommand,
|
|
19507
19567
|
stderr: result.stderr,
|
|
19508
19568
|
exitCode: result.exitCode ?? 0,
|
|
19509
|
-
cwd:
|
|
19569
|
+
cwd: effectiveCwd,
|
|
19510
19570
|
outputFile: outputFilePath,
|
|
19511
19571
|
error: errorMessage
|
|
19512
19572
|
}
|
|
@@ -19521,7 +19581,7 @@ var CliProvider = class {
|
|
|
19521
19581
|
command: renderedCommand,
|
|
19522
19582
|
stderr: result.stderr,
|
|
19523
19583
|
exitCode: result.exitCode ?? 0,
|
|
19524
|
-
cwd:
|
|
19584
|
+
cwd: effectiveCwd,
|
|
19525
19585
|
outputFile: outputFilePath,
|
|
19526
19586
|
recordId: evalCaseId
|
|
19527
19587
|
}
|
|
@@ -21464,6 +21524,57 @@ function subscribeToPiLogEntries(listener) {
|
|
|
21464
21524
|
store.delete(listener);
|
|
21465
21525
|
};
|
|
21466
21526
|
}
|
|
21527
|
+
var SUBPROVIDER_ALIASES = {
|
|
21528
|
+
azure: "azure-openai-responses"
|
|
21529
|
+
};
|
|
21530
|
+
var SUBPROVIDER_ALIASES_WITH_BASE_URL = {
|
|
21531
|
+
// Azure v1 endpoints are OpenAI-compatible; use the standard client
|
|
21532
|
+
// to avoid AzureOpenAI adding api-version query params.
|
|
21533
|
+
azure: "openai-responses"
|
|
21534
|
+
};
|
|
21535
|
+
var ENV_KEY_MAP = {
|
|
21536
|
+
google: "GEMINI_API_KEY",
|
|
21537
|
+
gemini: "GEMINI_API_KEY",
|
|
21538
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
21539
|
+
openai: "OPENAI_API_KEY",
|
|
21540
|
+
groq: "GROQ_API_KEY",
|
|
21541
|
+
xai: "XAI_API_KEY",
|
|
21542
|
+
openrouter: "OPENROUTER_API_KEY",
|
|
21543
|
+
azure: "AZURE_OPENAI_API_KEY"
|
|
21544
|
+
};
|
|
21545
|
+
var ENV_BASE_URL_MAP = {
|
|
21546
|
+
openai: "OPENAI_BASE_URL",
|
|
21547
|
+
azure: "AZURE_OPENAI_BASE_URL",
|
|
21548
|
+
openrouter: "OPENROUTER_BASE_URL"
|
|
21549
|
+
};
|
|
21550
|
+
function resolveSubprovider(name21, hasBaseUrl = false) {
|
|
21551
|
+
const lower = name21.toLowerCase();
|
|
21552
|
+
if (hasBaseUrl) {
|
|
21553
|
+
const alias = SUBPROVIDER_ALIASES_WITH_BASE_URL[lower];
|
|
21554
|
+
if (alias) return alias;
|
|
21555
|
+
}
|
|
21556
|
+
return SUBPROVIDER_ALIASES[lower] ?? name21;
|
|
21557
|
+
}
|
|
21558
|
+
function resolveCliProvider(name21) {
|
|
21559
|
+
const lower = name21.toLowerCase();
|
|
21560
|
+
if (lower === "azure") return "azure-openai-responses";
|
|
21561
|
+
return name21;
|
|
21562
|
+
}
|
|
21563
|
+
function resolveEnvKeyName(provider, hasBaseUrl = false) {
|
|
21564
|
+
const lower = provider.toLowerCase();
|
|
21565
|
+
if (hasBaseUrl && lower === "azure") return "OPENAI_API_KEY";
|
|
21566
|
+
return ENV_KEY_MAP[lower];
|
|
21567
|
+
}
|
|
21568
|
+
function resolveEnvBaseUrlName(provider, hasBaseUrl = false) {
|
|
21569
|
+
const lower = provider.toLowerCase();
|
|
21570
|
+
if (hasBaseUrl && lower === "azure") return "OPENAI_BASE_URL";
|
|
21571
|
+
return ENV_BASE_URL_MAP[lower];
|
|
21572
|
+
}
|
|
21573
|
+
function extractAzureResourceName(baseUrl) {
|
|
21574
|
+
const urlMatch = baseUrl.match(/^https?:\/\/([^./]+)/);
|
|
21575
|
+
if (urlMatch) return urlMatch[1];
|
|
21576
|
+
return baseUrl;
|
|
21577
|
+
}
|
|
21467
21578
|
function extractPiTextContent(content) {
|
|
21468
21579
|
if (typeof content === "string") {
|
|
21469
21580
|
return content;
|
|
@@ -21619,12 +21730,12 @@ var PiCliProvider = class {
|
|
|
21619
21730
|
buildPiArgs(prompt, inputFiles) {
|
|
21620
21731
|
const args = [];
|
|
21621
21732
|
if (this.config.subprovider) {
|
|
21622
|
-
args.push("--provider", this.config.subprovider);
|
|
21733
|
+
args.push("--provider", resolveCliProvider(this.config.subprovider));
|
|
21623
21734
|
}
|
|
21624
21735
|
if (this.config.model) {
|
|
21625
21736
|
args.push("--model", this.config.model);
|
|
21626
21737
|
}
|
|
21627
|
-
if (this.config.apiKey) {
|
|
21738
|
+
if (this.config.apiKey && this.config.subprovider?.toLowerCase() !== "azure") {
|
|
21628
21739
|
args.push("--api-key", this.config.apiKey);
|
|
21629
21740
|
}
|
|
21630
21741
|
args.push("--mode", "json");
|
|
@@ -21676,35 +21787,35 @@ ${prompt}` : prompt;
|
|
|
21676
21787
|
}
|
|
21677
21788
|
buildEnv() {
|
|
21678
21789
|
const env = { ...process.env };
|
|
21679
|
-
|
|
21680
|
-
|
|
21681
|
-
|
|
21682
|
-
|
|
21683
|
-
|
|
21684
|
-
|
|
21685
|
-
|
|
21686
|
-
|
|
21687
|
-
|
|
21688
|
-
|
|
21689
|
-
|
|
21690
|
-
|
|
21691
|
-
|
|
21692
|
-
|
|
21790
|
+
const provider = this.config.subprovider?.toLowerCase() ?? "google";
|
|
21791
|
+
if (provider === "azure") {
|
|
21792
|
+
if (this.config.apiKey) {
|
|
21793
|
+
env.AZURE_OPENAI_API_KEY = this.config.apiKey;
|
|
21794
|
+
}
|
|
21795
|
+
if (this.config.baseUrl) {
|
|
21796
|
+
env.AZURE_OPENAI_RESOURCE_NAME = extractAzureResourceName(this.config.baseUrl);
|
|
21797
|
+
}
|
|
21798
|
+
} else {
|
|
21799
|
+
if (this.config.apiKey) {
|
|
21800
|
+
const envKey = resolveEnvKeyName(provider);
|
|
21801
|
+
if (envKey) {
|
|
21802
|
+
env[envKey] = this.config.apiKey;
|
|
21803
|
+
}
|
|
21693
21804
|
}
|
|
21694
21805
|
}
|
|
21695
21806
|
if (this.config.subprovider) {
|
|
21696
|
-
const
|
|
21807
|
+
const resolvedProvider = resolveCliProvider(this.config.subprovider);
|
|
21697
21808
|
const PROVIDER_OWN_PREFIXES = {
|
|
21698
21809
|
openrouter: ["OPENROUTER_"],
|
|
21699
21810
|
anthropic: ["ANTHROPIC_"],
|
|
21700
21811
|
openai: ["OPENAI_"],
|
|
21701
|
-
azure: ["AZURE_OPENAI_"],
|
|
21812
|
+
"azure-openai-responses": ["AZURE_OPENAI_"],
|
|
21702
21813
|
google: ["GEMINI_", "GOOGLE_GENERATIVE_AI_"],
|
|
21703
21814
|
gemini: ["GEMINI_", "GOOGLE_GENERATIVE_AI_"],
|
|
21704
21815
|
groq: ["GROQ_"],
|
|
21705
21816
|
xai: ["XAI_"]
|
|
21706
21817
|
};
|
|
21707
|
-
const ownPrefixes = PROVIDER_OWN_PREFIXES[
|
|
21818
|
+
const ownPrefixes = PROVIDER_OWN_PREFIXES[resolvedProvider] ?? [];
|
|
21708
21819
|
const allOtherPrefixes = Object.entries(PROVIDER_OWN_PREFIXES).filter(([key]) => key !== provider).flatMap(([, prefixes]) => prefixes);
|
|
21709
21820
|
for (const key of Object.keys(env)) {
|
|
21710
21821
|
if (allOtherPrefixes.some((prefix) => key.startsWith(prefix)) && !ownPrefixes.some((prefix) => key.startsWith(prefix))) {
|
|
@@ -21995,6 +22106,24 @@ function extractMessages(events) {
|
|
|
21995
22106
|
}
|
|
21996
22107
|
}
|
|
21997
22108
|
}
|
|
22109
|
+
if (messages) {
|
|
22110
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
22111
|
+
if (messages[i].role === "assistant" && !messages[i].content) {
|
|
22112
|
+
for (let j = events.length - 1; j >= 0; j--) {
|
|
22113
|
+
const evt = events[j];
|
|
22114
|
+
if (!evt || evt.type !== "message_end") continue;
|
|
22115
|
+
const msg = evt.message;
|
|
22116
|
+
if (msg?.role !== "assistant") continue;
|
|
22117
|
+
const text2 = extractPiTextContent(msg.content);
|
|
22118
|
+
if (text2) {
|
|
22119
|
+
messages[i] = { ...messages[i], content: text2 };
|
|
22120
|
+
break;
|
|
22121
|
+
}
|
|
22122
|
+
}
|
|
22123
|
+
break;
|
|
22124
|
+
}
|
|
22125
|
+
}
|
|
22126
|
+
}
|
|
21998
22127
|
const eventToolCalls = extractToolCallsFromEvents(events);
|
|
21999
22128
|
if (eventToolCalls.length > 0) {
|
|
22000
22129
|
injectEventToolCalls(messages, eventToolCalls);
|
|
@@ -22179,17 +22308,43 @@ function formatTimeoutSuffix3(timeoutMs) {
|
|
|
22179
22308
|
if (!timeoutMs || timeoutMs <= 0) return "";
|
|
22180
22309
|
return ` after ${Math.ceil(timeoutMs / 1e3)}s`;
|
|
22181
22310
|
}
|
|
22311
|
+
function resolveWindowsCmd(executable) {
|
|
22312
|
+
if (process.platform !== "win32") return [executable, []];
|
|
22313
|
+
const lower = executable.toLowerCase();
|
|
22314
|
+
if (lower.endsWith(".js") || lower.endsWith(".exe")) return [executable, []];
|
|
22315
|
+
let fullPath;
|
|
22316
|
+
try {
|
|
22317
|
+
fullPath = execSync(`where ${executable}`, { encoding: "utf-8" }).trim().split(/\r?\n/)[0].trim();
|
|
22318
|
+
} catch {
|
|
22319
|
+
return [executable, []];
|
|
22320
|
+
}
|
|
22321
|
+
const cmdPath = fullPath.endsWith(".cmd") ? fullPath : `${fullPath}.cmd`;
|
|
22322
|
+
try {
|
|
22323
|
+
const content = readFileSync2(cmdPath, "utf-8");
|
|
22324
|
+
const match = content.match(/"?%_prog%"?\s+"([^"]+\.js)"/);
|
|
22325
|
+
if (match) {
|
|
22326
|
+
const dp0 = path19.dirname(path19.resolve(cmdPath));
|
|
22327
|
+
const scriptPath = match[1].replace(/%dp0%[/\\]?/gi, `${dp0}${path19.sep}`);
|
|
22328
|
+
try {
|
|
22329
|
+
accessSync(scriptPath);
|
|
22330
|
+
return ["node", [scriptPath]];
|
|
22331
|
+
} catch {
|
|
22332
|
+
}
|
|
22333
|
+
}
|
|
22334
|
+
} catch {
|
|
22335
|
+
}
|
|
22336
|
+
return [executable, []];
|
|
22337
|
+
}
|
|
22182
22338
|
async function defaultPiRunner(options) {
|
|
22183
22339
|
return await new Promise((resolve2, reject) => {
|
|
22184
22340
|
const parts = options.executable.split(/\s+/);
|
|
22185
|
-
const
|
|
22186
|
-
const executableArgs = parts.slice(1);
|
|
22341
|
+
const [resolvedExe, prefixArgs] = resolveWindowsCmd(parts[0]);
|
|
22342
|
+
const executableArgs = [...prefixArgs, ...parts.slice(1)];
|
|
22187
22343
|
const allArgs = [...executableArgs, ...options.args];
|
|
22188
|
-
const child = spawn3(
|
|
22344
|
+
const child = spawn3(resolvedExe, allArgs, {
|
|
22189
22345
|
cwd: options.cwd,
|
|
22190
22346
|
env: options.env,
|
|
22191
|
-
stdio: ["pipe", "pipe", "pipe"]
|
|
22192
|
-
shell: false
|
|
22347
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
22193
22348
|
});
|
|
22194
22349
|
let stdout = "";
|
|
22195
22350
|
let stderr = "";
|
|
@@ -22265,7 +22420,7 @@ function findAgentvRoot() {
|
|
|
22265
22420
|
for (let i = 0; i < 10; i++) {
|
|
22266
22421
|
try {
|
|
22267
22422
|
const pkg = path20.join(dir, "package.json");
|
|
22268
|
-
|
|
22423
|
+
accessSync2(pkg);
|
|
22269
22424
|
return dir;
|
|
22270
22425
|
} catch {
|
|
22271
22426
|
const parent = path20.dirname(dir);
|
|
@@ -22285,7 +22440,7 @@ async function doLoadSdkModules() {
|
|
|
22285
22440
|
if (await promptInstall()) {
|
|
22286
22441
|
const installDir = findAgentvRoot();
|
|
22287
22442
|
console.error(`Installing @mariozechner/pi-coding-agent into ${installDir}...`);
|
|
22288
|
-
|
|
22443
|
+
execSync2("bun add @mariozechner/pi-coding-agent", {
|
|
22289
22444
|
cwd: installDir,
|
|
22290
22445
|
stdio: "inherit"
|
|
22291
22446
|
});
|
|
@@ -22326,7 +22481,9 @@ async function loadSdkModules() {
|
|
|
22326
22481
|
codingTools: piSdk.codingTools,
|
|
22327
22482
|
toolMap,
|
|
22328
22483
|
SessionManager: piSdk.SessionManager,
|
|
22329
|
-
getModel: piAi.getModel
|
|
22484
|
+
getModel: piAi.getModel,
|
|
22485
|
+
// biome-ignore lint/suspicious/noExplicitAny: registerBuiltInApiProviders exists at runtime but not in type defs
|
|
22486
|
+
registerBuiltInApiProviders: piAi.registerBuiltInApiProviders
|
|
22330
22487
|
};
|
|
22331
22488
|
}
|
|
22332
22489
|
var PiCodingAgentProvider = class {
|
|
@@ -22348,17 +22505,31 @@ var PiCodingAgentProvider = class {
|
|
|
22348
22505
|
const startTime = (/* @__PURE__ */ new Date()).toISOString();
|
|
22349
22506
|
const startMs = Date.now();
|
|
22350
22507
|
const sdk = await loadSdkModules();
|
|
22508
|
+
sdk.registerBuiltInApiProviders();
|
|
22351
22509
|
const logger = await this.createStreamLogger(request).catch(() => void 0);
|
|
22352
22510
|
try {
|
|
22353
22511
|
const cwd = this.resolveCwd(request.cwd);
|
|
22354
|
-
const
|
|
22512
|
+
const rawProvider = this.config.subprovider ?? "google";
|
|
22513
|
+
const hasBaseUrl = !!this.config.baseUrl;
|
|
22514
|
+
const providerName = resolveSubprovider(rawProvider, hasBaseUrl);
|
|
22355
22515
|
const modelId = this.config.model ?? "gemini-2.5-flash";
|
|
22356
|
-
this.setApiKeyEnv(
|
|
22357
|
-
|
|
22516
|
+
this.setApiKeyEnv(rawProvider, hasBaseUrl);
|
|
22517
|
+
this.setBaseUrlEnv(rawProvider, hasBaseUrl);
|
|
22518
|
+
let model = sdk.getModel(providerName, modelId);
|
|
22358
22519
|
if (!model) {
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
|
|
22520
|
+
const envProvider = providerName.replace(/-responses$/, "");
|
|
22521
|
+
model = {
|
|
22522
|
+
id: modelId,
|
|
22523
|
+
name: modelId,
|
|
22524
|
+
api: providerName,
|
|
22525
|
+
provider: envProvider,
|
|
22526
|
+
baseUrl: this.config.baseUrl ?? "",
|
|
22527
|
+
reasoning: false,
|
|
22528
|
+
input: ["text"],
|
|
22529
|
+
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
|
22530
|
+
contextWindow: 128e3,
|
|
22531
|
+
maxTokens: 16384
|
|
22532
|
+
};
|
|
22362
22533
|
}
|
|
22363
22534
|
const tools = this.resolveTools(sdk);
|
|
22364
22535
|
const { session } = await sdk.createAgentSession({
|
|
@@ -22511,22 +22682,21 @@ ${fileList}`;
|
|
|
22511
22682
|
}
|
|
22512
22683
|
}
|
|
22513
22684
|
/** Maps config apiKey to the provider-specific env var the SDK reads. */
|
|
22514
|
-
setApiKeyEnv(providerName) {
|
|
22685
|
+
setApiKeyEnv(providerName, hasBaseUrl = false) {
|
|
22515
22686
|
if (!this.config.apiKey) return;
|
|
22516
|
-
const
|
|
22517
|
-
google: "GEMINI_API_KEY",
|
|
22518
|
-
gemini: "GEMINI_API_KEY",
|
|
22519
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
22520
|
-
openai: "OPENAI_API_KEY",
|
|
22521
|
-
groq: "GROQ_API_KEY",
|
|
22522
|
-
xai: "XAI_API_KEY",
|
|
22523
|
-
openrouter: "OPENROUTER_API_KEY"
|
|
22524
|
-
};
|
|
22525
|
-
const envKey = ENV_KEY_MAP[providerName.toLowerCase()];
|
|
22687
|
+
const envKey = resolveEnvKeyName(providerName, hasBaseUrl);
|
|
22526
22688
|
if (envKey) {
|
|
22527
22689
|
process.env[envKey] = this.config.apiKey;
|
|
22528
22690
|
}
|
|
22529
22691
|
}
|
|
22692
|
+
/** Maps config baseUrl to the provider-specific env var the SDK reads. */
|
|
22693
|
+
setBaseUrlEnv(providerName, hasBaseUrl = false) {
|
|
22694
|
+
if (!this.config.baseUrl) return;
|
|
22695
|
+
const envKey = resolveEnvBaseUrlName(providerName, hasBaseUrl);
|
|
22696
|
+
if (envKey) {
|
|
22697
|
+
process.env[envKey] = this.config.baseUrl;
|
|
22698
|
+
}
|
|
22699
|
+
}
|
|
22530
22700
|
resolveCwd(cwdOverride) {
|
|
22531
22701
|
if (cwdOverride) {
|
|
22532
22702
|
return path20.resolve(cwdOverride);
|
|
@@ -29468,20 +29638,10 @@ async function runEvaluation(options) {
|
|
|
29468
29638
|
if (resolvedTargetsByName.has(name21)) {
|
|
29469
29639
|
return resolvedTargetsByName.get(name21);
|
|
29470
29640
|
}
|
|
29471
|
-
|
|
29641
|
+
const definition = resolveDelegatedTargetDefinition(name21, targetDefinitions, envLookup);
|
|
29472
29642
|
if (!definition) {
|
|
29473
29643
|
return void 0;
|
|
29474
29644
|
}
|
|
29475
|
-
for (let depth = 0; depth < 5; depth++) {
|
|
29476
|
-
const useTarget = definition.use_target;
|
|
29477
|
-
if (typeof useTarget !== "string" || useTarget.trim().length === 0) break;
|
|
29478
|
-
const envMatch = useTarget.trim().match(/^\$\{\{\s*([A-Z0-9_]+)\s*\}\}$/i);
|
|
29479
|
-
const resolvedName = envMatch ? envLookup[envMatch[1]] ?? "" : useTarget.trim();
|
|
29480
|
-
if (resolvedName.length === 0) break;
|
|
29481
|
-
const next = targetDefinitions.get(resolvedName);
|
|
29482
|
-
if (!next) break;
|
|
29483
|
-
definition = next;
|
|
29484
|
-
}
|
|
29485
29645
|
const resolved = resolveTargetDefinition(definition, envLookup, evalFilePath);
|
|
29486
29646
|
resolvedTargetsByName.set(name21, resolved);
|
|
29487
29647
|
return resolved;
|
|
@@ -31559,7 +31719,7 @@ async function discoverDefaultTarget(repoRoot) {
|
|
|
31559
31719
|
return null;
|
|
31560
31720
|
}
|
|
31561
31721
|
async function loadEnvHierarchy(repoRoot, startPath) {
|
|
31562
|
-
const { readFileSync:
|
|
31722
|
+
const { readFileSync: readFileSync4 } = await import("node:fs");
|
|
31563
31723
|
const chain = buildDirectoryChain(startPath, repoRoot);
|
|
31564
31724
|
const envFiles = [];
|
|
31565
31725
|
for (const dir of chain) {
|
|
@@ -31568,7 +31728,7 @@ async function loadEnvHierarchy(repoRoot, startPath) {
|
|
|
31568
31728
|
}
|
|
31569
31729
|
for (let i = 0; i < envFiles.length; i++) {
|
|
31570
31730
|
try {
|
|
31571
|
-
const content =
|
|
31731
|
+
const content = readFileSync4(envFiles[i], "utf8");
|
|
31572
31732
|
for (const line of content.split("\n")) {
|
|
31573
31733
|
const trimmed = line.trim();
|
|
31574
31734
|
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
@@ -31779,7 +31939,7 @@ function loadProjectRegistry() {
|
|
|
31779
31939
|
return { projects: [] };
|
|
31780
31940
|
}
|
|
31781
31941
|
try {
|
|
31782
|
-
const raw =
|
|
31942
|
+
const raw = readFileSync3(registryPath, "utf-8");
|
|
31783
31943
|
const parsed = parseYaml3(raw);
|
|
31784
31944
|
if (!parsed || !Array.isArray(parsed.projects)) {
|
|
31785
31945
|
return { projects: [] };
|
|
@@ -32684,6 +32844,7 @@ export {
|
|
|
32684
32844
|
resolveFileReference,
|
|
32685
32845
|
CLI_PLACEHOLDERS,
|
|
32686
32846
|
COMMON_TARGET_SETTINGS,
|
|
32847
|
+
resolveDelegatedTargetDefinition,
|
|
32687
32848
|
resolveTargetDefinition,
|
|
32688
32849
|
KNOWN_PROVIDERS,
|
|
32689
32850
|
PROVIDER_ALIASES,
|
|
@@ -32835,4 +32996,4 @@ export {
|
|
|
32835
32996
|
readTranscriptFile,
|
|
32836
32997
|
createAgentKernel
|
|
32837
32998
|
};
|
|
32838
|
-
//# sourceMappingURL=chunk-
|
|
32999
|
+
//# sourceMappingURL=chunk-YXXD27OK.js.map
|