agentv 4.13.0 → 4.14.0
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-72AVLOSN.js → chunk-HP3ZUKYB.js} +846 -509
- package/dist/chunk-HP3ZUKYB.js.map +1 -0
- package/dist/{chunk-R747FXKW.js → chunk-IX3FYDXN.js} +5 -5
- package/dist/chunk-IX3FYDXN.js.map +1 -0
- package/dist/{chunk-I4BXYYI6.js → chunk-XDIQBOPH.js} +11 -26
- package/dist/chunk-XDIQBOPH.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/{dist-SG5AIKQK.js → dist-Y3NRIBUT.js} +2 -2
- package/dist/index.js +3 -3
- package/dist/{interactive-ENAAA4RQ.js → interactive-TNCUWC46.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-72AVLOSN.js.map +0 -1
- package/dist/chunk-I4BXYYI6.js.map +0 -1
- package/dist/chunk-R747FXKW.js.map +0 -1
- /package/dist/{dist-SG5AIKQK.js.map → dist-Y3NRIBUT.js.map} +0 -0
- /package/dist/{interactive-ENAAA4RQ.js.map → interactive-TNCUWC46.js.map} +0 -0
|
@@ -305,7 +305,7 @@ var require_dist = __commonJS({
|
|
|
305
305
|
}
|
|
306
306
|
});
|
|
307
307
|
|
|
308
|
-
// ../../packages/core/dist/chunk-
|
|
308
|
+
// ../../packages/core/dist/chunk-A3HYVKTI.js
|
|
309
309
|
import { constants } from "node:fs";
|
|
310
310
|
import { access, readFile } from "node:fs/promises";
|
|
311
311
|
import path from "node:path";
|
|
@@ -423,7 +423,7 @@ __export(external_exports2, {
|
|
|
423
423
|
void: () => voidType
|
|
424
424
|
});
|
|
425
425
|
|
|
426
|
-
// ../../packages/core/dist/chunk-
|
|
426
|
+
// ../../packages/core/dist/chunk-A3HYVKTI.js
|
|
427
427
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
428
428
|
import path3 from "node:path";
|
|
429
429
|
import fg from "fast-glob";
|
|
@@ -12986,7 +12986,8 @@ import { mkdir as mkdir3 } from "node:fs/promises";
|
|
|
12986
12986
|
import path14 from "node:path";
|
|
12987
12987
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
12988
12988
|
import { mkdir as mkdir4 } from "node:fs/promises";
|
|
12989
|
-
import
|
|
12989
|
+
import { homedir as homedir2 } from "node:os";
|
|
12990
|
+
import path17 from "node:path";
|
|
12990
12991
|
import { Readable, Writable } from "node:stream";
|
|
12991
12992
|
import { spawn as spawn2 } from "node:child_process";
|
|
12992
12993
|
|
|
@@ -14468,66 +14469,71 @@ var RequestError = class _RequestError extends Error {
|
|
|
14468
14469
|
};
|
|
14469
14470
|
|
|
14470
14471
|
// ../../packages/core/dist/index.js
|
|
14472
|
+
import { exec as execCallback } from "node:child_process";
|
|
14473
|
+
import { readdirSync, statSync } from "node:fs";
|
|
14474
|
+
import { readFile as readFile9, readdir, stat } from "node:fs/promises";
|
|
14475
|
+
import path15 from "node:path";
|
|
14476
|
+
import { promisify as promisify2 } from "node:util";
|
|
14471
14477
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
14472
|
-
import { createWriteStream as createWriteStream4, existsSync, readdirSync } from "node:fs";
|
|
14478
|
+
import { createWriteStream as createWriteStream4, existsSync, readdirSync as readdirSync2 } from "node:fs";
|
|
14473
14479
|
import { arch, homedir, platform } from "node:os";
|
|
14474
|
-
import
|
|
14480
|
+
import path16 from "node:path";
|
|
14475
14481
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
14476
|
-
import { readFile as
|
|
14482
|
+
import { readFile as readFile11 } from "node:fs/promises";
|
|
14483
|
+
import { homedir as homedir4 } from "node:os";
|
|
14484
|
+
import path19 from "node:path";
|
|
14485
|
+
import { readFile as readFile10, readdir as readdir2, stat as stat2 } from "node:fs/promises";
|
|
14477
14486
|
import { homedir as homedir3 } from "node:os";
|
|
14478
14487
|
import path18 from "node:path";
|
|
14479
|
-
import { readFile as readFile9, readdir, stat } from "node:fs/promises";
|
|
14480
|
-
import { homedir as homedir2 } from "node:os";
|
|
14481
|
-
import path17 from "node:path";
|
|
14482
14488
|
import { parse as parseYaml22 } from "yaml";
|
|
14483
14489
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
14484
14490
|
import { existsSync as existsSync2 } from "node:fs";
|
|
14485
14491
|
import { mkdir as mkdir5 } from "node:fs/promises";
|
|
14486
|
-
import
|
|
14492
|
+
import path20 from "node:path";
|
|
14487
14493
|
import { execSync, spawn as spawn3 } from "node:child_process";
|
|
14488
14494
|
import { randomUUID as randomUUID7 } from "node:crypto";
|
|
14489
14495
|
import { accessSync, createWriteStream as createWriteStream5, readFileSync as readFileSync2 } from "node:fs";
|
|
14490
14496
|
import { mkdir as mkdir6, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
14491
14497
|
import { tmpdir } from "node:os";
|
|
14492
|
-
import
|
|
14498
|
+
import path21 from "node:path";
|
|
14493
14499
|
import { execSync as execSync2 } from "node:child_process";
|
|
14494
14500
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
14495
14501
|
import { accessSync as accessSync2, createWriteStream as createWriteStream6, mkdirSync } from "node:fs";
|
|
14496
14502
|
import { mkdir as mkdir7 } from "node:fs/promises";
|
|
14497
|
-
import
|
|
14503
|
+
import path23 from "node:path";
|
|
14498
14504
|
import { createInterface } from "node:readline";
|
|
14499
14505
|
import { fileURLToPath as fileURLToPath4, pathToFileURL } from "node:url";
|
|
14500
14506
|
import os2 from "node:os";
|
|
14501
|
-
import
|
|
14507
|
+
import path222 from "node:path";
|
|
14502
14508
|
import { exec as exec2 } from "node:child_process";
|
|
14503
|
-
import { constants as constants3, access as access3, stat as
|
|
14504
|
-
import
|
|
14505
|
-
import { promisify as
|
|
14506
|
-
import { stat as
|
|
14507
|
-
import
|
|
14509
|
+
import { constants as constants3, access as access3, stat as stat6 } from "node:fs/promises";
|
|
14510
|
+
import path34 from "node:path";
|
|
14511
|
+
import { promisify as promisify4 } from "node:util";
|
|
14512
|
+
import { stat as stat5, writeFile as writeFile4 } from "node:fs/promises";
|
|
14513
|
+
import path322 from "node:path";
|
|
14508
14514
|
import { constants as constants22 } from "node:fs";
|
|
14509
|
-
import { access as access22, mkdir as mkdir8, readdir as
|
|
14510
|
-
import path23 from "node:path";
|
|
14515
|
+
import { access as access22, mkdir as mkdir8, readdir as readdir3, rm as rm2, stat as stat3 } from "node:fs/promises";
|
|
14511
14516
|
import path24 from "node:path";
|
|
14512
14517
|
import path25 from "node:path";
|
|
14513
|
-
import { readFile as readFile11 } from "node:fs/promises";
|
|
14514
14518
|
import path26 from "node:path";
|
|
14519
|
+
import { readFile as readFile12 } from "node:fs/promises";
|
|
14520
|
+
import path27 from "node:path";
|
|
14515
14521
|
import { exec, spawn as spawn4 } from "node:child_process";
|
|
14516
14522
|
import { mkdir as mkdir9, writeFile as writeFile2 } from "node:fs/promises";
|
|
14523
|
+
import path29 from "node:path";
|
|
14524
|
+
import { promisify as promisify3 } from "node:util";
|
|
14517
14525
|
import path28 from "node:path";
|
|
14518
|
-
import {
|
|
14519
|
-
import
|
|
14520
|
-
import { copyFile, mkdir as mkdir10, readFile as readFile12, readdir as readdir3, stat as stat3, writeFile as writeFile3 } from "node:fs/promises";
|
|
14526
|
+
import { copyFile, mkdir as mkdir10, readFile as readFile13, readdir as readdir4, stat as stat4, writeFile as writeFile3 } from "node:fs/promises";
|
|
14527
|
+
import path31 from "node:path";
|
|
14521
14528
|
import path30 from "node:path";
|
|
14522
|
-
import path29 from "node:path";
|
|
14523
14529
|
import JSON5 from "json5";
|
|
14524
14530
|
import { writeFile as writeFile5 } from "node:fs/promises";
|
|
14525
|
-
import
|
|
14531
|
+
import path33 from "node:path";
|
|
14526
14532
|
import { constants as constants4 } from "node:fs";
|
|
14527
|
-
import { access as access4, readFile as
|
|
14528
|
-
import path34 from "node:path";
|
|
14529
|
-
import { parse as parse5 } from "yaml";
|
|
14533
|
+
import { access as access4, readFile as readFile14 } from "node:fs/promises";
|
|
14530
14534
|
import path35 from "node:path";
|
|
14535
|
+
import { parse as parse5 } from "yaml";
|
|
14536
|
+
import path36 from "node:path";
|
|
14531
14537
|
import fg2 from "fast-glob";
|
|
14532
14538
|
import { mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
|
|
14533
14539
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
@@ -14535,58 +14541,54 @@ import { dirname, join } from "node:path";
|
|
|
14535
14541
|
import { randomBytes } from "node:crypto";
|
|
14536
14542
|
import { createServer } from "node:http";
|
|
14537
14543
|
import fs2 from "node:fs/promises";
|
|
14538
|
-
import
|
|
14544
|
+
import path37 from "node:path";
|
|
14539
14545
|
import { createHash as createHash2, randomUUID as randomUUID9 } from "node:crypto";
|
|
14540
14546
|
import { existsSync as existsSync5 } from "node:fs";
|
|
14541
|
-
import { copyFile as copyFile2, mkdir as mkdir14, readdir as
|
|
14547
|
+
import { copyFile as copyFile2, mkdir as mkdir14, readdir as readdir8, stat as stat9 } from "node:fs/promises";
|
|
14542
14548
|
import path45 from "node:path";
|
|
14543
14549
|
import micromatch3 from "micromatch";
|
|
14544
|
-
import path37 from "node:path";
|
|
14545
14550
|
import path38 from "node:path";
|
|
14546
|
-
import fg22 from "fast-glob";
|
|
14547
14551
|
import path39 from "node:path";
|
|
14548
|
-
import
|
|
14549
|
-
import { exec as execCallback } from "node:child_process";
|
|
14550
|
-
import { readdirSync as readdirSync2, statSync } from "node:fs";
|
|
14552
|
+
import fg22 from "fast-glob";
|
|
14551
14553
|
import path40 from "node:path";
|
|
14552
|
-
import
|
|
14553
|
-
import { cp, mkdir as mkdir12, readdir as
|
|
14554
|
+
import fg3 from "fast-glob";
|
|
14555
|
+
import { cp, mkdir as mkdir12, readdir as readdir5, rm as rm4, stat as stat7 } from "node:fs/promises";
|
|
14554
14556
|
import path41 from "node:path";
|
|
14555
14557
|
import { execFile } from "node:child_process";
|
|
14556
14558
|
import { createHash } from "node:crypto";
|
|
14557
14559
|
import { existsSync as existsSync3 } from "node:fs";
|
|
14558
|
-
import { cp as cp2, mkdir as mkdir13, readFile as
|
|
14560
|
+
import { cp as cp2, mkdir as mkdir13, readFile as readFile15, readdir as readdir6, rm as rm5, unlink, writeFile as writeFile7 } from "node:fs/promises";
|
|
14559
14561
|
import path422 from "node:path";
|
|
14560
14562
|
import { promisify as promisify5 } from "node:util";
|
|
14561
14563
|
import { execFile as execFile2 } from "node:child_process";
|
|
14562
14564
|
import { existsSync as existsSync4 } from "node:fs";
|
|
14563
14565
|
import path43 from "node:path";
|
|
14564
14566
|
import { promisify as promisify6 } from "node:util";
|
|
14565
|
-
import { readdir as
|
|
14567
|
+
import { readdir as readdir7, stat as stat8 } from "node:fs/promises";
|
|
14566
14568
|
import path44 from "node:path";
|
|
14567
14569
|
import { existsSync as existsSync6 } from "node:fs";
|
|
14568
14570
|
import path46 from "node:path";
|
|
14569
|
-
import { readFile as
|
|
14571
|
+
import { readFile as readFile16 } from "node:fs/promises";
|
|
14570
14572
|
import path47 from "node:path";
|
|
14571
14573
|
import { parse as parse6 } from "yaml";
|
|
14572
|
-
import { mkdir as mkdir15, readFile as
|
|
14574
|
+
import { mkdir as mkdir15, readFile as readFile17, writeFile as writeFile8 } from "node:fs/promises";
|
|
14573
14575
|
import path48 from "node:path";
|
|
14574
14576
|
import { execFile as execFile3 } from "node:child_process";
|
|
14575
14577
|
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync, writeFileSync } from "node:fs";
|
|
14576
|
-
import { cp as cp3, mkdtemp as mkdtemp3, readdir as
|
|
14578
|
+
import { cp as cp3, mkdtemp as mkdtemp3, readdir as readdir9, rm as rm6, stat as stat10 } from "node:fs/promises";
|
|
14577
14579
|
import os3 from "node:os";
|
|
14578
14580
|
import path49 from "node:path";
|
|
14579
14581
|
import { promisify as promisify7 } from "node:util";
|
|
14580
14582
|
import { existsSync as existsSync8, mkdirSync as mkdirSync3, readFileSync as readFileSync4, readdirSync as readdirSync3, statSync as statSync2, writeFileSync as writeFileSync2 } from "node:fs";
|
|
14581
14583
|
import path50 from "node:path";
|
|
14582
14584
|
import { parse as parseYaml3, stringify as stringifyYaml } from "yaml";
|
|
14583
|
-
import { readdir as readdir9, stat as stat10 } from "node:fs/promises";
|
|
14584
|
-
import { homedir as homedir4 } from "node:os";
|
|
14585
|
-
import path51 from "node:path";
|
|
14586
14585
|
import { readdir as readdir10, stat as stat11 } from "node:fs/promises";
|
|
14587
14586
|
import { homedir as homedir5 } from "node:os";
|
|
14587
|
+
import path51 from "node:path";
|
|
14588
|
+
import { readdir as readdir11, stat as stat12 } from "node:fs/promises";
|
|
14589
|
+
import { homedir as homedir6 } from "node:os";
|
|
14588
14590
|
import path52 from "node:path";
|
|
14589
|
-
import { readFile as
|
|
14591
|
+
import { readFile as readFile18 } from "node:fs/promises";
|
|
14590
14592
|
function computeTraceSummary(messages) {
|
|
14591
14593
|
const toolCallCounts = {};
|
|
14592
14594
|
const toolDurations = {};
|
|
@@ -18043,7 +18045,11 @@ async function loadTestSuite(evalFilePath, repoRoot, options) {
|
|
|
18043
18045
|
if (format === "agent-skills-json") {
|
|
18044
18046
|
return { tests: await loadTestsFromAgentSkills(evalFilePath) };
|
|
18045
18047
|
}
|
|
18046
|
-
const { tests, parsed } = await loadTestsFromYaml(
|
|
18048
|
+
const { tests, parsed, suiteWorkspacePath } = await loadTestsFromYaml(
|
|
18049
|
+
evalFilePath,
|
|
18050
|
+
repoRoot,
|
|
18051
|
+
options
|
|
18052
|
+
);
|
|
18047
18053
|
const metadata = parseMetadata(parsed);
|
|
18048
18054
|
const failOnError = extractFailOnError(parsed);
|
|
18049
18055
|
const threshold = extractThreshold(parsed);
|
|
@@ -18056,7 +18062,8 @@ async function loadTestSuite(evalFilePath, repoRoot, options) {
|
|
|
18056
18062
|
totalBudgetUsd: extractTotalBudgetUsd(parsed),
|
|
18057
18063
|
...metadata !== void 0 && { metadata },
|
|
18058
18064
|
...failOnError !== void 0 && { failOnError },
|
|
18059
|
-
...threshold !== void 0 && { threshold }
|
|
18065
|
+
...threshold !== void 0 && { threshold },
|
|
18066
|
+
...suiteWorkspacePath !== void 0 && { workspacePath: suiteWorkspacePath }
|
|
18060
18067
|
};
|
|
18061
18068
|
}
|
|
18062
18069
|
var loadEvalSuite = loadTestSuite;
|
|
@@ -18218,6 +18225,11 @@ async function loadTestsFromYaml(evalFilePath, repoRoot, options) {
|
|
|
18218
18225
|
const mergedWorkspace = mergeWorkspaceConfigs(suiteWorkspace, caseWorkspace);
|
|
18219
18226
|
const metadata = isJsonObject(testCaseConfig.metadata) ? testCaseConfig.metadata : void 0;
|
|
18220
18227
|
const caseTargets = extractTargetsFromTestCase(testCaseConfig);
|
|
18228
|
+
const dependsOn = Array.isArray(testCaseConfig.depends_on) ? testCaseConfig.depends_on.filter(
|
|
18229
|
+
(v) => typeof v === "string"
|
|
18230
|
+
) : void 0;
|
|
18231
|
+
const onDependencyFailureRaw = asString5(testCaseConfig.on_dependency_failure);
|
|
18232
|
+
const onDependencyFailure = onDependencyFailureRaw === "skip" || onDependencyFailureRaw === "fail" || onDependencyFailureRaw === "run" ? onDependencyFailureRaw : void 0;
|
|
18221
18233
|
const testCase = {
|
|
18222
18234
|
id,
|
|
18223
18235
|
suite: suiteName,
|
|
@@ -18235,11 +18247,13 @@ async function loadTestsFromYaml(evalFilePath, repoRoot, options) {
|
|
|
18235
18247
|
workspace: mergedWorkspace,
|
|
18236
18248
|
metadata,
|
|
18237
18249
|
targets: caseTargets,
|
|
18238
|
-
...caseThreshold !== void 0 ? { threshold: caseThreshold } : {}
|
|
18250
|
+
...caseThreshold !== void 0 ? { threshold: caseThreshold } : {},
|
|
18251
|
+
...dependsOn && dependsOn.length > 0 ? { depends_on: dependsOn } : {},
|
|
18252
|
+
...onDependencyFailure ? { on_dependency_failure: onDependencyFailure } : {}
|
|
18239
18253
|
};
|
|
18240
18254
|
results.push(testCase);
|
|
18241
18255
|
}
|
|
18242
|
-
return { tests: results, parsed: suite };
|
|
18256
|
+
return { tests: results, parsed: suite, suiteWorkspacePath: suiteWorkspace?.path };
|
|
18243
18257
|
}
|
|
18244
18258
|
async function loadTestById(evalFilePath, repoRoot, evalId) {
|
|
18245
18259
|
const tests = await loadTests(evalFilePath, repoRoot);
|
|
@@ -21030,6 +21044,110 @@ function formatElapsed3(startedAt) {
|
|
|
21030
21044
|
}
|
|
21031
21045
|
return `${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`;
|
|
21032
21046
|
}
|
|
21047
|
+
var execAsync2 = promisify2(execCallback);
|
|
21048
|
+
var SNAPSHOT_MAX_FILE_BYTES = 512 * 1024;
|
|
21049
|
+
var SNAPSHOT_EXCLUDE_DIRS = /* @__PURE__ */ new Set([".git", "node_modules", ".agentv", "__pycache__"]);
|
|
21050
|
+
function gitExecOpts(workspacePath) {
|
|
21051
|
+
const { GIT_DIR: _, GIT_WORK_TREE: __, ...env } = process.env;
|
|
21052
|
+
return { cwd: workspacePath, env };
|
|
21053
|
+
}
|
|
21054
|
+
async function initializeBaseline(workspacePath) {
|
|
21055
|
+
const opts = gitExecOpts(workspacePath);
|
|
21056
|
+
await execAsync2("git init", opts);
|
|
21057
|
+
await execAsync2("git add -A", opts);
|
|
21058
|
+
await execAsync2(
|
|
21059
|
+
'git -c user.email=agentv@localhost -c user.name=agentv commit --allow-empty -m "agentv-baseline"',
|
|
21060
|
+
opts
|
|
21061
|
+
);
|
|
21062
|
+
const { stdout } = await execAsync2("git rev-parse HEAD", opts);
|
|
21063
|
+
return stdout.trim();
|
|
21064
|
+
}
|
|
21065
|
+
async function captureFileChanges(workspacePath, baselineCommit) {
|
|
21066
|
+
const opts = gitExecOpts(workspacePath);
|
|
21067
|
+
await stageNestedRepoChanges(workspacePath);
|
|
21068
|
+
await execAsync2("git add -A", opts);
|
|
21069
|
+
const { stdout } = await execAsync2(`git diff ${baselineCommit} --submodule=diff`, opts);
|
|
21070
|
+
return stdout.trim();
|
|
21071
|
+
}
|
|
21072
|
+
async function stageNestedRepoChanges(workspacePath) {
|
|
21073
|
+
let entries;
|
|
21074
|
+
try {
|
|
21075
|
+
entries = readdirSync(workspacePath);
|
|
21076
|
+
} catch {
|
|
21077
|
+
return;
|
|
21078
|
+
}
|
|
21079
|
+
for (const entry of entries) {
|
|
21080
|
+
if (entry === ".git" || entry === "node_modules") continue;
|
|
21081
|
+
const childPath = path15.join(workspacePath, entry);
|
|
21082
|
+
try {
|
|
21083
|
+
if (!statSync(childPath).isDirectory()) continue;
|
|
21084
|
+
if (!statSync(path15.join(childPath, ".git")).isDirectory()) continue;
|
|
21085
|
+
} catch {
|
|
21086
|
+
continue;
|
|
21087
|
+
}
|
|
21088
|
+
const childOpts = gitExecOpts(childPath);
|
|
21089
|
+
await execAsync2("git add -A", childOpts);
|
|
21090
|
+
}
|
|
21091
|
+
}
|
|
21092
|
+
async function captureSnapshot(dir) {
|
|
21093
|
+
const snapshot = /* @__PURE__ */ new Map();
|
|
21094
|
+
await walkDir(dir, dir, snapshot);
|
|
21095
|
+
return snapshot;
|
|
21096
|
+
}
|
|
21097
|
+
async function walkDir(rootDir, currentDir, snapshot) {
|
|
21098
|
+
let entries;
|
|
21099
|
+
try {
|
|
21100
|
+
entries = await readdir(currentDir);
|
|
21101
|
+
} catch {
|
|
21102
|
+
return;
|
|
21103
|
+
}
|
|
21104
|
+
for (const entry of entries) {
|
|
21105
|
+
if (SNAPSHOT_EXCLUDE_DIRS.has(entry)) continue;
|
|
21106
|
+
const fullPath = path15.join(currentDir, entry);
|
|
21107
|
+
let fileStat;
|
|
21108
|
+
try {
|
|
21109
|
+
fileStat = await stat(fullPath);
|
|
21110
|
+
} catch {
|
|
21111
|
+
continue;
|
|
21112
|
+
}
|
|
21113
|
+
if (fileStat.isDirectory()) {
|
|
21114
|
+
await walkDir(rootDir, fullPath, snapshot);
|
|
21115
|
+
} else if (fileStat.isFile()) {
|
|
21116
|
+
if (fileStat.size > SNAPSHOT_MAX_FILE_BYTES) continue;
|
|
21117
|
+
let content;
|
|
21118
|
+
try {
|
|
21119
|
+
content = await readFile9(fullPath, "utf8");
|
|
21120
|
+
if (content.includes("\0")) continue;
|
|
21121
|
+
} catch {
|
|
21122
|
+
continue;
|
|
21123
|
+
}
|
|
21124
|
+
const relativePath = path15.relative(rootDir, fullPath).replace(/\\/g, "/");
|
|
21125
|
+
snapshot.set(relativePath, content);
|
|
21126
|
+
}
|
|
21127
|
+
}
|
|
21128
|
+
}
|
|
21129
|
+
function generateNewFileDiff(relativePath, content) {
|
|
21130
|
+
const lines = content.endsWith("\n") ? content.slice(0, -1).split("\n") : content.split("\n");
|
|
21131
|
+
const addedLines = lines.map((l) => `+${l}`).join("\n");
|
|
21132
|
+
return [
|
|
21133
|
+
`diff --git a/${relativePath} b/${relativePath}`,
|
|
21134
|
+
"new file mode 100644",
|
|
21135
|
+
"--- /dev/null",
|
|
21136
|
+
`+++ b/${relativePath}`,
|
|
21137
|
+
`@@ -0,0 +1,${lines.length} @@`,
|
|
21138
|
+
addedLines
|
|
21139
|
+
].join("\n");
|
|
21140
|
+
}
|
|
21141
|
+
async function captureSessionArtifacts(filesDir, pathPrefix = "") {
|
|
21142
|
+
const snapshot = await captureSnapshot(filesDir).catch(() => void 0);
|
|
21143
|
+
if (!snapshot || snapshot.size === 0) return void 0;
|
|
21144
|
+
const parts = [];
|
|
21145
|
+
for (const [relPath, content] of snapshot) {
|
|
21146
|
+
const displayPath = pathPrefix ? `${pathPrefix}/${relPath}` : relPath;
|
|
21147
|
+
parts.push(generateNewFileDiff(displayPath, content));
|
|
21148
|
+
}
|
|
21149
|
+
return parts.join("\n");
|
|
21150
|
+
}
|
|
21033
21151
|
var GLOBAL_LOGS_KEY3 = Symbol.for("agentv.copilotCliLogs");
|
|
21034
21152
|
var GLOBAL_SUBSCRIBERS_KEY3 = Symbol.for("agentv.copilotCliLogSubscribers");
|
|
21035
21153
|
function getCopilotCliLogStore() {
|
|
@@ -21103,7 +21221,7 @@ function resolvePlatformCliPath() {
|
|
|
21103
21221
|
try {
|
|
21104
21222
|
const resolved = import.meta.resolve(`${packageName}/package.json`);
|
|
21105
21223
|
const packageJsonPath = resolved.startsWith("file:") ? fileURLToPath3(resolved) : resolved;
|
|
21106
|
-
const binaryPath =
|
|
21224
|
+
const binaryPath = path16.join(path16.dirname(packageJsonPath), binaryName);
|
|
21107
21225
|
if (existsSync(binaryPath)) {
|
|
21108
21226
|
return binaryPath;
|
|
21109
21227
|
}
|
|
@@ -21111,7 +21229,7 @@ function resolvePlatformCliPath() {
|
|
|
21111
21229
|
}
|
|
21112
21230
|
let searchDir = process.cwd();
|
|
21113
21231
|
for (let i = 0; i < 10; i++) {
|
|
21114
|
-
const standardPath =
|
|
21232
|
+
const standardPath = path16.join(
|
|
21115
21233
|
searchDir,
|
|
21116
21234
|
"node_modules",
|
|
21117
21235
|
...packageName.split("/"),
|
|
@@ -21120,13 +21238,13 @@ function resolvePlatformCliPath() {
|
|
|
21120
21238
|
if (existsSync(standardPath)) {
|
|
21121
21239
|
return standardPath;
|
|
21122
21240
|
}
|
|
21123
|
-
const bunDir =
|
|
21241
|
+
const bunDir = path16.join(searchDir, "node_modules", ".bun");
|
|
21124
21242
|
const prefix = `@github+copilot-${osPart}-${archPart}@`;
|
|
21125
21243
|
try {
|
|
21126
|
-
const entries =
|
|
21244
|
+
const entries = readdirSync2(bunDir);
|
|
21127
21245
|
for (const entry of entries) {
|
|
21128
21246
|
if (entry.startsWith(prefix)) {
|
|
21129
|
-
const candidate =
|
|
21247
|
+
const candidate = path16.join(
|
|
21130
21248
|
bunDir,
|
|
21131
21249
|
entry,
|
|
21132
21250
|
"node_modules",
|
|
@@ -21141,16 +21259,16 @@ function resolvePlatformCliPath() {
|
|
|
21141
21259
|
}
|
|
21142
21260
|
} catch {
|
|
21143
21261
|
}
|
|
21144
|
-
const parent =
|
|
21262
|
+
const parent = path16.dirname(searchDir);
|
|
21145
21263
|
if (parent === searchDir) break;
|
|
21146
21264
|
searchDir = parent;
|
|
21147
21265
|
}
|
|
21148
21266
|
for (const root of globalNpmRoots()) {
|
|
21149
|
-
const hoisted =
|
|
21267
|
+
const hoisted = path16.join(root, "@github", `copilot-${osPart}-${archPart}`, binaryName);
|
|
21150
21268
|
if (existsSync(hoisted)) {
|
|
21151
21269
|
return hoisted;
|
|
21152
21270
|
}
|
|
21153
|
-
const nested =
|
|
21271
|
+
const nested = path16.join(
|
|
21154
21272
|
root,
|
|
21155
21273
|
"@github",
|
|
21156
21274
|
"copilot",
|
|
@@ -21171,20 +21289,20 @@ function globalNpmRoots() {
|
|
|
21171
21289
|
const home = homedir();
|
|
21172
21290
|
if (os4 === "win32") {
|
|
21173
21291
|
if (process.env.APPDATA) {
|
|
21174
|
-
roots.push(
|
|
21292
|
+
roots.push(path16.join(process.env.APPDATA, "npm", "node_modules"));
|
|
21175
21293
|
}
|
|
21176
|
-
roots.push(
|
|
21294
|
+
roots.push(path16.join(home, "AppData", "Roaming", "npm", "node_modules"));
|
|
21177
21295
|
} else {
|
|
21178
21296
|
roots.push("/opt/homebrew/lib/node_modules");
|
|
21179
21297
|
roots.push("/usr/local/lib/node_modules");
|
|
21180
21298
|
roots.push("/usr/lib/node_modules");
|
|
21181
|
-
roots.push(
|
|
21182
|
-
roots.push(
|
|
21299
|
+
roots.push(path16.join(home, ".npm-global", "lib", "node_modules"));
|
|
21300
|
+
roots.push(path16.join(home, ".local", "lib", "node_modules"));
|
|
21183
21301
|
}
|
|
21184
21302
|
if (process.env.npm_config_prefix) {
|
|
21185
21303
|
const prefix = process.env.npm_config_prefix;
|
|
21186
21304
|
roots.push(
|
|
21187
|
-
os4 === "win32" ?
|
|
21305
|
+
os4 === "win32" ? path16.join(prefix, "node_modules") : path16.join(prefix, "lib", "node_modules")
|
|
21188
21306
|
);
|
|
21189
21307
|
}
|
|
21190
21308
|
return Array.from(new Set(roots));
|
|
@@ -21231,14 +21349,22 @@ var CopilotStreamLogger = class _CopilotStreamLogger {
|
|
|
21231
21349
|
startedAt = Date.now();
|
|
21232
21350
|
format;
|
|
21233
21351
|
summarize;
|
|
21234
|
-
|
|
21352
|
+
chunkExtractor;
|
|
21353
|
+
pendingText = "";
|
|
21354
|
+
constructor(filePath, format, summarize, chunkExtractor) {
|
|
21235
21355
|
this.filePath = filePath;
|
|
21236
21356
|
this.format = format;
|
|
21237
21357
|
this.summarize = summarize;
|
|
21358
|
+
this.chunkExtractor = chunkExtractor;
|
|
21238
21359
|
this.stream = createWriteStream4(filePath, { flags: "a" });
|
|
21239
21360
|
}
|
|
21240
21361
|
static async create(options, summarize) {
|
|
21241
|
-
const logger = new _CopilotStreamLogger(
|
|
21362
|
+
const logger = new _CopilotStreamLogger(
|
|
21363
|
+
options.filePath,
|
|
21364
|
+
options.format,
|
|
21365
|
+
summarize,
|
|
21366
|
+
options.chunkExtractor
|
|
21367
|
+
);
|
|
21242
21368
|
const header = [
|
|
21243
21369
|
`# ${options.headerLabel} stream log`,
|
|
21244
21370
|
`# target: ${options.targetName}`,
|
|
@@ -21254,19 +21380,42 @@ var CopilotStreamLogger = class _CopilotStreamLogger {
|
|
|
21254
21380
|
return logger;
|
|
21255
21381
|
}
|
|
21256
21382
|
handleEvent(eventType, data) {
|
|
21257
|
-
const elapsed = formatElapsed4(this.startedAt);
|
|
21258
21383
|
if (this.format === "json") {
|
|
21259
|
-
|
|
21260
|
-
|
|
21261
|
-
} else {
|
|
21262
|
-
const summary = this.summarize(eventType, data);
|
|
21263
|
-
if (summary) {
|
|
21264
|
-
this.stream.write(`[+${elapsed}] [${eventType}] ${summary}
|
|
21384
|
+
const elapsed2 = formatElapsed4(this.startedAt);
|
|
21385
|
+
this.stream.write(`${JSON.stringify({ time: elapsed2, event: eventType, data })}
|
|
21265
21386
|
`);
|
|
21387
|
+
return;
|
|
21388
|
+
}
|
|
21389
|
+
if (this.chunkExtractor) {
|
|
21390
|
+
const chunkText = this.chunkExtractor(eventType, data);
|
|
21391
|
+
if (chunkText === null) {
|
|
21392
|
+
this.pendingText = "";
|
|
21393
|
+
return;
|
|
21394
|
+
}
|
|
21395
|
+
if (chunkText !== void 0) {
|
|
21396
|
+
this.pendingText += chunkText;
|
|
21397
|
+
return;
|
|
21266
21398
|
}
|
|
21399
|
+
this.flushPendingText();
|
|
21400
|
+
}
|
|
21401
|
+
const elapsed = formatElapsed4(this.startedAt);
|
|
21402
|
+
const summary = this.summarize(eventType, data);
|
|
21403
|
+
if (summary) {
|
|
21404
|
+
this.stream.write(`[+${elapsed}] [${eventType}] ${summary}
|
|
21405
|
+
`);
|
|
21267
21406
|
}
|
|
21268
21407
|
}
|
|
21408
|
+
flushPendingText() {
|
|
21409
|
+
if (!this.pendingText) return;
|
|
21410
|
+
const elapsed = formatElapsed4(this.startedAt);
|
|
21411
|
+
this.stream.write(`[+${elapsed}] [assistant_message] ${this.pendingText}
|
|
21412
|
+
`);
|
|
21413
|
+
this.pendingText = "";
|
|
21414
|
+
}
|
|
21269
21415
|
async close() {
|
|
21416
|
+
if (this.format !== "json") {
|
|
21417
|
+
this.flushPendingText();
|
|
21418
|
+
}
|
|
21270
21419
|
await new Promise((resolve2, reject) => {
|
|
21271
21420
|
this.stream.once("error", reject);
|
|
21272
21421
|
this.stream.end(() => resolve2());
|
|
@@ -21473,6 +21622,10 @@ var CopilotCliProvider = class {
|
|
|
21473
21622
|
content: finalContent
|
|
21474
21623
|
});
|
|
21475
21624
|
}
|
|
21625
|
+
const sessionId = session.sessionId;
|
|
21626
|
+
const fileChanges = sessionId ? await captureSessionArtifacts(
|
|
21627
|
+
path17.join(homedir2(), ".copilot", "session-state", sessionId, "files")
|
|
21628
|
+
).catch(() => void 0) : void 0;
|
|
21476
21629
|
return {
|
|
21477
21630
|
raw: {
|
|
21478
21631
|
model: this.config.model,
|
|
@@ -21484,7 +21637,8 @@ var CopilotCliProvider = class {
|
|
|
21484
21637
|
costUsd,
|
|
21485
21638
|
durationMs,
|
|
21486
21639
|
startTime,
|
|
21487
|
-
endTime
|
|
21640
|
+
endTime,
|
|
21641
|
+
...fileChanges ? { fileChanges } : {}
|
|
21488
21642
|
};
|
|
21489
21643
|
} finally {
|
|
21490
21644
|
await logger?.close();
|
|
@@ -21525,10 +21679,10 @@ var CopilotCliProvider = class {
|
|
|
21525
21679
|
}
|
|
21526
21680
|
resolveCwd(cwdOverride) {
|
|
21527
21681
|
if (cwdOverride) {
|
|
21528
|
-
return
|
|
21682
|
+
return path17.resolve(cwdOverride);
|
|
21529
21683
|
}
|
|
21530
21684
|
if (this.config.cwd) {
|
|
21531
|
-
return
|
|
21685
|
+
return path17.resolve(this.config.cwd);
|
|
21532
21686
|
}
|
|
21533
21687
|
return void 0;
|
|
21534
21688
|
}
|
|
@@ -21547,9 +21701,9 @@ var CopilotCliProvider = class {
|
|
|
21547
21701
|
return void 0;
|
|
21548
21702
|
}
|
|
21549
21703
|
if (this.config.logDir) {
|
|
21550
|
-
return
|
|
21704
|
+
return path17.resolve(this.config.logDir);
|
|
21551
21705
|
}
|
|
21552
|
-
return
|
|
21706
|
+
return path17.join(process.cwd(), ".agentv", "logs", "copilot-cli");
|
|
21553
21707
|
}
|
|
21554
21708
|
async createStreamLogger(request) {
|
|
21555
21709
|
const logDir = this.resolveLogDirectory();
|
|
@@ -21563,7 +21717,7 @@ var CopilotCliProvider = class {
|
|
|
21563
21717
|
console.warn(`Skipping Copilot CLI stream logging (could not create ${logDir}): ${message}`);
|
|
21564
21718
|
return void 0;
|
|
21565
21719
|
}
|
|
21566
|
-
const filePath =
|
|
21720
|
+
const filePath = path17.join(logDir, buildLogFilename4(request, this.targetName, "copilot-cli"));
|
|
21567
21721
|
try {
|
|
21568
21722
|
const logger = await CopilotStreamLogger.create(
|
|
21569
21723
|
{
|
|
@@ -21572,7 +21726,8 @@ var CopilotCliProvider = class {
|
|
|
21572
21726
|
evalCaseId: request.evalCaseId,
|
|
21573
21727
|
attempt: request.attempt,
|
|
21574
21728
|
format: this.config.logFormat ?? "summary",
|
|
21575
|
-
headerLabel: "Copilot CLI (ACP)"
|
|
21729
|
+
headerLabel: "Copilot CLI (ACP)",
|
|
21730
|
+
chunkExtractor: extractAcpChunk
|
|
21576
21731
|
},
|
|
21577
21732
|
summarizeAcpEvent
|
|
21578
21733
|
);
|
|
@@ -21631,6 +21786,14 @@ Fix options:
|
|
|
21631
21786
|
- In .env: COPILOT_EXE=C:\\Users\\<you>\\AppData\\Roaming\\npm\\node_modules\\@github\\copilot-win32-x64\\copilot.exe
|
|
21632
21787
|
- In .agentv/targets.yaml: executable: \${{ COPILOT_EXE }}`;
|
|
21633
21788
|
}
|
|
21789
|
+
function extractAcpChunk(eventType, data) {
|
|
21790
|
+
if (eventType === "agent_thought_chunk") return null;
|
|
21791
|
+
if (eventType !== "agent_message_chunk") return void 0;
|
|
21792
|
+
if (!data || typeof data !== "object") return void 0;
|
|
21793
|
+
const d = data;
|
|
21794
|
+
const content = d.content;
|
|
21795
|
+
return content?.type === "text" && typeof content.text === "string" ? content.text : void 0;
|
|
21796
|
+
}
|
|
21634
21797
|
function summarizeAcpEvent(eventType, data) {
|
|
21635
21798
|
if (!data || typeof data !== "object") {
|
|
21636
21799
|
return eventType;
|
|
@@ -21781,28 +21944,28 @@ function parseCopilotEvents(eventsJsonl) {
|
|
|
21781
21944
|
durationMs
|
|
21782
21945
|
};
|
|
21783
21946
|
}
|
|
21784
|
-
var DEFAULT_SESSION_STATE_DIR = () =>
|
|
21947
|
+
var DEFAULT_SESSION_STATE_DIR = () => path18.join(homedir3(), ".copilot", "session-state");
|
|
21785
21948
|
async function discoverCopilotSessions(opts) {
|
|
21786
21949
|
const sessionStateDir = opts?.sessionStateDir ?? DEFAULT_SESSION_STATE_DIR();
|
|
21787
21950
|
const limit = opts?.limit ?? 10;
|
|
21788
21951
|
let entries;
|
|
21789
21952
|
try {
|
|
21790
|
-
entries = await
|
|
21953
|
+
entries = await readdir2(sessionStateDir);
|
|
21791
21954
|
} catch {
|
|
21792
21955
|
return [];
|
|
21793
21956
|
}
|
|
21794
21957
|
const sessions = [];
|
|
21795
21958
|
for (const entry of entries) {
|
|
21796
|
-
const sessionDir =
|
|
21797
|
-
const workspacePath =
|
|
21798
|
-
const eventsPath =
|
|
21959
|
+
const sessionDir = path18.join(sessionStateDir, entry);
|
|
21960
|
+
const workspacePath = path18.join(sessionDir, "workspace.yaml");
|
|
21961
|
+
const eventsPath = path18.join(sessionDir, "events.jsonl");
|
|
21799
21962
|
try {
|
|
21800
|
-
const workspaceContent = await
|
|
21963
|
+
const workspaceContent = await readFile10(workspacePath, "utf8");
|
|
21801
21964
|
const workspace = parseYaml22(workspaceContent) ?? {};
|
|
21802
21965
|
const cwd = String(workspace.cwd ?? "");
|
|
21803
21966
|
let updatedAt;
|
|
21804
21967
|
try {
|
|
21805
|
-
const eventsStat = await
|
|
21968
|
+
const eventsStat = await stat2(eventsPath);
|
|
21806
21969
|
updatedAt = eventsStat.mtime;
|
|
21807
21970
|
} catch {
|
|
21808
21971
|
updatedAt = /* @__PURE__ */ new Date(0);
|
|
@@ -21854,21 +22017,24 @@ var CopilotLogProvider = class {
|
|
|
21854
22017
|
}
|
|
21855
22018
|
async invoke(_request) {
|
|
21856
22019
|
const sessionDir = await this.resolveSessionDir();
|
|
21857
|
-
const eventsPath =
|
|
22020
|
+
const eventsPath = path19.join(sessionDir, "events.jsonl");
|
|
21858
22021
|
let eventsContent;
|
|
21859
22022
|
try {
|
|
21860
|
-
eventsContent = await
|
|
22023
|
+
eventsContent = await readFile11(eventsPath, "utf8");
|
|
21861
22024
|
} catch (err) {
|
|
21862
22025
|
throw new Error(
|
|
21863
22026
|
`Failed to read Copilot session transcript at ${eventsPath}: ${err instanceof Error ? err.message : String(err)}`
|
|
21864
22027
|
);
|
|
21865
22028
|
}
|
|
21866
22029
|
const parsed = parseCopilotEvents(eventsContent);
|
|
22030
|
+
const filesDir = path19.join(sessionDir, "files");
|
|
22031
|
+
const fileChanges = await captureSessionArtifacts(filesDir).catch(() => void 0);
|
|
21867
22032
|
return {
|
|
21868
22033
|
output: parsed.messages,
|
|
21869
22034
|
tokenUsage: parsed.tokenUsage,
|
|
21870
22035
|
durationMs: parsed.durationMs,
|
|
21871
|
-
startTime: parsed.meta.startedAt
|
|
22036
|
+
startTime: parsed.meta.startedAt,
|
|
22037
|
+
...fileChanges ? { fileChanges } : {}
|
|
21872
22038
|
};
|
|
21873
22039
|
}
|
|
21874
22040
|
async resolveSessionDir() {
|
|
@@ -21876,8 +22042,8 @@ var CopilotLogProvider = class {
|
|
|
21876
22042
|
return this.config.sessionDir;
|
|
21877
22043
|
}
|
|
21878
22044
|
if (this.config.sessionId) {
|
|
21879
|
-
const stateDir = this.config.sessionStateDir ??
|
|
21880
|
-
return
|
|
22045
|
+
const stateDir = this.config.sessionStateDir ?? path19.join(homedir4(), ".copilot", "session-state");
|
|
22046
|
+
return path19.join(stateDir, this.config.sessionId);
|
|
21881
22047
|
}
|
|
21882
22048
|
if (this.config.discover === "latest") {
|
|
21883
22049
|
const sessions = await discoverCopilotSessions({
|
|
@@ -22138,6 +22304,10 @@ var CopilotSdkProvider = class {
|
|
|
22138
22304
|
content: finalContent
|
|
22139
22305
|
});
|
|
22140
22306
|
}
|
|
22307
|
+
const sessionWorkspacePath = session.workspacePath;
|
|
22308
|
+
const fileChanges = sessionWorkspacePath ? await captureSessionArtifacts(path20.join(sessionWorkspacePath, "files")).catch(
|
|
22309
|
+
() => void 0
|
|
22310
|
+
) : void 0;
|
|
22141
22311
|
return {
|
|
22142
22312
|
raw: {
|
|
22143
22313
|
model: this.config.model,
|
|
@@ -22149,7 +22319,8 @@ var CopilotSdkProvider = class {
|
|
|
22149
22319
|
costUsd,
|
|
22150
22320
|
durationMs,
|
|
22151
22321
|
startTime,
|
|
22152
|
-
endTime
|
|
22322
|
+
endTime,
|
|
22323
|
+
...fileChanges ? { fileChanges } : {}
|
|
22153
22324
|
};
|
|
22154
22325
|
} finally {
|
|
22155
22326
|
unsubscribe();
|
|
@@ -22202,10 +22373,10 @@ var CopilotSdkProvider = class {
|
|
|
22202
22373
|
}
|
|
22203
22374
|
resolveCwd(cwdOverride) {
|
|
22204
22375
|
if (cwdOverride) {
|
|
22205
|
-
return
|
|
22376
|
+
return path20.resolve(cwdOverride);
|
|
22206
22377
|
}
|
|
22207
22378
|
if (this.config.cwd) {
|
|
22208
|
-
return
|
|
22379
|
+
return path20.resolve(this.config.cwd);
|
|
22209
22380
|
}
|
|
22210
22381
|
return void 0;
|
|
22211
22382
|
}
|
|
@@ -22214,9 +22385,9 @@ var CopilotSdkProvider = class {
|
|
|
22214
22385
|
return void 0;
|
|
22215
22386
|
}
|
|
22216
22387
|
if (this.config.logDir) {
|
|
22217
|
-
return
|
|
22388
|
+
return path20.resolve(this.config.logDir);
|
|
22218
22389
|
}
|
|
22219
|
-
return
|
|
22390
|
+
return path20.join(process.cwd(), ".agentv", "logs", "copilot-sdk");
|
|
22220
22391
|
}
|
|
22221
22392
|
async createStreamLogger(request) {
|
|
22222
22393
|
const logDir = this.resolveLogDirectory();
|
|
@@ -22230,7 +22401,7 @@ var CopilotSdkProvider = class {
|
|
|
22230
22401
|
console.warn(`Skipping Copilot SDK stream logging (could not create ${logDir}): ${message}`);
|
|
22231
22402
|
return void 0;
|
|
22232
22403
|
}
|
|
22233
|
-
const filePath =
|
|
22404
|
+
const filePath = path20.join(logDir, buildLogFilename4(request, this.targetName, "copilot-sdk"));
|
|
22234
22405
|
try {
|
|
22235
22406
|
const logger = await CopilotStreamLogger.create(
|
|
22236
22407
|
{
|
|
@@ -22239,7 +22410,8 @@ var CopilotSdkProvider = class {
|
|
|
22239
22410
|
evalCaseId: request.evalCaseId,
|
|
22240
22411
|
attempt: request.attempt,
|
|
22241
22412
|
format: this.config.logFormat ?? "summary",
|
|
22242
|
-
headerLabel: "Copilot SDK"
|
|
22413
|
+
headerLabel: "Copilot SDK",
|
|
22414
|
+
chunkExtractor: extractSdkChunk
|
|
22243
22415
|
},
|
|
22244
22416
|
summarizeSdkEvent
|
|
22245
22417
|
);
|
|
@@ -22259,9 +22431,9 @@ var CopilotSdkProvider = class {
|
|
|
22259
22431
|
};
|
|
22260
22432
|
function resolveSkillDirectories(cwd) {
|
|
22261
22433
|
const candidates = [
|
|
22262
|
-
|
|
22263
|
-
|
|
22264
|
-
|
|
22434
|
+
path20.join(cwd, ".claude", "skills"),
|
|
22435
|
+
path20.join(cwd, ".agents", "skills"),
|
|
22436
|
+
path20.join(cwd, ".codex", "skills")
|
|
22265
22437
|
];
|
|
22266
22438
|
return candidates.filter((dir) => existsSync2(dir));
|
|
22267
22439
|
}
|
|
@@ -22275,6 +22447,12 @@ function normalizeByokBaseUrl(baseUrl, type) {
|
|
|
22275
22447
|
}
|
|
22276
22448
|
return trimmed;
|
|
22277
22449
|
}
|
|
22450
|
+
function extractSdkChunk(eventType, data) {
|
|
22451
|
+
if (eventType !== "assistant.message_delta") return void 0;
|
|
22452
|
+
if (!data || typeof data !== "object") return void 0;
|
|
22453
|
+
const d = data;
|
|
22454
|
+
return typeof d.deltaContent === "string" ? d.deltaContent : void 0;
|
|
22455
|
+
}
|
|
22278
22456
|
function summarizeSdkEvent(eventType, data) {
|
|
22279
22457
|
if (!data || typeof data !== "object") {
|
|
22280
22458
|
return eventType;
|
|
@@ -22533,7 +22711,7 @@ var PiCliProvider = class {
|
|
|
22533
22711
|
const cwd = this.resolveCwd(workspaceRoot, request.cwd);
|
|
22534
22712
|
const logger = await this.createStreamLogger(request).catch(() => void 0);
|
|
22535
22713
|
try {
|
|
22536
|
-
const promptFile =
|
|
22714
|
+
const promptFile = path21.join(cwd, PROMPT_FILENAME);
|
|
22537
22715
|
await writeFile(promptFile, request.question, "utf8");
|
|
22538
22716
|
const args = this.buildPiArgs(request.question, inputFiles);
|
|
22539
22717
|
const result = await this.executePi(args, cwd, request.signal, logger);
|
|
@@ -22596,10 +22774,10 @@ var PiCliProvider = class {
|
|
|
22596
22774
|
}
|
|
22597
22775
|
resolveCwd(workspaceRoot, cwdOverride) {
|
|
22598
22776
|
if (cwdOverride) {
|
|
22599
|
-
return
|
|
22777
|
+
return path21.resolve(cwdOverride);
|
|
22600
22778
|
}
|
|
22601
22779
|
if (this.config.cwd) {
|
|
22602
|
-
return
|
|
22780
|
+
return path21.resolve(this.config.cwd);
|
|
22603
22781
|
}
|
|
22604
22782
|
if (workspaceRoot) {
|
|
22605
22783
|
return workspaceRoot;
|
|
@@ -22705,7 +22883,7 @@ ${prompt}` : prompt;
|
|
|
22705
22883
|
return env;
|
|
22706
22884
|
}
|
|
22707
22885
|
async createWorkspace() {
|
|
22708
|
-
return await mkdtemp(
|
|
22886
|
+
return await mkdtemp(path21.join(tmpdir(), WORKSPACE_PREFIX));
|
|
22709
22887
|
}
|
|
22710
22888
|
async cleanupWorkspace(workspaceRoot) {
|
|
22711
22889
|
try {
|
|
@@ -22715,9 +22893,9 @@ ${prompt}` : prompt;
|
|
|
22715
22893
|
}
|
|
22716
22894
|
resolveLogDirectory() {
|
|
22717
22895
|
if (this.config.logDir) {
|
|
22718
|
-
return
|
|
22896
|
+
return path21.resolve(this.config.logDir);
|
|
22719
22897
|
}
|
|
22720
|
-
return
|
|
22898
|
+
return path21.join(process.cwd(), ".agentv", "logs", "pi-cli");
|
|
22721
22899
|
}
|
|
22722
22900
|
async createStreamLogger(request) {
|
|
22723
22901
|
const logDir = this.resolveLogDirectory();
|
|
@@ -22731,7 +22909,7 @@ ${prompt}` : prompt;
|
|
|
22731
22909
|
console.warn(`Skipping Pi stream logging (could not create ${logDir}): ${message}`);
|
|
22732
22910
|
return void 0;
|
|
22733
22911
|
}
|
|
22734
|
-
const filePath =
|
|
22912
|
+
const filePath = path21.join(logDir, buildLogFilename5(request, this.targetName));
|
|
22735
22913
|
try {
|
|
22736
22914
|
const logger = await PiStreamLogger.create({
|
|
22737
22915
|
filePath,
|
|
@@ -23202,8 +23380,8 @@ function resolveWindowsCmd(executable) {
|
|
|
23202
23380
|
const content = readFileSync2(cmdPath, "utf-8");
|
|
23203
23381
|
const match = content.match(/"?%_prog%"?\s+"([^"]+\.js)"/);
|
|
23204
23382
|
if (match) {
|
|
23205
|
-
const dp0 =
|
|
23206
|
-
const scriptPath = match[1].replace(/%dp0%[/\\]?/gi, `${dp0}${
|
|
23383
|
+
const dp0 = path21.dirname(path21.resolve(cmdPath));
|
|
23384
|
+
const scriptPath = match[1].replace(/%dp0%[/\\]?/gi, `${dp0}${path21.sep}`);
|
|
23207
23385
|
try {
|
|
23208
23386
|
accessSync(scriptPath);
|
|
23209
23387
|
return ["node", [scriptPath]];
|
|
@@ -23286,19 +23464,19 @@ function getAgentvHome() {
|
|
|
23286
23464
|
}
|
|
23287
23465
|
return envHome;
|
|
23288
23466
|
}
|
|
23289
|
-
return
|
|
23467
|
+
return path222.join(os2.homedir(), ".agentv");
|
|
23290
23468
|
}
|
|
23291
23469
|
function getWorkspacesRoot() {
|
|
23292
|
-
return
|
|
23470
|
+
return path222.join(getAgentvHome(), "workspaces");
|
|
23293
23471
|
}
|
|
23294
23472
|
function getSubagentsRoot() {
|
|
23295
|
-
return
|
|
23473
|
+
return path222.join(getAgentvHome(), "subagents");
|
|
23296
23474
|
}
|
|
23297
23475
|
function getTraceStateRoot() {
|
|
23298
|
-
return
|
|
23476
|
+
return path222.join(getAgentvHome(), "trace-state");
|
|
23299
23477
|
}
|
|
23300
23478
|
function getWorkspacePoolRoot() {
|
|
23301
|
-
return
|
|
23479
|
+
return path222.join(getAgentvHome(), "workspace-pool");
|
|
23302
23480
|
}
|
|
23303
23481
|
var piCodingAgentModule = null;
|
|
23304
23482
|
var piAiModule = null;
|
|
@@ -23318,7 +23496,7 @@ async function promptInstall() {
|
|
|
23318
23496
|
}
|
|
23319
23497
|
}
|
|
23320
23498
|
function findManagedSdkInstallRoot() {
|
|
23321
|
-
return
|
|
23499
|
+
return path23.join(getAgentvHome(), "deps", "pi-sdk");
|
|
23322
23500
|
}
|
|
23323
23501
|
function resolveGlobalNpmRoot() {
|
|
23324
23502
|
try {
|
|
@@ -23332,7 +23510,7 @@ function resolveGlobalNpmRoot() {
|
|
|
23332
23510
|
}
|
|
23333
23511
|
}
|
|
23334
23512
|
function buildGlobalModuleEntry(moduleName, globalNpmRoot) {
|
|
23335
|
-
return
|
|
23513
|
+
return path23.join(globalNpmRoot, ...moduleName.split("/"), "dist", "index.js");
|
|
23336
23514
|
}
|
|
23337
23515
|
function findAccessiblePath(paths) {
|
|
23338
23516
|
for (const candidate of paths) {
|
|
@@ -23358,11 +23536,11 @@ async function tryImportLocalSdkModules() {
|
|
|
23358
23536
|
async function tryImportManagedSdkModules() {
|
|
23359
23537
|
const managedRoot = findManagedSdkInstallRoot();
|
|
23360
23538
|
const piCodingAgentEntry = findAccessiblePath([
|
|
23361
|
-
|
|
23539
|
+
path23.join(managedRoot, "node_modules", "@mariozechner", "pi-coding-agent", "dist", "index.js")
|
|
23362
23540
|
]);
|
|
23363
23541
|
const piAiEntry = findAccessiblePath([
|
|
23364
|
-
|
|
23365
|
-
|
|
23542
|
+
path23.join(managedRoot, "node_modules", "@mariozechner", "pi-ai", "dist", "index.js"),
|
|
23543
|
+
path23.join(
|
|
23366
23544
|
managedRoot,
|
|
23367
23545
|
"node_modules",
|
|
23368
23546
|
"@mariozechner",
|
|
@@ -23393,7 +23571,7 @@ async function tryImportGlobalSdkModules() {
|
|
|
23393
23571
|
]);
|
|
23394
23572
|
const piAiEntry = findAccessiblePath([
|
|
23395
23573
|
buildGlobalModuleEntry("@mariozechner/pi-ai", globalNpmRoot),
|
|
23396
|
-
|
|
23574
|
+
path23.join(
|
|
23397
23575
|
globalNpmRoot,
|
|
23398
23576
|
"@mariozechner",
|
|
23399
23577
|
"pi-coding-agent",
|
|
@@ -23694,10 +23872,10 @@ ${fileList}`;
|
|
|
23694
23872
|
}
|
|
23695
23873
|
resolveCwd(cwdOverride) {
|
|
23696
23874
|
if (cwdOverride) {
|
|
23697
|
-
return
|
|
23875
|
+
return path23.resolve(cwdOverride);
|
|
23698
23876
|
}
|
|
23699
23877
|
if (this.config.cwd) {
|
|
23700
|
-
return
|
|
23878
|
+
return path23.resolve(this.config.cwd);
|
|
23701
23879
|
}
|
|
23702
23880
|
return process.cwd();
|
|
23703
23881
|
}
|
|
@@ -23716,9 +23894,9 @@ ${fileList}`;
|
|
|
23716
23894
|
}
|
|
23717
23895
|
resolveLogDirectory() {
|
|
23718
23896
|
if (this.config.logDir) {
|
|
23719
|
-
return
|
|
23897
|
+
return path23.resolve(this.config.logDir);
|
|
23720
23898
|
}
|
|
23721
|
-
return
|
|
23899
|
+
return path23.join(process.cwd(), ".agentv", "logs", "pi-coding-agent");
|
|
23722
23900
|
}
|
|
23723
23901
|
async createStreamLogger(request) {
|
|
23724
23902
|
const logDir = this.resolveLogDirectory();
|
|
@@ -23732,7 +23910,7 @@ ${fileList}`;
|
|
|
23732
23910
|
console.warn(`Skipping Pi stream logging (could not create ${logDir}): ${message}`);
|
|
23733
23911
|
return void 0;
|
|
23734
23912
|
}
|
|
23735
|
-
const filePath =
|
|
23913
|
+
const filePath = path23.join(logDir, buildLogFilename6(request, this.targetName));
|
|
23736
23914
|
try {
|
|
23737
23915
|
const logger = await PiStreamLogger2.create({
|
|
23738
23916
|
filePath,
|
|
@@ -23953,10 +24131,10 @@ async function ensureDir(target) {
|
|
|
23953
24131
|
await mkdir8(target, { recursive: true });
|
|
23954
24132
|
}
|
|
23955
24133
|
async function readDirEntries(target) {
|
|
23956
|
-
const entries = await
|
|
24134
|
+
const entries = await readdir3(target, { withFileTypes: true });
|
|
23957
24135
|
return entries.map((entry) => ({
|
|
23958
24136
|
name: entry.name,
|
|
23959
|
-
absolutePath:
|
|
24137
|
+
absolutePath: path24.join(target, entry.name),
|
|
23960
24138
|
isDirectory: entry.isDirectory()
|
|
23961
24139
|
}));
|
|
23962
24140
|
}
|
|
@@ -23970,7 +24148,7 @@ async function removeIfExists(target) {
|
|
|
23970
24148
|
}
|
|
23971
24149
|
}
|
|
23972
24150
|
function pathToFileUri2(filePath) {
|
|
23973
|
-
const absolutePath =
|
|
24151
|
+
const absolutePath = path25.isAbsolute(filePath) ? filePath : path25.resolve(filePath);
|
|
23974
24152
|
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
23975
24153
|
if (/^[a-zA-Z]:\//.test(normalizedPath)) {
|
|
23976
24154
|
return `file:///${normalizedPath}`;
|
|
@@ -24062,8 +24240,8 @@ function createBatchRequestPrompt(userQuery, responseFileTmp, responseFileFinal,
|
|
|
24062
24240
|
});
|
|
24063
24241
|
}
|
|
24064
24242
|
function createBatchOrchestratorPrompt(requestFiles, responseFiles, templateContent) {
|
|
24065
|
-
const requestLines = requestFiles.map((file, index) => `${index + 1}. messages/${
|
|
24066
|
-
const responseList = responseFiles.map((file) => `"${
|
|
24243
|
+
const requestLines = requestFiles.map((file, index) => `${index + 1}. messages/${path26.basename(file)}`).join("\n");
|
|
24244
|
+
const responseList = responseFiles.map((file) => `"${path26.basename(file)}"`).join(", ");
|
|
24067
24245
|
return renderTemplate2(templateContent, {
|
|
24068
24246
|
requestFiles: requestLines,
|
|
24069
24247
|
responseList
|
|
@@ -24102,7 +24280,7 @@ async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, sile
|
|
|
24102
24280
|
const maxAttempts = 10;
|
|
24103
24281
|
while (attempts < maxAttempts) {
|
|
24104
24282
|
try {
|
|
24105
|
-
const content = await
|
|
24283
|
+
const content = await readFile12(responseFileFinal, { encoding: "utf8" });
|
|
24106
24284
|
if (!silent) {
|
|
24107
24285
|
process.stdout.write(`${content}
|
|
24108
24286
|
`);
|
|
@@ -24123,7 +24301,7 @@ async function waitForResponseOutput(responseFileFinal, pollInterval = 1e3, sile
|
|
|
24123
24301
|
}
|
|
24124
24302
|
async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, silent = false, timeoutMs = DEFAULT_TIMEOUT_MS) {
|
|
24125
24303
|
if (!silent) {
|
|
24126
|
-
const fileList = responseFilesFinal.map((file) =>
|
|
24304
|
+
const fileList = responseFilesFinal.map((file) => path27.basename(file)).join(", ");
|
|
24127
24305
|
console.error(`waiting for ${responseFilesFinal.length} batch response(s): ${fileList}`);
|
|
24128
24306
|
}
|
|
24129
24307
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -24132,7 +24310,7 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
|
|
|
24132
24310
|
while (pending.size > 0) {
|
|
24133
24311
|
if (Date.now() >= deadline) {
|
|
24134
24312
|
if (!silent) {
|
|
24135
|
-
const remaining = [...pending].map((f) =>
|
|
24313
|
+
const remaining = [...pending].map((f) => path27.basename(f)).join(", ");
|
|
24136
24314
|
console.error(
|
|
24137
24315
|
`error: timed out after ${Math.round(timeoutMs / 1e3)}s waiting for batch responses. Still pending: ${remaining}`
|
|
24138
24316
|
);
|
|
@@ -24159,7 +24337,7 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
|
|
|
24159
24337
|
const maxAttempts = 10;
|
|
24160
24338
|
while (attempts < maxAttempts) {
|
|
24161
24339
|
try {
|
|
24162
|
-
const content = await
|
|
24340
|
+
const content = await readFile12(file, { encoding: "utf8" });
|
|
24163
24341
|
if (!silent) {
|
|
24164
24342
|
process.stdout.write(`${content}
|
|
24165
24343
|
`);
|
|
@@ -24183,10 +24361,10 @@ var DEFAULT_LOCK_NAME = "subagent.lock";
|
|
|
24183
24361
|
var DEFAULT_ALIVE_FILENAME = ".alive";
|
|
24184
24362
|
function getDefaultSubagentRoot(vscodeCmd = "code") {
|
|
24185
24363
|
const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
|
|
24186
|
-
return
|
|
24364
|
+
return path28.join(getSubagentsRoot(), folder);
|
|
24187
24365
|
}
|
|
24188
24366
|
var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
|
|
24189
|
-
var
|
|
24367
|
+
var execAsync3 = promisify3(exec);
|
|
24190
24368
|
function shellQuote(cmd) {
|
|
24191
24369
|
return cmd.includes(" ") ? `"${cmd}"` : cmd;
|
|
24192
24370
|
}
|
|
@@ -24232,7 +24410,7 @@ async function raceSpawnError(child, graceMs = 200) {
|
|
|
24232
24410
|
}
|
|
24233
24411
|
async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
|
|
24234
24412
|
try {
|
|
24235
|
-
const { stdout } = await
|
|
24413
|
+
const { stdout } = await execAsync3(`${shellQuote(vscodeCmd)} --status`, {
|
|
24236
24414
|
timeout: 1e4,
|
|
24237
24415
|
windowsHide: true
|
|
24238
24416
|
});
|
|
@@ -24248,11 +24426,11 @@ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir,
|
|
|
24248
24426
|
await raceSpawnError(child);
|
|
24249
24427
|
return true;
|
|
24250
24428
|
}
|
|
24251
|
-
const aliveFile =
|
|
24429
|
+
const aliveFile = path29.join(subagentDir, DEFAULT_ALIVE_FILENAME);
|
|
24252
24430
|
await removeIfExists(aliveFile);
|
|
24253
|
-
const githubAgentsDir =
|
|
24431
|
+
const githubAgentsDir = path29.join(subagentDir, ".github", "agents");
|
|
24254
24432
|
await mkdir9(githubAgentsDir, { recursive: true });
|
|
24255
|
-
const wakeupDst =
|
|
24433
|
+
const wakeupDst = path29.join(githubAgentsDir, "wakeup.md");
|
|
24256
24434
|
await writeFile2(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
|
|
24257
24435
|
const workspaceChild = spawnVsCode(vscodeCmd, [workspacePath], {
|
|
24258
24436
|
label: "open-workspace"
|
|
@@ -24265,7 +24443,7 @@ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir,
|
|
|
24265
24443
|
"chat",
|
|
24266
24444
|
"-m",
|
|
24267
24445
|
wakeupChatId,
|
|
24268
|
-
`create a file named .alive in the ${
|
|
24446
|
+
`create a file named .alive in the ${path29.basename(subagentDir)} folder`
|
|
24269
24447
|
];
|
|
24270
24448
|
const wakeupChild = spawnVsCode(vscodeCmd, chatArgs, { label: "send-wakeup-chat" });
|
|
24271
24449
|
await raceSpawnError(wakeupChild);
|
|
@@ -24280,10 +24458,10 @@ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir,
|
|
|
24280
24458
|
return true;
|
|
24281
24459
|
}
|
|
24282
24460
|
async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
|
|
24283
|
-
const workspacePath =
|
|
24284
|
-
const messagesDir =
|
|
24461
|
+
const workspacePath = path29.join(subagentDir, `${path29.basename(subagentDir)}.code-workspace`);
|
|
24462
|
+
const messagesDir = path29.join(subagentDir, "messages");
|
|
24285
24463
|
await mkdir9(messagesDir, { recursive: true });
|
|
24286
|
-
const reqFile =
|
|
24464
|
+
const reqFile = path29.join(messagesDir, `${timestamp}_req.md`);
|
|
24287
24465
|
await writeFile2(reqFile, requestInstructions, { encoding: "utf8" });
|
|
24288
24466
|
const reqUri = pathToFileUri2(reqFile);
|
|
24289
24467
|
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
@@ -24291,16 +24469,16 @@ async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, reques
|
|
|
24291
24469
|
chatArgs.push("-a", attachment);
|
|
24292
24470
|
}
|
|
24293
24471
|
chatArgs.push("-a", reqFile);
|
|
24294
|
-
chatArgs.push(`Follow instructions in [${
|
|
24472
|
+
chatArgs.push(`Follow instructions in [${path29.basename(reqFile)}](${reqUri})`);
|
|
24295
24473
|
const workspaceReady = await ensureWorkspaceFocused(
|
|
24296
24474
|
workspacePath,
|
|
24297
|
-
|
|
24475
|
+
path29.basename(subagentDir),
|
|
24298
24476
|
subagentDir,
|
|
24299
24477
|
vscodeCmd
|
|
24300
24478
|
);
|
|
24301
24479
|
if (!workspaceReady) {
|
|
24302
24480
|
throw new Error(
|
|
24303
|
-
`VS Code workspace '${
|
|
24481
|
+
`VS Code workspace '${path29.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
|
|
24304
24482
|
);
|
|
24305
24483
|
}
|
|
24306
24484
|
await sleep2(500);
|
|
@@ -24308,8 +24486,8 @@ async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, reques
|
|
|
24308
24486
|
await raceSpawnError(child);
|
|
24309
24487
|
}
|
|
24310
24488
|
async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
|
|
24311
|
-
const workspacePath =
|
|
24312
|
-
const messagesDir =
|
|
24489
|
+
const workspacePath = path29.join(subagentDir, `${path29.basename(subagentDir)}.code-workspace`);
|
|
24490
|
+
const messagesDir = path29.join(subagentDir, "messages");
|
|
24313
24491
|
await mkdir9(messagesDir, { recursive: true });
|
|
24314
24492
|
const chatArgs = ["-r", "chat", "-m", chatId];
|
|
24315
24493
|
for (const attachment of attachmentPaths) {
|
|
@@ -24318,13 +24496,13 @@ async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, c
|
|
|
24318
24496
|
chatArgs.push(chatInstruction);
|
|
24319
24497
|
const workspaceReady = await ensureWorkspaceFocused(
|
|
24320
24498
|
workspacePath,
|
|
24321
|
-
|
|
24499
|
+
path29.basename(subagentDir),
|
|
24322
24500
|
subagentDir,
|
|
24323
24501
|
vscodeCmd
|
|
24324
24502
|
);
|
|
24325
24503
|
if (!workspaceReady) {
|
|
24326
24504
|
throw new Error(
|
|
24327
|
-
`VS Code workspace '${
|
|
24505
|
+
`VS Code workspace '${path29.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
|
|
24328
24506
|
);
|
|
24329
24507
|
}
|
|
24330
24508
|
await sleep2(500);
|
|
@@ -24346,10 +24524,10 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
|
|
|
24346
24524
|
}
|
|
24347
24525
|
const transformedFolders = workspace.folders.map((folder) => {
|
|
24348
24526
|
const folderPath = folder.path;
|
|
24349
|
-
if (
|
|
24527
|
+
if (path30.isAbsolute(folderPath)) {
|
|
24350
24528
|
return folder;
|
|
24351
24529
|
}
|
|
24352
|
-
const absolutePath =
|
|
24530
|
+
const absolutePath = path30.resolve(templateDir, folderPath);
|
|
24353
24531
|
return {
|
|
24354
24532
|
...folder,
|
|
24355
24533
|
path: absolutePath
|
|
@@ -24371,19 +24549,19 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
|
|
|
24371
24549
|
if (locationMap && typeof locationMap === "object") {
|
|
24372
24550
|
const transformedMap = {};
|
|
24373
24551
|
for (const [locationPath, value] of Object.entries(locationMap)) {
|
|
24374
|
-
const isAbsolute =
|
|
24552
|
+
const isAbsolute = path30.isAbsolute(locationPath);
|
|
24375
24553
|
if (isAbsolute) {
|
|
24376
24554
|
transformedMap[locationPath] = value;
|
|
24377
24555
|
} else {
|
|
24378
24556
|
const firstGlobIndex = locationPath.search(/[*]/);
|
|
24379
24557
|
if (firstGlobIndex === -1) {
|
|
24380
|
-
const resolvedPath =
|
|
24558
|
+
const resolvedPath = path30.resolve(templateDir, locationPath).replace(/\\/g, "/");
|
|
24381
24559
|
transformedMap[resolvedPath] = value;
|
|
24382
24560
|
} else {
|
|
24383
24561
|
const basePathEnd = locationPath.lastIndexOf("/", firstGlobIndex);
|
|
24384
24562
|
const basePath = basePathEnd !== -1 ? locationPath.substring(0, basePathEnd) : ".";
|
|
24385
24563
|
const patternPath = locationPath.substring(basePathEnd !== -1 ? basePathEnd : 0);
|
|
24386
|
-
const resolvedPath = (
|
|
24564
|
+
const resolvedPath = (path30.resolve(templateDir, basePath) + patternPath).replace(
|
|
24387
24565
|
/\\/g,
|
|
24388
24566
|
"/"
|
|
24389
24567
|
);
|
|
@@ -24422,7 +24600,7 @@ async function findUnlockedSubagent(subagentRoot) {
|
|
|
24422
24600
|
number: Number.parseInt(entry.name.split("-")[1] ?? "", 10)
|
|
24423
24601
|
})).filter((entry) => Number.isInteger(entry.number)).sort((a, b) => a.number - b.number);
|
|
24424
24602
|
for (const subagent of subagents) {
|
|
24425
|
-
const lockFile =
|
|
24603
|
+
const lockFile = path31.join(subagent.absolutePath, DEFAULT_LOCK_NAME);
|
|
24426
24604
|
if (!await pathExists(lockFile)) {
|
|
24427
24605
|
return subagent.absolutePath;
|
|
24428
24606
|
}
|
|
@@ -24432,26 +24610,26 @@ async function findUnlockedSubagent(subagentRoot) {
|
|
|
24432
24610
|
async function copyAgentConfig(subagentDir, workspaceTemplate, cwd) {
|
|
24433
24611
|
let workspaceContent;
|
|
24434
24612
|
if (workspaceTemplate) {
|
|
24435
|
-
const workspaceSrc =
|
|
24613
|
+
const workspaceSrc = path31.resolve(workspaceTemplate);
|
|
24436
24614
|
if (!await pathExists(workspaceSrc)) {
|
|
24437
24615
|
throw new Error(`workspace template not found: ${workspaceSrc}`);
|
|
24438
24616
|
}
|
|
24439
|
-
const stats = await
|
|
24617
|
+
const stats = await stat4(workspaceSrc);
|
|
24440
24618
|
if (!stats.isFile()) {
|
|
24441
24619
|
throw new Error(`workspace template must be a file, not a directory: ${workspaceSrc}`);
|
|
24442
24620
|
}
|
|
24443
|
-
const templateText = await
|
|
24621
|
+
const templateText = await readFile13(workspaceSrc, "utf8");
|
|
24444
24622
|
workspaceContent = JSON.parse(templateText);
|
|
24445
24623
|
} else {
|
|
24446
24624
|
workspaceContent = DEFAULT_WORKSPACE_TEMPLATE;
|
|
24447
24625
|
}
|
|
24448
|
-
const workspaceName = `${
|
|
24449
|
-
const workspaceDst =
|
|
24450
|
-
const templateDir = workspaceTemplate ?
|
|
24626
|
+
const workspaceName = `${path31.basename(subagentDir)}.code-workspace`;
|
|
24627
|
+
const workspaceDst = path31.join(subagentDir, workspaceName);
|
|
24628
|
+
const templateDir = workspaceTemplate ? path31.dirname(path31.resolve(workspaceTemplate)) : subagentDir;
|
|
24451
24629
|
const workspaceJson = JSON.stringify(workspaceContent, null, 2);
|
|
24452
24630
|
let transformedContent = transformWorkspacePaths(workspaceJson, templateDir);
|
|
24453
24631
|
if (cwd) {
|
|
24454
|
-
const absCwd =
|
|
24632
|
+
const absCwd = path31.resolve(cwd);
|
|
24455
24633
|
const parsed = JSON.parse(transformedContent);
|
|
24456
24634
|
const alreadyPresent = parsed.folders.some((f) => f.path === absCwd);
|
|
24457
24635
|
if (!alreadyPresent) {
|
|
@@ -24460,35 +24638,35 @@ async function copyAgentConfig(subagentDir, workspaceTemplate, cwd) {
|
|
|
24460
24638
|
}
|
|
24461
24639
|
}
|
|
24462
24640
|
await writeFile3(workspaceDst, transformedContent, "utf8");
|
|
24463
|
-
const messagesDir =
|
|
24641
|
+
const messagesDir = path31.join(subagentDir, "messages");
|
|
24464
24642
|
await mkdir10(messagesDir, { recursive: true });
|
|
24465
24643
|
return { workspace: workspaceDst, messagesDir };
|
|
24466
24644
|
}
|
|
24467
24645
|
async function createSubagentLock(subagentDir) {
|
|
24468
|
-
const messagesDir =
|
|
24646
|
+
const messagesDir = path31.join(subagentDir, "messages");
|
|
24469
24647
|
if (await pathExists(messagesDir)) {
|
|
24470
|
-
const files = await
|
|
24648
|
+
const files = await readdir4(messagesDir);
|
|
24471
24649
|
await Promise.all(
|
|
24472
24650
|
files.map(async (file) => {
|
|
24473
|
-
const target =
|
|
24651
|
+
const target = path31.join(messagesDir, file);
|
|
24474
24652
|
await removeIfExists(target);
|
|
24475
24653
|
})
|
|
24476
24654
|
);
|
|
24477
24655
|
}
|
|
24478
|
-
const githubAgentsDir =
|
|
24656
|
+
const githubAgentsDir = path31.join(subagentDir, ".github", "agents");
|
|
24479
24657
|
if (await pathExists(githubAgentsDir)) {
|
|
24480
|
-
const agentFiles = await
|
|
24658
|
+
const agentFiles = await readdir4(githubAgentsDir);
|
|
24481
24659
|
const preservedFiles = /* @__PURE__ */ new Set(["wakeup.md", "subagent.md"]);
|
|
24482
24660
|
await Promise.all(
|
|
24483
|
-
agentFiles.filter((file) => file.endsWith(".md") && !preservedFiles.has(file)).map((file) => removeIfExists(
|
|
24661
|
+
agentFiles.filter((file) => file.endsWith(".md") && !preservedFiles.has(file)).map((file) => removeIfExists(path31.join(githubAgentsDir, file)))
|
|
24484
24662
|
);
|
|
24485
24663
|
}
|
|
24486
|
-
const lockFile =
|
|
24664
|
+
const lockFile = path31.join(subagentDir, DEFAULT_LOCK_NAME);
|
|
24487
24665
|
await writeFile3(lockFile, "", { encoding: "utf8" });
|
|
24488
24666
|
return lockFile;
|
|
24489
24667
|
}
|
|
24490
24668
|
async function removeSubagentLock(subagentDir) {
|
|
24491
|
-
const lockFile =
|
|
24669
|
+
const lockFile = path31.join(subagentDir, DEFAULT_LOCK_NAME);
|
|
24492
24670
|
await removeIfExists(lockFile);
|
|
24493
24671
|
}
|
|
24494
24672
|
async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspaceTemplate, dryRun, cwd) {
|
|
@@ -24508,9 +24686,9 @@ async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspa
|
|
|
24508
24686
|
return 1;
|
|
24509
24687
|
}
|
|
24510
24688
|
if (promptFile) {
|
|
24511
|
-
const githubAgentsDir =
|
|
24689
|
+
const githubAgentsDir = path31.join(subagentDir, ".github", "agents");
|
|
24512
24690
|
await mkdir10(githubAgentsDir, { recursive: true });
|
|
24513
|
-
const agentFile =
|
|
24691
|
+
const agentFile = path31.join(githubAgentsDir, `${chatId}.md`);
|
|
24514
24692
|
try {
|
|
24515
24693
|
await copyFile(promptFile, agentFile);
|
|
24516
24694
|
} catch (error) {
|
|
@@ -24527,11 +24705,11 @@ async function resolvePromptFile(promptFile) {
|
|
|
24527
24705
|
if (!promptFile) {
|
|
24528
24706
|
return void 0;
|
|
24529
24707
|
}
|
|
24530
|
-
const resolvedPrompt =
|
|
24708
|
+
const resolvedPrompt = path322.resolve(promptFile);
|
|
24531
24709
|
if (!await pathExists(resolvedPrompt)) {
|
|
24532
24710
|
throw new Error(`Prompt file not found: ${resolvedPrompt}`);
|
|
24533
24711
|
}
|
|
24534
|
-
const promptStats = await
|
|
24712
|
+
const promptStats = await stat5(resolvedPrompt);
|
|
24535
24713
|
if (!promptStats.isFile()) {
|
|
24536
24714
|
throw new Error(`Prompt file must be a file, not a directory: ${resolvedPrompt}`);
|
|
24537
24715
|
}
|
|
@@ -24543,7 +24721,7 @@ async function resolveAttachments(extraAttachments) {
|
|
|
24543
24721
|
}
|
|
24544
24722
|
const resolved = [];
|
|
24545
24723
|
for (const attachment of extraAttachments) {
|
|
24546
|
-
const resolvedPath =
|
|
24724
|
+
const resolvedPath = path322.resolve(attachment);
|
|
24547
24725
|
if (!await pathExists(resolvedPath)) {
|
|
24548
24726
|
throw new Error(`Attachment not found: ${resolvedPath}`);
|
|
24549
24727
|
}
|
|
@@ -24585,7 +24763,7 @@ async function dispatchAgentSession(options) {
|
|
|
24585
24763
|
error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
|
|
24586
24764
|
};
|
|
24587
24765
|
}
|
|
24588
|
-
const subagentName =
|
|
24766
|
+
const subagentName = path322.basename(subagentDir);
|
|
24589
24767
|
const chatId = Math.random().toString(16).slice(2, 10);
|
|
24590
24768
|
const preparationResult = await prepareSubagentDirectory(
|
|
24591
24769
|
subagentDir,
|
|
@@ -24613,9 +24791,9 @@ async function dispatchAgentSession(options) {
|
|
|
24613
24791
|
};
|
|
24614
24792
|
}
|
|
24615
24793
|
const timestamp = generateTimestamp();
|
|
24616
|
-
const messagesDir =
|
|
24617
|
-
const responseFileTmp =
|
|
24618
|
-
const responseFileFinal =
|
|
24794
|
+
const messagesDir = path322.join(subagentDir, "messages");
|
|
24795
|
+
const responseFileTmp = path322.join(messagesDir, `${timestamp}_res.tmp.md`);
|
|
24796
|
+
const responseFileFinal = path322.join(messagesDir, `${timestamp}_res.md`);
|
|
24619
24797
|
const requestInstructions = createRequestPrompt(
|
|
24620
24798
|
userQuery,
|
|
24621
24799
|
responseFileTmp,
|
|
@@ -24720,7 +24898,7 @@ async function dispatchBatchAgent(options) {
|
|
|
24720
24898
|
error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
|
|
24721
24899
|
};
|
|
24722
24900
|
}
|
|
24723
|
-
subagentName =
|
|
24901
|
+
subagentName = path322.basename(subagentDir);
|
|
24724
24902
|
const chatId = Math.random().toString(16).slice(2, 10);
|
|
24725
24903
|
const preparationResult = await prepareSubagentDirectory(
|
|
24726
24904
|
subagentDir,
|
|
@@ -24751,17 +24929,17 @@ async function dispatchBatchAgent(options) {
|
|
|
24751
24929
|
};
|
|
24752
24930
|
}
|
|
24753
24931
|
const timestamp = generateTimestamp();
|
|
24754
|
-
const messagesDir =
|
|
24932
|
+
const messagesDir = path322.join(subagentDir, "messages");
|
|
24755
24933
|
requestFiles = userQueries.map(
|
|
24756
|
-
(_, index) =>
|
|
24934
|
+
(_, index) => path322.join(messagesDir, `${timestamp}_${index}_req.md`)
|
|
24757
24935
|
);
|
|
24758
24936
|
const responseTmpFiles = userQueries.map(
|
|
24759
|
-
(_, index) =>
|
|
24937
|
+
(_, index) => path322.join(messagesDir, `${timestamp}_${index}_res.tmp.md`)
|
|
24760
24938
|
);
|
|
24761
24939
|
responseFilesFinal = userQueries.map(
|
|
24762
|
-
(_, index) =>
|
|
24940
|
+
(_, index) => path322.join(messagesDir, `${timestamp}_${index}_res.md`)
|
|
24763
24941
|
);
|
|
24764
|
-
const orchestratorFile =
|
|
24942
|
+
const orchestratorFile = path322.join(messagesDir, `${timestamp}_orchestrator.md`);
|
|
24765
24943
|
if (!dryRun) {
|
|
24766
24944
|
await Promise.all(
|
|
24767
24945
|
userQueries.map((query, index) => {
|
|
@@ -24874,7 +25052,7 @@ async function provisionSubagents(options) {
|
|
|
24874
25052
|
if (!Number.isInteger(subagents) || subagents < 1) {
|
|
24875
25053
|
throw new Error("subagents must be a positive integer");
|
|
24876
25054
|
}
|
|
24877
|
-
const targetPath =
|
|
25055
|
+
const targetPath = path33.resolve(targetRoot);
|
|
24878
25056
|
if (!dryRun) {
|
|
24879
25057
|
await ensureDir(targetPath);
|
|
24880
25058
|
}
|
|
@@ -24894,7 +25072,7 @@ async function provisionSubagents(options) {
|
|
|
24894
25072
|
continue;
|
|
24895
25073
|
}
|
|
24896
25074
|
highestNumber = Math.max(highestNumber, parsed);
|
|
24897
|
-
const lockFile =
|
|
25075
|
+
const lockFile = path33.join(entry.absolutePath, lockName);
|
|
24898
25076
|
const locked = await pathExists(lockFile);
|
|
24899
25077
|
if (locked) {
|
|
24900
25078
|
lockedSubagents.add(entry.absolutePath);
|
|
@@ -24911,10 +25089,10 @@ async function provisionSubagents(options) {
|
|
|
24911
25089
|
break;
|
|
24912
25090
|
}
|
|
24913
25091
|
const subagentDir = subagent.absolutePath;
|
|
24914
|
-
const githubAgentsDir =
|
|
24915
|
-
const lockFile =
|
|
24916
|
-
const workspaceDst =
|
|
24917
|
-
const wakeupDst =
|
|
25092
|
+
const githubAgentsDir = path33.join(subagentDir, ".github", "agents");
|
|
25093
|
+
const lockFile = path33.join(subagentDir, lockName);
|
|
25094
|
+
const workspaceDst = path33.join(subagentDir, `${path33.basename(subagentDir)}.code-workspace`);
|
|
25095
|
+
const wakeupDst = path33.join(githubAgentsDir, "wakeup.md");
|
|
24918
25096
|
const isLocked = await pathExists(lockFile);
|
|
24919
25097
|
if (isLocked && !force) {
|
|
24920
25098
|
continue;
|
|
@@ -24952,10 +25130,10 @@ async function provisionSubagents(options) {
|
|
|
24952
25130
|
let nextIndex = highestNumber;
|
|
24953
25131
|
while (subagentsProvisioned < subagents) {
|
|
24954
25132
|
nextIndex += 1;
|
|
24955
|
-
const subagentDir =
|
|
24956
|
-
const githubAgentsDir =
|
|
24957
|
-
const workspaceDst =
|
|
24958
|
-
const wakeupDst =
|
|
25133
|
+
const subagentDir = path33.join(targetPath, `subagent-${nextIndex}`);
|
|
25134
|
+
const githubAgentsDir = path33.join(subagentDir, ".github", "agents");
|
|
25135
|
+
const workspaceDst = path33.join(subagentDir, `${path33.basename(subagentDir)}.code-workspace`);
|
|
25136
|
+
const wakeupDst = path33.join(githubAgentsDir, "wakeup.md");
|
|
24959
25137
|
if (!dryRun) {
|
|
24960
25138
|
await ensureDir(subagentDir);
|
|
24961
25139
|
await ensureDir(githubAgentsDir);
|
|
@@ -24998,7 +25176,7 @@ var AGENTV_BATCH_REQUEST_TEMPLATE = `[[ ## task ## ]]
|
|
|
24998
25176
|
2. When completely finished and the response is stable, rename it to: {{responseFileFinal}}
|
|
24999
25177
|
3. Do not unlock the workspace from this request; batch orchestration will handle unlocking after all responses are ready.
|
|
25000
25178
|
`;
|
|
25001
|
-
var
|
|
25179
|
+
var execAsync4 = promisify4(exec2);
|
|
25002
25180
|
var VSCodeProvider = class {
|
|
25003
25181
|
id;
|
|
25004
25182
|
kind;
|
|
@@ -25141,7 +25319,7 @@ var VSCodeProvider = class {
|
|
|
25141
25319
|
async function locateVSCodeExecutable(candidate) {
|
|
25142
25320
|
const includesPathSeparator = candidate.includes("/") || candidate.includes("\\");
|
|
25143
25321
|
if (includesPathSeparator) {
|
|
25144
|
-
const resolved =
|
|
25322
|
+
const resolved = path34.isAbsolute(candidate) ? candidate : path34.resolve(candidate);
|
|
25145
25323
|
try {
|
|
25146
25324
|
await access3(resolved, constants3.F_OK);
|
|
25147
25325
|
return resolved;
|
|
@@ -25153,7 +25331,7 @@ async function locateVSCodeExecutable(candidate) {
|
|
|
25153
25331
|
}
|
|
25154
25332
|
const locator = process.platform === "win32" ? "where" : "which";
|
|
25155
25333
|
try {
|
|
25156
|
-
const { stdout } = await
|
|
25334
|
+
const { stdout } = await execAsync4(`${locator} ${candidate}`);
|
|
25157
25335
|
const lines = stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
25158
25336
|
if (lines.length > 0 && lines[0]) {
|
|
25159
25337
|
await access3(lines[0], constants3.F_OK);
|
|
@@ -25170,7 +25348,7 @@ async function resolveWorkspaceTemplateFile(template) {
|
|
|
25170
25348
|
return void 0;
|
|
25171
25349
|
}
|
|
25172
25350
|
try {
|
|
25173
|
-
const stats = await
|
|
25351
|
+
const stats = await stat6(path34.resolve(template));
|
|
25174
25352
|
return stats.isFile() ? template : void 0;
|
|
25175
25353
|
} catch {
|
|
25176
25354
|
return template;
|
|
@@ -25194,7 +25372,7 @@ function buildMandatoryPrereadBlock2(attachmentFiles) {
|
|
|
25194
25372
|
return "";
|
|
25195
25373
|
}
|
|
25196
25374
|
const buildList = (files) => files.map((absolutePath) => {
|
|
25197
|
-
const fileName =
|
|
25375
|
+
const fileName = path34.basename(absolutePath);
|
|
25198
25376
|
const fileUri = pathToFileUri3(absolutePath);
|
|
25199
25377
|
return `* [${fileName}](${fileUri})`;
|
|
25200
25378
|
});
|
|
@@ -25215,7 +25393,7 @@ function collectAttachmentFiles(attachments) {
|
|
|
25215
25393
|
}
|
|
25216
25394
|
const unique = /* @__PURE__ */ new Map();
|
|
25217
25395
|
for (const attachment of attachments) {
|
|
25218
|
-
const absolutePath =
|
|
25396
|
+
const absolutePath = path34.resolve(attachment);
|
|
25219
25397
|
if (!unique.has(absolutePath)) {
|
|
25220
25398
|
unique.set(absolutePath, absolutePath);
|
|
25221
25399
|
}
|
|
@@ -25223,7 +25401,7 @@ function collectAttachmentFiles(attachments) {
|
|
|
25223
25401
|
return Array.from(unique.values());
|
|
25224
25402
|
}
|
|
25225
25403
|
function pathToFileUri3(filePath) {
|
|
25226
|
-
const absolutePath =
|
|
25404
|
+
const absolutePath = path34.isAbsolute(filePath) ? filePath : path34.resolve(filePath);
|
|
25227
25405
|
const normalizedPath = absolutePath.replace(/\\/g, "/");
|
|
25228
25406
|
if (/^[a-zA-Z]:\//.test(normalizedPath)) {
|
|
25229
25407
|
return `file:///${normalizedPath}`;
|
|
@@ -25236,7 +25414,7 @@ function normalizeAttachments(attachments) {
|
|
|
25236
25414
|
}
|
|
25237
25415
|
const deduped = /* @__PURE__ */ new Set();
|
|
25238
25416
|
for (const attachment of attachments) {
|
|
25239
|
-
deduped.add(
|
|
25417
|
+
deduped.add(path34.resolve(attachment));
|
|
25240
25418
|
}
|
|
25241
25419
|
return Array.from(deduped);
|
|
25242
25420
|
}
|
|
@@ -25245,7 +25423,7 @@ function mergeAttachments(all) {
|
|
|
25245
25423
|
for (const list of all) {
|
|
25246
25424
|
if (!list) continue;
|
|
25247
25425
|
for (const inputFile of list) {
|
|
25248
|
-
deduped.add(
|
|
25426
|
+
deduped.add(path34.resolve(inputFile));
|
|
25249
25427
|
}
|
|
25250
25428
|
}
|
|
25251
25429
|
return deduped.size > 0 ? Array.from(deduped) : void 0;
|
|
@@ -25328,11 +25506,11 @@ async function fileExists3(filePath) {
|
|
|
25328
25506
|
}
|
|
25329
25507
|
}
|
|
25330
25508
|
async function readTargetDefinitions(filePath) {
|
|
25331
|
-
const absolutePath =
|
|
25509
|
+
const absolutePath = path35.resolve(filePath);
|
|
25332
25510
|
if (!await fileExists3(absolutePath)) {
|
|
25333
25511
|
throw new Error(`targets.yaml not found at ${absolutePath}`);
|
|
25334
25512
|
}
|
|
25335
|
-
const raw = await
|
|
25513
|
+
const raw = await readFile14(absolutePath, "utf8");
|
|
25336
25514
|
const parsed = parse5(raw);
|
|
25337
25515
|
if (!isRecord(parsed)) {
|
|
25338
25516
|
throw new Error(`targets.yaml at ${absolutePath} must be a YAML object with a 'targets' field`);
|
|
@@ -25349,11 +25527,11 @@ function listTargetNames(definitions) {
|
|
|
25349
25527
|
async function discoverProviders(registry, baseDir) {
|
|
25350
25528
|
const patterns = ["*.ts", "*.js", "*.mts", "*.mjs"];
|
|
25351
25529
|
const candidateDirs = [];
|
|
25352
|
-
let dir =
|
|
25353
|
-
const root =
|
|
25530
|
+
let dir = path36.resolve(baseDir);
|
|
25531
|
+
const root = path36.parse(dir).root;
|
|
25354
25532
|
while (dir !== root) {
|
|
25355
|
-
candidateDirs.push(
|
|
25356
|
-
dir =
|
|
25533
|
+
candidateDirs.push(path36.join(dir, ".agentv", "providers"));
|
|
25534
|
+
dir = path36.dirname(dir);
|
|
25357
25535
|
}
|
|
25358
25536
|
let files = [];
|
|
25359
25537
|
for (const providersDir of candidateDirs) {
|
|
@@ -25369,7 +25547,7 @@ async function discoverProviders(registry, baseDir) {
|
|
|
25369
25547
|
}
|
|
25370
25548
|
const discoveredKinds = [];
|
|
25371
25549
|
for (const filePath of files) {
|
|
25372
|
-
const basename =
|
|
25550
|
+
const basename = path36.basename(filePath);
|
|
25373
25551
|
const kindName = basename.replace(/\.(ts|js|mts|mjs)$/, "");
|
|
25374
25552
|
if (registry.has(kindName)) {
|
|
25375
25553
|
continue;
|
|
@@ -27040,8 +27218,8 @@ function toAiSdkImageParts(images) {
|
|
|
27040
27218
|
}));
|
|
27041
27219
|
}
|
|
27042
27220
|
function resolveSandboxed(basePath, relativePath) {
|
|
27043
|
-
const resolved =
|
|
27044
|
-
if (!resolved.startsWith(basePath +
|
|
27221
|
+
const resolved = path37.resolve(basePath, relativePath);
|
|
27222
|
+
if (!resolved.startsWith(basePath + path37.sep) && resolved !== basePath) {
|
|
27045
27223
|
throw new Error(`Path '${relativePath}' is outside the workspace`);
|
|
27046
27224
|
}
|
|
27047
27225
|
return resolved;
|
|
@@ -27074,11 +27252,11 @@ function createFilesystemTools(workspacePath) {
|
|
|
27074
27252
|
execute: async (input) => {
|
|
27075
27253
|
try {
|
|
27076
27254
|
const resolved = resolveSandboxed(workspacePath, input.path);
|
|
27077
|
-
const
|
|
27078
|
-
if (
|
|
27255
|
+
const stat13 = await fs2.stat(resolved);
|
|
27256
|
+
if (stat13.isDirectory()) {
|
|
27079
27257
|
return { error: `'${input.path}' is a directory, not a file` };
|
|
27080
27258
|
}
|
|
27081
|
-
const buffer = Buffer.alloc(Math.min(
|
|
27259
|
+
const buffer = Buffer.alloc(Math.min(stat13.size, MAX_FILE_SIZE));
|
|
27082
27260
|
const fd = await fs2.open(resolved, "r");
|
|
27083
27261
|
try {
|
|
27084
27262
|
await fd.read(buffer, 0, buffer.length, 0);
|
|
@@ -27086,8 +27264,8 @@ function createFilesystemTools(workspacePath) {
|
|
|
27086
27264
|
await fd.close();
|
|
27087
27265
|
}
|
|
27088
27266
|
const content = buffer.toString("utf-8");
|
|
27089
|
-
const truncated =
|
|
27090
|
-
return { content, truncated, size:
|
|
27267
|
+
const truncated = stat13.size > MAX_FILE_SIZE;
|
|
27268
|
+
return { content, truncated, size: stat13.size };
|
|
27091
27269
|
} catch (error) {
|
|
27092
27270
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
27093
27271
|
}
|
|
@@ -27131,15 +27309,15 @@ async function searchDirectory(dirPath, workspacePath, regex, matches) {
|
|
|
27131
27309
|
for (const entry of entries) {
|
|
27132
27310
|
if (matches.length >= MAX_SEARCH_MATCHES) return;
|
|
27133
27311
|
if (SEARCH_SKIP_DIRS.has(entry.name)) continue;
|
|
27134
|
-
const fullPath =
|
|
27312
|
+
const fullPath = path37.join(dirPath, entry.name);
|
|
27135
27313
|
if (entry.isDirectory()) {
|
|
27136
27314
|
await searchDirectory(fullPath, workspacePath, regex, matches);
|
|
27137
27315
|
} else if (entry.isFile()) {
|
|
27138
|
-
const ext =
|
|
27316
|
+
const ext = path37.extname(entry.name).toLowerCase();
|
|
27139
27317
|
if (BINARY_EXTENSIONS.has(ext)) continue;
|
|
27140
27318
|
try {
|
|
27141
|
-
const
|
|
27142
|
-
if (
|
|
27319
|
+
const stat13 = await fs2.stat(fullPath);
|
|
27320
|
+
if (stat13.size > MAX_FILE_SIZE) continue;
|
|
27143
27321
|
const content = await fs2.readFile(fullPath, "utf-8");
|
|
27144
27322
|
const lines = content.split("\n");
|
|
27145
27323
|
for (let i = 0; i < lines.length; i++) {
|
|
@@ -27147,7 +27325,7 @@ async function searchDirectory(dirPath, workspacePath, regex, matches) {
|
|
|
27147
27325
|
regex.lastIndex = 0;
|
|
27148
27326
|
if (regex.test(lines[i])) {
|
|
27149
27327
|
matches.push({
|
|
27150
|
-
file:
|
|
27328
|
+
file: path37.relative(workspacePath, fullPath),
|
|
27151
27329
|
line: i + 1,
|
|
27152
27330
|
text: lines[i].substring(0, 200)
|
|
27153
27331
|
});
|
|
@@ -29336,7 +29514,7 @@ async function executePromptTemplate(script, context2, config, timeoutMs) {
|
|
|
29336
29514
|
};
|
|
29337
29515
|
const inputJson = JSON.stringify(toSnakeCaseDeep(payload), null, 2);
|
|
29338
29516
|
const scriptPath = script[script.length - 1];
|
|
29339
|
-
const cwd =
|
|
29517
|
+
const cwd = path38.dirname(scriptPath);
|
|
29340
29518
|
try {
|
|
29341
29519
|
const stdout = await executeScript(script, inputJson, timeoutMs, cwd);
|
|
29342
29520
|
const prompt = stdout.trim();
|
|
@@ -29618,11 +29796,11 @@ function createBuiltinRegistry() {
|
|
|
29618
29796
|
async function discoverAssertions(registry, baseDir) {
|
|
29619
29797
|
const patterns = ["*.ts", "*.js", "*.mts", "*.mjs"];
|
|
29620
29798
|
const candidateDirs = [];
|
|
29621
|
-
let dir =
|
|
29622
|
-
const root =
|
|
29799
|
+
let dir = path39.resolve(baseDir);
|
|
29800
|
+
const root = path39.parse(dir).root;
|
|
29623
29801
|
while (dir !== root) {
|
|
29624
|
-
candidateDirs.push(
|
|
29625
|
-
dir =
|
|
29802
|
+
candidateDirs.push(path39.join(dir, ".agentv", "assertions"));
|
|
29803
|
+
dir = path39.dirname(dir);
|
|
29626
29804
|
}
|
|
29627
29805
|
let files = [];
|
|
29628
29806
|
for (const assertionsDir of candidateDirs) {
|
|
@@ -29638,7 +29816,7 @@ async function discoverAssertions(registry, baseDir) {
|
|
|
29638
29816
|
}
|
|
29639
29817
|
const discoveredTypes = [];
|
|
29640
29818
|
for (const filePath of files) {
|
|
29641
|
-
const basename =
|
|
29819
|
+
const basename = path39.basename(filePath);
|
|
29642
29820
|
const typeName = basename.replace(/\.(ts|js|mts|mjs)$/, "");
|
|
29643
29821
|
if (registry.has(typeName)) {
|
|
29644
29822
|
continue;
|
|
@@ -29657,12 +29835,12 @@ async function discoverAssertions(registry, baseDir) {
|
|
|
29657
29835
|
async function discoverGraders(registry, baseDir) {
|
|
29658
29836
|
const patterns = ["*.ts", "*.js", "*.mts", "*.mjs"];
|
|
29659
29837
|
const candidateDirs = [];
|
|
29660
|
-
let dir =
|
|
29661
|
-
const root =
|
|
29838
|
+
let dir = path40.resolve(baseDir);
|
|
29839
|
+
const root = path40.parse(dir).root;
|
|
29662
29840
|
while (dir !== root) {
|
|
29663
|
-
candidateDirs.push(
|
|
29664
|
-
candidateDirs.push(
|
|
29665
|
-
dir =
|
|
29841
|
+
candidateDirs.push(path40.join(dir, ".agentv", "graders"));
|
|
29842
|
+
candidateDirs.push(path40.join(dir, ".agentv", "judges"));
|
|
29843
|
+
dir = path40.dirname(dir);
|
|
29666
29844
|
}
|
|
29667
29845
|
let files = [];
|
|
29668
29846
|
for (const gradersDir of candidateDirs) {
|
|
@@ -29678,7 +29856,7 @@ async function discoverGraders(registry, baseDir) {
|
|
|
29678
29856
|
}
|
|
29679
29857
|
const discoveredTypes = [];
|
|
29680
29858
|
for (const filePath of files) {
|
|
29681
|
-
const basename =
|
|
29859
|
+
const basename = path40.basename(filePath);
|
|
29682
29860
|
const typeName = basename.replace(/\.(ts|js|mts|mjs)$/, "");
|
|
29683
29861
|
if (registry.has(typeName)) {
|
|
29684
29862
|
continue;
|
|
@@ -29832,49 +30010,6 @@ function getTCritical(df) {
|
|
|
29832
30010
|
if (df >= 30) return 1.96;
|
|
29833
30011
|
return T_TABLE_95[df - 1];
|
|
29834
30012
|
}
|
|
29835
|
-
var execAsync4 = promisify4(execCallback);
|
|
29836
|
-
function gitExecOpts(workspacePath) {
|
|
29837
|
-
const { GIT_DIR: _, GIT_WORK_TREE: __, ...env } = process.env;
|
|
29838
|
-
return { cwd: workspacePath, env };
|
|
29839
|
-
}
|
|
29840
|
-
async function initializeBaseline(workspacePath) {
|
|
29841
|
-
const opts = gitExecOpts(workspacePath);
|
|
29842
|
-
await execAsync4("git init", opts);
|
|
29843
|
-
await execAsync4("git add -A", opts);
|
|
29844
|
-
await execAsync4(
|
|
29845
|
-
'git -c user.email=agentv@localhost -c user.name=agentv commit --allow-empty -m "agentv-baseline"',
|
|
29846
|
-
opts
|
|
29847
|
-
);
|
|
29848
|
-
const { stdout } = await execAsync4("git rev-parse HEAD", opts);
|
|
29849
|
-
return stdout.trim();
|
|
29850
|
-
}
|
|
29851
|
-
async function captureFileChanges(workspacePath, baselineCommit) {
|
|
29852
|
-
const opts = gitExecOpts(workspacePath);
|
|
29853
|
-
await stageNestedRepoChanges(workspacePath);
|
|
29854
|
-
await execAsync4("git add -A", opts);
|
|
29855
|
-
const { stdout } = await execAsync4(`git diff ${baselineCommit} --submodule=diff`, opts);
|
|
29856
|
-
return stdout.trim();
|
|
29857
|
-
}
|
|
29858
|
-
async function stageNestedRepoChanges(workspacePath) {
|
|
29859
|
-
let entries;
|
|
29860
|
-
try {
|
|
29861
|
-
entries = readdirSync2(workspacePath);
|
|
29862
|
-
} catch {
|
|
29863
|
-
return;
|
|
29864
|
-
}
|
|
29865
|
-
for (const entry of entries) {
|
|
29866
|
-
if (entry === ".git" || entry === "node_modules") continue;
|
|
29867
|
-
const childPath = path40.join(workspacePath, entry);
|
|
29868
|
-
try {
|
|
29869
|
-
if (!statSync(childPath).isDirectory()) continue;
|
|
29870
|
-
if (!statSync(path40.join(childPath, ".git")).isDirectory()) continue;
|
|
29871
|
-
} catch {
|
|
29872
|
-
continue;
|
|
29873
|
-
}
|
|
29874
|
-
const childOpts = gitExecOpts(childPath);
|
|
29875
|
-
await execAsync4("git add -A", childOpts);
|
|
29876
|
-
}
|
|
29877
|
-
}
|
|
29878
30013
|
var TemplateNotFoundError = class extends Error {
|
|
29879
30014
|
constructor(templatePath) {
|
|
29880
30015
|
super(`Workspace template not found: ${templatePath}`);
|
|
@@ -29896,7 +30031,7 @@ var WorkspaceCreationError = class extends Error {
|
|
|
29896
30031
|
};
|
|
29897
30032
|
async function isDirectory(filePath) {
|
|
29898
30033
|
try {
|
|
29899
|
-
const stats = await
|
|
30034
|
+
const stats = await stat7(filePath);
|
|
29900
30035
|
return stats.isDirectory();
|
|
29901
30036
|
} catch {
|
|
29902
30037
|
return false;
|
|
@@ -29908,7 +30043,7 @@ function getWorkspacePath(evalRunId, caseId, workspaceRoot) {
|
|
|
29908
30043
|
}
|
|
29909
30044
|
async function copyDirectoryRecursive(src, dest) {
|
|
29910
30045
|
await mkdir12(dest, { recursive: true });
|
|
29911
|
-
const entries = await
|
|
30046
|
+
const entries = await readdir5(src, { withFileTypes: true });
|
|
29912
30047
|
for (const entry of entries) {
|
|
29913
30048
|
const srcPath = path41.join(src, entry.name);
|
|
29914
30049
|
const destPath = path41.join(dest, entry.name);
|
|
@@ -30029,7 +30164,7 @@ function computeWorkspaceFingerprint(repos) {
|
|
|
30029
30164
|
}
|
|
30030
30165
|
async function copyDirectoryRecursive2(src, dest, skipDirs) {
|
|
30031
30166
|
await mkdir13(dest, { recursive: true });
|
|
30032
|
-
const entries = await
|
|
30167
|
+
const entries = await readdir6(src, { withFileTypes: true });
|
|
30033
30168
|
for (const entry of entries) {
|
|
30034
30169
|
const srcPath = path422.join(src, entry.name);
|
|
30035
30170
|
const destPath = path422.join(dest, entry.name);
|
|
@@ -30137,7 +30272,7 @@ var WorkspacePoolManager = class {
|
|
|
30137
30272
|
throw err;
|
|
30138
30273
|
}
|
|
30139
30274
|
try {
|
|
30140
|
-
const pidStr = await
|
|
30275
|
+
const pidStr = await readFile15(lockPath, "utf-8");
|
|
30141
30276
|
const pid = Number.parseInt(pidStr.trim(), 10);
|
|
30142
30277
|
if (!Number.isNaN(pid)) {
|
|
30143
30278
|
try {
|
|
@@ -30164,7 +30299,7 @@ var WorkspacePoolManager = class {
|
|
|
30164
30299
|
async checkDrift(poolDir, fingerprint) {
|
|
30165
30300
|
const metadataPath = path422.join(poolDir, "metadata.json");
|
|
30166
30301
|
try {
|
|
30167
|
-
const raw = await
|
|
30302
|
+
const raw = await readFile15(metadataPath, "utf-8");
|
|
30168
30303
|
const metadata = JSON.parse(raw);
|
|
30169
30304
|
return metadata.fingerprint !== fingerprint;
|
|
30170
30305
|
} catch {
|
|
@@ -30183,13 +30318,13 @@ var WorkspacePoolManager = class {
|
|
|
30183
30318
|
}
|
|
30184
30319
|
/** Remove all slot directories and their lock files from a pool directory. */
|
|
30185
30320
|
async removeAllSlots(poolDir) {
|
|
30186
|
-
const entries = await
|
|
30321
|
+
const entries = await readdir6(poolDir);
|
|
30187
30322
|
for (const entry of entries) {
|
|
30188
30323
|
if (entry.startsWith("slot-") && !entry.endsWith(".lock")) {
|
|
30189
30324
|
const lockPath = path422.join(poolDir, `${entry}.lock`);
|
|
30190
30325
|
if (existsSync3(lockPath)) {
|
|
30191
30326
|
try {
|
|
30192
|
-
const pidStr = await
|
|
30327
|
+
const pidStr = await readFile15(lockPath, "utf-8");
|
|
30193
30328
|
const pid = Number.parseInt(pidStr.trim(), 10);
|
|
30194
30329
|
if (!Number.isNaN(pid)) {
|
|
30195
30330
|
try {
|
|
@@ -30461,7 +30596,7 @@ async function resolveWorkspaceTemplate(templatePath) {
|
|
|
30461
30596
|
return void 0;
|
|
30462
30597
|
}
|
|
30463
30598
|
const resolved = path44.resolve(templatePath);
|
|
30464
|
-
const stats = await
|
|
30599
|
+
const stats = await stat8(resolved);
|
|
30465
30600
|
if (stats.isFile()) {
|
|
30466
30601
|
return {
|
|
30467
30602
|
dir: path44.dirname(resolved),
|
|
@@ -30471,7 +30606,7 @@ async function resolveWorkspaceTemplate(templatePath) {
|
|
|
30471
30606
|
if (!stats.isDirectory()) {
|
|
30472
30607
|
throw new Error(`workspace template is neither a file nor a directory: ${resolved}`);
|
|
30473
30608
|
}
|
|
30474
|
-
const entries = await
|
|
30609
|
+
const entries = await readdir7(resolved);
|
|
30475
30610
|
const workspaceFiles = entries.filter((e) => e.endsWith(".code-workspace"));
|
|
30476
30611
|
if (workspaceFiles.length === 1) {
|
|
30477
30612
|
return {
|
|
@@ -30573,6 +30708,100 @@ function getWorkspaceTemplate(target) {
|
|
|
30573
30708
|
}
|
|
30574
30709
|
return void 0;
|
|
30575
30710
|
}
|
|
30711
|
+
function validateDependencyGraph(tests) {
|
|
30712
|
+
const ids = /* @__PURE__ */ new Set();
|
|
30713
|
+
for (const test of tests) {
|
|
30714
|
+
if (ids.has(test.id)) {
|
|
30715
|
+
throw new Error(`Duplicate test ID '${test.id}' \u2014 each test must have a unique ID`);
|
|
30716
|
+
}
|
|
30717
|
+
ids.add(test.id);
|
|
30718
|
+
}
|
|
30719
|
+
for (const test of tests) {
|
|
30720
|
+
if (!test.depends_on) continue;
|
|
30721
|
+
for (const dep of test.depends_on) {
|
|
30722
|
+
if (!ids.has(dep)) {
|
|
30723
|
+
throw new Error(
|
|
30724
|
+
`Test '${test.id}' depends on '${dep}', but no test with that ID exists in this suite`
|
|
30725
|
+
);
|
|
30726
|
+
}
|
|
30727
|
+
if (dep === test.id) {
|
|
30728
|
+
throw new Error(`Test '${test.id}' depends on itself`);
|
|
30729
|
+
}
|
|
30730
|
+
}
|
|
30731
|
+
}
|
|
30732
|
+
const depMap = /* @__PURE__ */ new Map();
|
|
30733
|
+
for (const test of tests) {
|
|
30734
|
+
if (test.depends_on && test.depends_on.length > 0) {
|
|
30735
|
+
depMap.set(test.id, test.depends_on);
|
|
30736
|
+
}
|
|
30737
|
+
}
|
|
30738
|
+
const visited = /* @__PURE__ */ new Set();
|
|
30739
|
+
const visiting = /* @__PURE__ */ new Set();
|
|
30740
|
+
function visit(id, path53) {
|
|
30741
|
+
if (visiting.has(id)) {
|
|
30742
|
+
const cycle = [...path53.slice(path53.indexOf(id)), id];
|
|
30743
|
+
throw new Error(`Circular dependency detected: ${cycle.join(" \u2192 ")}`);
|
|
30744
|
+
}
|
|
30745
|
+
if (visited.has(id)) return;
|
|
30746
|
+
visiting.add(id);
|
|
30747
|
+
path53.push(id);
|
|
30748
|
+
for (const dep of depMap.get(id) ?? []) {
|
|
30749
|
+
visit(dep, path53);
|
|
30750
|
+
}
|
|
30751
|
+
path53.pop();
|
|
30752
|
+
visiting.delete(id);
|
|
30753
|
+
visited.add(id);
|
|
30754
|
+
}
|
|
30755
|
+
for (const test of tests) {
|
|
30756
|
+
visit(test.id, []);
|
|
30757
|
+
}
|
|
30758
|
+
}
|
|
30759
|
+
function computeWaves(tests) {
|
|
30760
|
+
const hasDeps = tests.some((t) => t.depends_on && t.depends_on.length > 0);
|
|
30761
|
+
if (!hasDeps) {
|
|
30762
|
+
return [tests.slice()];
|
|
30763
|
+
}
|
|
30764
|
+
const inDegree = /* @__PURE__ */ new Map();
|
|
30765
|
+
const dependents = /* @__PURE__ */ new Map();
|
|
30766
|
+
const testById = /* @__PURE__ */ new Map();
|
|
30767
|
+
for (const test of tests) {
|
|
30768
|
+
testById.set(test.id, test);
|
|
30769
|
+
inDegree.set(test.id, 0);
|
|
30770
|
+
}
|
|
30771
|
+
for (const test of tests) {
|
|
30772
|
+
if (!test.depends_on) continue;
|
|
30773
|
+
inDegree.set(test.id, test.depends_on.length);
|
|
30774
|
+
for (const dep of test.depends_on) {
|
|
30775
|
+
const list = dependents.get(dep) ?? [];
|
|
30776
|
+
list.push(test.id);
|
|
30777
|
+
dependents.set(dep, list);
|
|
30778
|
+
}
|
|
30779
|
+
}
|
|
30780
|
+
const waves = [];
|
|
30781
|
+
let ready = tests.filter((t) => (inDegree.get(t.id) ?? 0) === 0);
|
|
30782
|
+
while (ready.length > 0) {
|
|
30783
|
+
waves.push(ready);
|
|
30784
|
+
const nextReady = [];
|
|
30785
|
+
for (const test of ready) {
|
|
30786
|
+
for (const depId of dependents.get(test.id) ?? []) {
|
|
30787
|
+
const newDeg = (inDegree.get(depId) ?? 1) - 1;
|
|
30788
|
+
inDegree.set(depId, newDeg);
|
|
30789
|
+
if (newDeg === 0) {
|
|
30790
|
+
const depTest = testById.get(depId);
|
|
30791
|
+
if (depTest) nextReady.push(depTest);
|
|
30792
|
+
}
|
|
30793
|
+
}
|
|
30794
|
+
}
|
|
30795
|
+
ready = nextReady;
|
|
30796
|
+
}
|
|
30797
|
+
const totalScheduled = waves.reduce((sum, w) => sum + w.length, 0);
|
|
30798
|
+
if (totalScheduled !== tests.length) {
|
|
30799
|
+
throw new Error(
|
|
30800
|
+
`Internal error: ${tests.length - totalScheduled} tests were not scheduled (possible undetected cycle)`
|
|
30801
|
+
);
|
|
30802
|
+
}
|
|
30803
|
+
return waves;
|
|
30804
|
+
}
|
|
30576
30805
|
async function runEvaluation(options) {
|
|
30577
30806
|
const {
|
|
30578
30807
|
testFilePath: evalFilePath,
|
|
@@ -30840,11 +31069,11 @@ async function runEvaluation(options) {
|
|
|
30840
31069
|
let staticMaterialised = false;
|
|
30841
31070
|
const isYamlConfiguredPath = !cliWorkspacePath && !!yamlWorkspacePath;
|
|
30842
31071
|
if (useStaticWorkspace && configuredStaticPath) {
|
|
30843
|
-
const dirExists = await
|
|
31072
|
+
const dirExists = await stat9(configuredStaticPath).then(
|
|
30844
31073
|
(s) => s.isDirectory(),
|
|
30845
31074
|
() => false
|
|
30846
31075
|
);
|
|
30847
|
-
const isEmpty = dirExists ? (await
|
|
31076
|
+
const isEmpty = dirExists ? (await readdir8(configuredStaticPath)).length === 0 : false;
|
|
30848
31077
|
if (isYamlConfiguredPath && (!dirExists || isEmpty)) {
|
|
30849
31078
|
if (!dirExists) {
|
|
30850
31079
|
await mkdir14(configuredStaticPath, { recursive: true });
|
|
@@ -30896,10 +31125,41 @@ async function runEvaluation(options) {
|
|
|
30896
31125
|
setupLog(`created empty shared workspace at: ${sharedWorkspacePath}`);
|
|
30897
31126
|
}
|
|
30898
31127
|
try {
|
|
31128
|
+
let toDependencyResult2 = function(r) {
|
|
31129
|
+
const outputText = extractLastAssistantContent(r.output);
|
|
31130
|
+
return {
|
|
31131
|
+
score: r.score,
|
|
31132
|
+
output: outputText,
|
|
31133
|
+
workspace_path: r.workspacePath,
|
|
31134
|
+
details: r.scores ? Object.fromEntries(
|
|
31135
|
+
r.scores.map((s) => [s.name, { score: s.score, verdict: s.verdict }])
|
|
31136
|
+
) : void 0,
|
|
31137
|
+
status: r.executionStatus === "ok" ? "passed" : r.executionStatus === "execution_error" ? "error" : "failed"
|
|
31138
|
+
};
|
|
31139
|
+
}, checkDependencies2 = function(evalCase) {
|
|
31140
|
+
const depResults = {};
|
|
31141
|
+
if (!evalCase.depends_on || evalCase.depends_on.length === 0) {
|
|
31142
|
+
return { ok: true, depResults };
|
|
31143
|
+
}
|
|
31144
|
+
let allPassed = true;
|
|
31145
|
+
for (const depId of evalCase.depends_on) {
|
|
31146
|
+
const depResult = completedResults.get(depId);
|
|
31147
|
+
if (depResult) {
|
|
31148
|
+
depResults[depId] = toDependencyResult2(depResult);
|
|
31149
|
+
if (depResult.executionStatus === "execution_error") {
|
|
31150
|
+
allPassed = false;
|
|
31151
|
+
}
|
|
31152
|
+
} else {
|
|
31153
|
+
allPassed = false;
|
|
31154
|
+
}
|
|
31155
|
+
}
|
|
31156
|
+
return { ok: allPassed, depResults };
|
|
31157
|
+
};
|
|
31158
|
+
var toDependencyResult = toDependencyResult2, checkDependencies = checkDependencies2;
|
|
30899
31159
|
if (suiteWorkspaceFile && sharedWorkspacePath) {
|
|
30900
31160
|
const copiedWorkspaceFile = path45.join(sharedWorkspacePath, path45.basename(suiteWorkspaceFile));
|
|
30901
31161
|
try {
|
|
30902
|
-
await
|
|
31162
|
+
await stat9(copiedWorkspaceFile);
|
|
30903
31163
|
suiteWorkspaceFile = copiedWorkspaceFile;
|
|
30904
31164
|
} catch {
|
|
30905
31165
|
}
|
|
@@ -31006,8 +31266,9 @@ async function runEvaluation(options) {
|
|
|
31006
31266
|
try {
|
|
31007
31267
|
sharedBaselineCommit = await initializeBaseline(sharedWorkspacePath);
|
|
31008
31268
|
setupLog(`shared baseline initialized: ${sharedBaselineCommit}`);
|
|
31009
|
-
} catch {
|
|
31010
|
-
|
|
31269
|
+
} catch (error) {
|
|
31270
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31271
|
+
setupLog(`shared baseline initialization failed (file_changes unavailable): ${message}`);
|
|
31011
31272
|
}
|
|
31012
31273
|
}
|
|
31013
31274
|
if (availablePoolSlots.length > 0) {
|
|
@@ -31016,8 +31277,11 @@ async function runEvaluation(options) {
|
|
|
31016
31277
|
const baseline = await initializeBaseline(slot.path);
|
|
31017
31278
|
poolSlotBaselines.set(slot.path, baseline);
|
|
31018
31279
|
setupLog(`pool slot ${slot.index} baseline initialized: ${baseline}`);
|
|
31019
|
-
} catch {
|
|
31020
|
-
|
|
31280
|
+
} catch (error) {
|
|
31281
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
31282
|
+
setupLog(
|
|
31283
|
+
`pool slot ${slot.index} baseline initialization failed (file_changes unavailable): ${message}`
|
|
31284
|
+
);
|
|
31021
31285
|
}
|
|
31022
31286
|
}
|
|
31023
31287
|
}
|
|
@@ -31027,204 +31291,259 @@ async function runEvaluation(options) {
|
|
|
31027
31291
|
let cumulativeBudgetCost = 0;
|
|
31028
31292
|
let budgetExhausted = false;
|
|
31029
31293
|
let failOnErrorTriggered = false;
|
|
31030
|
-
|
|
31031
|
-
|
|
31032
|
-
|
|
31033
|
-
|
|
31034
|
-
|
|
31035
|
-
|
|
31036
|
-
|
|
31294
|
+
validateDependencyGraph(filteredEvalCases);
|
|
31295
|
+
const waves = computeWaves(filteredEvalCases);
|
|
31296
|
+
const completedResults = /* @__PURE__ */ new Map();
|
|
31297
|
+
const results = [];
|
|
31298
|
+
async function dispatchTest(evalCase, depResults) {
|
|
31299
|
+
const workerId = nextWorkerId++;
|
|
31300
|
+
workerIdByEvalId.set(evalCase.id, workerId);
|
|
31301
|
+
if (totalBudgetUsd !== void 0 && budgetExhausted) {
|
|
31302
|
+
const budgetResult = {
|
|
31303
|
+
timestamp: (now2 ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
|
|
31304
|
+
testId: evalCase.id,
|
|
31305
|
+
suite: evalCase.suite,
|
|
31306
|
+
category: evalCase.category,
|
|
31307
|
+
score: 0,
|
|
31308
|
+
assertions: [],
|
|
31309
|
+
output: [],
|
|
31310
|
+
target: target.name,
|
|
31311
|
+
error: `Suite budget exceeded ($${cumulativeBudgetCost.toFixed(4)} / $${totalBudgetUsd.toFixed(4)})`,
|
|
31312
|
+
budgetExceeded: true,
|
|
31313
|
+
executionStatus: "execution_error",
|
|
31314
|
+
failureStage: "setup",
|
|
31315
|
+
failureReasonCode: "budget_exceeded",
|
|
31316
|
+
executionError: {
|
|
31317
|
+
message: `Suite budget exceeded ($${cumulativeBudgetCost.toFixed(4)} / $${totalBudgetUsd.toFixed(4)})`,
|
|
31318
|
+
stage: "setup"
|
|
31319
|
+
}
|
|
31320
|
+
};
|
|
31321
|
+
if (onProgress) {
|
|
31322
|
+
await onProgress({
|
|
31323
|
+
workerId,
|
|
31037
31324
|
testId: evalCase.id,
|
|
31038
|
-
|
|
31039
|
-
|
|
31040
|
-
|
|
31041
|
-
|
|
31042
|
-
|
|
31043
|
-
|
|
31044
|
-
|
|
31045
|
-
|
|
31046
|
-
|
|
31047
|
-
|
|
31048
|
-
|
|
31049
|
-
|
|
31050
|
-
|
|
31051
|
-
|
|
31325
|
+
status: "failed",
|
|
31326
|
+
completedAt: Date.now(),
|
|
31327
|
+
error: budgetResult.error,
|
|
31328
|
+
score: budgetResult.score,
|
|
31329
|
+
executionStatus: budgetResult.executionStatus
|
|
31330
|
+
});
|
|
31331
|
+
}
|
|
31332
|
+
if (onResult) {
|
|
31333
|
+
await onResult(budgetResult);
|
|
31334
|
+
}
|
|
31335
|
+
return budgetResult;
|
|
31336
|
+
}
|
|
31337
|
+
if (failOnError === true && failOnErrorTriggered) {
|
|
31338
|
+
const errorMsg = "Halted: execution error encountered with fail_on_error enabled";
|
|
31339
|
+
const haltResult = {
|
|
31340
|
+
timestamp: (now2 ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
|
|
31341
|
+
testId: evalCase.id,
|
|
31342
|
+
suite: evalCase.suite,
|
|
31343
|
+
category: evalCase.category,
|
|
31344
|
+
score: 0,
|
|
31345
|
+
assertions: [],
|
|
31346
|
+
output: [],
|
|
31347
|
+
target: target.name,
|
|
31348
|
+
error: errorMsg,
|
|
31349
|
+
executionStatus: "execution_error",
|
|
31350
|
+
failureStage: "setup",
|
|
31351
|
+
failureReasonCode: "error_threshold_exceeded",
|
|
31352
|
+
executionError: { message: errorMsg, stage: "setup" }
|
|
31353
|
+
};
|
|
31354
|
+
if (onProgress) {
|
|
31355
|
+
await onProgress({
|
|
31356
|
+
workerId,
|
|
31357
|
+
testId: evalCase.id,
|
|
31358
|
+
status: "failed",
|
|
31359
|
+
completedAt: Date.now(),
|
|
31360
|
+
error: haltResult.error,
|
|
31361
|
+
score: haltResult.score,
|
|
31362
|
+
executionStatus: haltResult.executionStatus
|
|
31363
|
+
});
|
|
31364
|
+
}
|
|
31365
|
+
if (onResult) {
|
|
31366
|
+
await onResult(haltResult);
|
|
31367
|
+
}
|
|
31368
|
+
return haltResult;
|
|
31369
|
+
}
|
|
31370
|
+
if (onProgress) {
|
|
31371
|
+
await onProgress({
|
|
31372
|
+
workerId,
|
|
31373
|
+
testId: evalCase.id,
|
|
31374
|
+
status: "running",
|
|
31375
|
+
startedAt: Date.now()
|
|
31376
|
+
});
|
|
31377
|
+
}
|
|
31378
|
+
const testPoolSlot = availablePoolSlots.length > 0 ? availablePoolSlots.pop() : void 0;
|
|
31379
|
+
const testWorkspacePath = testPoolSlot?.path ?? sharedWorkspacePath;
|
|
31380
|
+
const testBaselineCommit = testPoolSlot ? poolSlotBaselines.get(testPoolSlot.path) : sharedBaselineCommit;
|
|
31381
|
+
try {
|
|
31382
|
+
const graderProvider = await resolveGraderProvider(target);
|
|
31383
|
+
const runCaseOptions = {
|
|
31384
|
+
evalCase,
|
|
31385
|
+
provider: primaryProvider,
|
|
31386
|
+
target,
|
|
31387
|
+
evaluators: evaluatorRegistry,
|
|
31388
|
+
maxRetries,
|
|
31389
|
+
agentTimeoutMs,
|
|
31390
|
+
cache,
|
|
31391
|
+
useCache,
|
|
31392
|
+
now: now2,
|
|
31393
|
+
graderProvider,
|
|
31394
|
+
targetResolver,
|
|
31395
|
+
availableTargets,
|
|
31396
|
+
evalRunId,
|
|
31397
|
+
keepWorkspaces,
|
|
31398
|
+
cleanupWorkspaces,
|
|
31399
|
+
retainOnSuccess: resolvedRetainOnSuccess,
|
|
31400
|
+
retainOnFailure: resolvedRetainOnFailure,
|
|
31401
|
+
sharedWorkspacePath: testWorkspacePath,
|
|
31402
|
+
sharedBaselineCommit: testBaselineCommit,
|
|
31403
|
+
suiteWorkspaceFile,
|
|
31404
|
+
streamCallbacks,
|
|
31405
|
+
typeRegistry,
|
|
31406
|
+
repoManager,
|
|
31407
|
+
evalDir,
|
|
31408
|
+
verbose,
|
|
31409
|
+
threshold: scoreThreshold,
|
|
31410
|
+
...depResults && Object.keys(depResults).length > 0 ? { dependencyResults: depResults } : {}
|
|
31411
|
+
};
|
|
31412
|
+
let result = trials && trials.count > 1 ? await runEvalCaseWithTrials(runCaseOptions, trials) : await runEvalCase(runCaseOptions);
|
|
31413
|
+
if (totalBudgetUsd !== void 0) {
|
|
31414
|
+
let caseCost;
|
|
31415
|
+
if (result.trials && result.trials.length > 0) {
|
|
31416
|
+
const trialCostSum = result.trials.reduce((sum, t) => sum + (t.costUsd ?? 0), 0);
|
|
31417
|
+
if (trialCostSum > 0) {
|
|
31418
|
+
caseCost = trialCostSum;
|
|
31052
31419
|
}
|
|
31053
|
-
}
|
|
31054
|
-
|
|
31055
|
-
await onProgress({
|
|
31056
|
-
workerId,
|
|
31057
|
-
testId: evalCase.id,
|
|
31058
|
-
status: "failed",
|
|
31059
|
-
completedAt: Date.now(),
|
|
31060
|
-
error: budgetResult.error,
|
|
31061
|
-
score: budgetResult.score,
|
|
31062
|
-
executionStatus: budgetResult.executionStatus
|
|
31063
|
-
});
|
|
31420
|
+
} else {
|
|
31421
|
+
caseCost = result.costUsd;
|
|
31064
31422
|
}
|
|
31065
|
-
if (
|
|
31066
|
-
|
|
31423
|
+
if (caseCost !== void 0) {
|
|
31424
|
+
cumulativeBudgetCost += caseCost;
|
|
31425
|
+
if (cumulativeBudgetCost >= totalBudgetUsd) {
|
|
31426
|
+
budgetExhausted = true;
|
|
31427
|
+
}
|
|
31067
31428
|
}
|
|
31068
|
-
return budgetResult;
|
|
31069
31429
|
}
|
|
31070
|
-
if (failOnError === true &&
|
|
31071
|
-
|
|
31072
|
-
|
|
31073
|
-
|
|
31430
|
+
if (failOnError === true && result.executionStatus === "execution_error") {
|
|
31431
|
+
failOnErrorTriggered = true;
|
|
31432
|
+
}
|
|
31433
|
+
if (beforeAllOutput && !beforeAllOutputAttached) {
|
|
31434
|
+
result = { ...result, beforeAllOutput };
|
|
31435
|
+
beforeAllOutputAttached = true;
|
|
31436
|
+
}
|
|
31437
|
+
if (onProgress) {
|
|
31438
|
+
await onProgress({
|
|
31439
|
+
workerId,
|
|
31074
31440
|
testId: evalCase.id,
|
|
31075
|
-
|
|
31076
|
-
|
|
31077
|
-
|
|
31078
|
-
|
|
31079
|
-
|
|
31080
|
-
|
|
31081
|
-
|
|
31082
|
-
|
|
31083
|
-
failureStage: "setup",
|
|
31084
|
-
failureReasonCode: "error_threshold_exceeded",
|
|
31085
|
-
executionError: { message: errorMsg, stage: "setup" }
|
|
31086
|
-
};
|
|
31087
|
-
if (onProgress) {
|
|
31088
|
-
await onProgress({
|
|
31089
|
-
workerId,
|
|
31090
|
-
testId: evalCase.id,
|
|
31091
|
-
status: "failed",
|
|
31092
|
-
completedAt: Date.now(),
|
|
31093
|
-
error: haltResult.error,
|
|
31094
|
-
score: haltResult.score,
|
|
31095
|
-
executionStatus: haltResult.executionStatus
|
|
31096
|
-
});
|
|
31097
|
-
}
|
|
31098
|
-
if (onResult) {
|
|
31099
|
-
await onResult(haltResult);
|
|
31100
|
-
}
|
|
31101
|
-
return haltResult;
|
|
31441
|
+
status: result.error ? "failed" : "completed",
|
|
31442
|
+
startedAt: 0,
|
|
31443
|
+
// Not used for completed status
|
|
31444
|
+
completedAt: Date.now(),
|
|
31445
|
+
error: result.error,
|
|
31446
|
+
score: result.score,
|
|
31447
|
+
executionStatus: result.executionStatus
|
|
31448
|
+
});
|
|
31102
31449
|
}
|
|
31450
|
+
if (onResult) {
|
|
31451
|
+
await onResult(result);
|
|
31452
|
+
}
|
|
31453
|
+
return result;
|
|
31454
|
+
} catch (error) {
|
|
31103
31455
|
if (onProgress) {
|
|
31104
31456
|
await onProgress({
|
|
31105
31457
|
workerId,
|
|
31106
31458
|
testId: evalCase.id,
|
|
31107
|
-
status: "
|
|
31108
|
-
|
|
31459
|
+
status: "failed",
|
|
31460
|
+
completedAt: Date.now(),
|
|
31461
|
+
error: error instanceof Error ? error.message : String(error)
|
|
31109
31462
|
});
|
|
31110
31463
|
}
|
|
31111
|
-
|
|
31112
|
-
|
|
31113
|
-
|
|
31114
|
-
|
|
31115
|
-
|
|
31116
|
-
|
|
31117
|
-
|
|
31118
|
-
|
|
31119
|
-
|
|
31120
|
-
|
|
31121
|
-
|
|
31122
|
-
|
|
31123
|
-
|
|
31124
|
-
|
|
31125
|
-
|
|
31126
|
-
|
|
31127
|
-
|
|
31128
|
-
|
|
31129
|
-
|
|
31130
|
-
|
|
31131
|
-
|
|
31132
|
-
|
|
31133
|
-
|
|
31134
|
-
|
|
31135
|
-
|
|
31136
|
-
|
|
31137
|
-
|
|
31138
|
-
|
|
31139
|
-
|
|
31140
|
-
|
|
31141
|
-
|
|
31142
|
-
|
|
31143
|
-
|
|
31144
|
-
|
|
31145
|
-
|
|
31146
|
-
|
|
31147
|
-
|
|
31148
|
-
|
|
31149
|
-
|
|
31150
|
-
|
|
31151
|
-
|
|
31152
|
-
|
|
31153
|
-
|
|
31154
|
-
|
|
31155
|
-
|
|
31156
|
-
|
|
31157
|
-
|
|
31158
|
-
|
|
31464
|
+
throw error;
|
|
31465
|
+
} finally {
|
|
31466
|
+
if (testPoolSlot) {
|
|
31467
|
+
availablePoolSlots.push(testPoolSlot);
|
|
31468
|
+
}
|
|
31469
|
+
}
|
|
31470
|
+
}
|
|
31471
|
+
for (const wave of waves) {
|
|
31472
|
+
const wavePromises = wave.map(
|
|
31473
|
+
(evalCase) => limit(async () => {
|
|
31474
|
+
if (evalCase.depends_on && evalCase.depends_on.length > 0) {
|
|
31475
|
+
const { ok, depResults } = checkDependencies2(evalCase);
|
|
31476
|
+
if (!ok) {
|
|
31477
|
+
const policy = evalCase.on_dependency_failure ?? "skip";
|
|
31478
|
+
if (policy === "skip" || policy === "fail") {
|
|
31479
|
+
const failedDeps = evalCase.depends_on.filter(
|
|
31480
|
+
(d) => completedResults.get(d)?.executionStatus === "execution_error"
|
|
31481
|
+
);
|
|
31482
|
+
const prefix = policy === "skip" ? "Skipped" : "Failed";
|
|
31483
|
+
const errorMsg = `${prefix}: dependency failed (${failedDeps.join(", ")})`;
|
|
31484
|
+
const depFailResult = {
|
|
31485
|
+
timestamp: (now2 ?? (() => /* @__PURE__ */ new Date()))().toISOString(),
|
|
31486
|
+
testId: evalCase.id,
|
|
31487
|
+
suite: evalCase.suite,
|
|
31488
|
+
category: evalCase.category,
|
|
31489
|
+
score: 0,
|
|
31490
|
+
assertions: [],
|
|
31491
|
+
output: [],
|
|
31492
|
+
target: target.name,
|
|
31493
|
+
error: errorMsg,
|
|
31494
|
+
executionStatus: "execution_error",
|
|
31495
|
+
failureStage: "setup",
|
|
31496
|
+
failureReasonCode: "dependency_failed",
|
|
31497
|
+
executionError: { message: errorMsg, stage: "setup" }
|
|
31498
|
+
};
|
|
31499
|
+
if (onProgress) {
|
|
31500
|
+
await onProgress({
|
|
31501
|
+
workerId: nextWorkerId++,
|
|
31502
|
+
testId: evalCase.id,
|
|
31503
|
+
status: "failed",
|
|
31504
|
+
completedAt: Date.now(),
|
|
31505
|
+
error: depFailResult.error,
|
|
31506
|
+
score: 0,
|
|
31507
|
+
executionStatus: depFailResult.executionStatus
|
|
31508
|
+
});
|
|
31509
|
+
}
|
|
31510
|
+
if (onResult) {
|
|
31511
|
+
await onResult(depFailResult);
|
|
31512
|
+
}
|
|
31513
|
+
return depFailResult;
|
|
31159
31514
|
}
|
|
31160
31515
|
}
|
|
31516
|
+
return dispatchTest(evalCase, depResults);
|
|
31161
31517
|
}
|
|
31162
|
-
|
|
31163
|
-
|
|
31164
|
-
|
|
31165
|
-
|
|
31166
|
-
|
|
31167
|
-
|
|
31168
|
-
|
|
31169
|
-
|
|
31170
|
-
|
|
31171
|
-
|
|
31172
|
-
|
|
31173
|
-
|
|
31174
|
-
|
|
31175
|
-
|
|
31176
|
-
|
|
31177
|
-
|
|
31178
|
-
|
|
31179
|
-
|
|
31180
|
-
|
|
31181
|
-
|
|
31518
|
+
return dispatchTest(evalCase);
|
|
31519
|
+
})
|
|
31520
|
+
);
|
|
31521
|
+
const settled = await Promise.allSettled(wavePromises);
|
|
31522
|
+
for (let i = 0; i < settled.length; i++) {
|
|
31523
|
+
const outcome = settled[i];
|
|
31524
|
+
const evalCase = wave[i];
|
|
31525
|
+
if (outcome.status === "fulfilled") {
|
|
31526
|
+
completedResults.set(evalCase.id, outcome.value);
|
|
31527
|
+
results.push(outcome.value);
|
|
31528
|
+
} else {
|
|
31529
|
+
const formattingMode = usesFileReferencePrompt(primaryProvider) ? "agent" : "lm";
|
|
31530
|
+
const promptInputs = await buildPromptInputs(evalCase, formattingMode);
|
|
31531
|
+
const errorResult = buildErrorResult(
|
|
31532
|
+
evalCase,
|
|
31533
|
+
target.name,
|
|
31534
|
+
(now2 ?? (() => /* @__PURE__ */ new Date()))(),
|
|
31535
|
+
outcome.reason,
|
|
31536
|
+
promptInputs,
|
|
31537
|
+
primaryProvider,
|
|
31538
|
+
"agent",
|
|
31539
|
+
"provider_error",
|
|
31540
|
+
verbose
|
|
31541
|
+
);
|
|
31542
|
+
completedResults.set(evalCase.id, errorResult);
|
|
31543
|
+
results.push(errorResult);
|
|
31182
31544
|
if (onResult) {
|
|
31183
|
-
await onResult(
|
|
31545
|
+
await onResult(errorResult);
|
|
31184
31546
|
}
|
|
31185
|
-
return result;
|
|
31186
|
-
} catch (error) {
|
|
31187
|
-
if (onProgress) {
|
|
31188
|
-
await onProgress({
|
|
31189
|
-
workerId,
|
|
31190
|
-
testId: evalCase.id,
|
|
31191
|
-
status: "failed",
|
|
31192
|
-
completedAt: Date.now(),
|
|
31193
|
-
error: error instanceof Error ? error.message : String(error)
|
|
31194
|
-
});
|
|
31195
|
-
}
|
|
31196
|
-
throw error;
|
|
31197
|
-
} finally {
|
|
31198
|
-
if (testPoolSlot) {
|
|
31199
|
-
availablePoolSlots.push(testPoolSlot);
|
|
31200
|
-
}
|
|
31201
|
-
}
|
|
31202
|
-
})
|
|
31203
|
-
);
|
|
31204
|
-
const settled = await Promise.allSettled(promises);
|
|
31205
|
-
const results = [];
|
|
31206
|
-
for (let i = 0; i < settled.length; i++) {
|
|
31207
|
-
const outcome = settled[i];
|
|
31208
|
-
if (outcome.status === "fulfilled") {
|
|
31209
|
-
results.push(outcome.value);
|
|
31210
|
-
} else {
|
|
31211
|
-
const evalCase = filteredEvalCases[i];
|
|
31212
|
-
const formattingMode = usesFileReferencePrompt(primaryProvider) ? "agent" : "lm";
|
|
31213
|
-
const promptInputs = await buildPromptInputs(evalCase, formattingMode);
|
|
31214
|
-
const errorResult = buildErrorResult(
|
|
31215
|
-
evalCase,
|
|
31216
|
-
target.name,
|
|
31217
|
-
(now2 ?? (() => /* @__PURE__ */ new Date()))(),
|
|
31218
|
-
outcome.reason,
|
|
31219
|
-
promptInputs,
|
|
31220
|
-
primaryProvider,
|
|
31221
|
-
"agent",
|
|
31222
|
-
"provider_error",
|
|
31223
|
-
verbose
|
|
31224
|
-
);
|
|
31225
|
-
results.push(errorResult);
|
|
31226
|
-
if (onResult) {
|
|
31227
|
-
await onResult(errorResult);
|
|
31228
31547
|
}
|
|
31229
31548
|
}
|
|
31230
31549
|
}
|
|
@@ -31469,7 +31788,8 @@ async function runEvalCase(options) {
|
|
|
31469
31788
|
repoManager,
|
|
31470
31789
|
evalDir,
|
|
31471
31790
|
verbose,
|
|
31472
|
-
threshold: caseThreshold
|
|
31791
|
+
threshold: caseThreshold,
|
|
31792
|
+
dependencyResults
|
|
31473
31793
|
} = options;
|
|
31474
31794
|
const setupDebug = process.env.AGENTV_SETUP_DEBUG === "1";
|
|
31475
31795
|
const formattingMode = usesFileReferencePrompt(provider) ? "agent" : "lm";
|
|
@@ -31513,7 +31833,7 @@ async function runEvalCase(options) {
|
|
|
31513
31833
|
if (caseWorkspaceFile && workspacePath) {
|
|
31514
31834
|
const copiedFile = path45.join(workspacePath, path45.basename(caseWorkspaceFile));
|
|
31515
31835
|
try {
|
|
31516
|
-
await
|
|
31836
|
+
await stat9(copiedFile);
|
|
31517
31837
|
caseWorkspaceFile = copiedFile;
|
|
31518
31838
|
} catch {
|
|
31519
31839
|
}
|
|
@@ -31677,7 +31997,11 @@ async function runEvalCase(options) {
|
|
|
31677
31997
|
if (!baselineCommit && workspacePath) {
|
|
31678
31998
|
try {
|
|
31679
31999
|
baselineCommit = await initializeBaseline(workspacePath);
|
|
31680
|
-
} catch {
|
|
32000
|
+
} catch (error) {
|
|
32001
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
32002
|
+
if (verbose) {
|
|
32003
|
+
console.warn(`[setup] test=${evalCase.id} baseline initialization failed: ${message}`);
|
|
32004
|
+
}
|
|
31681
32005
|
}
|
|
31682
32006
|
}
|
|
31683
32007
|
const caseStartMs = Date.now();
|
|
@@ -31788,6 +32112,11 @@ async function runEvalCase(options) {
|
|
|
31788
32112
|
} catch {
|
|
31789
32113
|
}
|
|
31790
32114
|
}
|
|
32115
|
+
const providerFileChanges = providerResponse?.fileChanges;
|
|
32116
|
+
if (providerFileChanges) {
|
|
32117
|
+
fileChanges = fileChanges ? `${fileChanges}
|
|
32118
|
+
${providerFileChanges}` : providerFileChanges;
|
|
32119
|
+
}
|
|
31791
32120
|
const providerError = extractProviderError(providerResponse);
|
|
31792
32121
|
if (caseHooksEnabled && repoManager && workspacePath && evalCase.workspace?.hooks?.after_each?.reset && evalCase.workspace.hooks.after_each.reset !== "none" && evalCase.workspace.repos) {
|
|
31793
32122
|
try {
|
|
@@ -31845,7 +32174,8 @@ async function runEvalCase(options) {
|
|
|
31845
32174
|
workspacePath,
|
|
31846
32175
|
dockerConfig: evalCase.workspace?.docker,
|
|
31847
32176
|
verbose,
|
|
31848
|
-
threshold: evalCase.threshold ?? caseThreshold
|
|
32177
|
+
threshold: evalCase.threshold ?? caseThreshold,
|
|
32178
|
+
dependencyResults
|
|
31849
32179
|
});
|
|
31850
32180
|
const effectiveThreshold = evalCase.threshold ?? caseThreshold;
|
|
31851
32181
|
const totalDurationMs = Date.now() - caseStartMs;
|
|
@@ -32038,7 +32368,8 @@ async function evaluateCandidate(options) {
|
|
|
32038
32368
|
fileChanges,
|
|
32039
32369
|
workspacePath,
|
|
32040
32370
|
dockerConfig,
|
|
32041
|
-
threshold: evalThreshold
|
|
32371
|
+
threshold: evalThreshold,
|
|
32372
|
+
dependencyResults
|
|
32042
32373
|
} = options;
|
|
32043
32374
|
const gradeTimestamp = nowFn();
|
|
32044
32375
|
const { score, scores } = await runEvaluatorsForCase({
|
|
@@ -32065,7 +32396,8 @@ async function evaluateCandidate(options) {
|
|
|
32065
32396
|
fileChanges,
|
|
32066
32397
|
workspacePath,
|
|
32067
32398
|
dockerConfig,
|
|
32068
|
-
threshold: evalThreshold
|
|
32399
|
+
threshold: evalThreshold,
|
|
32400
|
+
dependencyResults
|
|
32069
32401
|
});
|
|
32070
32402
|
const completedAt = nowFn();
|
|
32071
32403
|
let agentRequest;
|
|
@@ -32141,7 +32473,8 @@ async function runEvaluatorsForCase(options) {
|
|
|
32141
32473
|
fileChanges,
|
|
32142
32474
|
workspacePath,
|
|
32143
32475
|
dockerConfig,
|
|
32144
|
-
threshold
|
|
32476
|
+
threshold,
|
|
32477
|
+
dependencyResults
|
|
32145
32478
|
} = options;
|
|
32146
32479
|
if (evalCase.assertions && evalCase.assertions.length > 0) {
|
|
32147
32480
|
return runEvaluatorList({
|
|
@@ -32169,7 +32502,8 @@ async function runEvaluatorsForCase(options) {
|
|
|
32169
32502
|
fileChanges,
|
|
32170
32503
|
workspacePath,
|
|
32171
32504
|
dockerConfig,
|
|
32172
|
-
threshold
|
|
32505
|
+
threshold,
|
|
32506
|
+
dependencyResults
|
|
32173
32507
|
});
|
|
32174
32508
|
}
|
|
32175
32509
|
const evaluatorKind = evalCase.evaluator ?? "llm-grader";
|
|
@@ -32199,6 +32533,7 @@ async function runEvaluatorsForCase(options) {
|
|
|
32199
32533
|
fileChanges,
|
|
32200
32534
|
workspacePath,
|
|
32201
32535
|
dockerConfig,
|
|
32536
|
+
dependencyResults,
|
|
32202
32537
|
...implicitEvaluator ? { evaluator: implicitEvaluator } : {}
|
|
32203
32538
|
});
|
|
32204
32539
|
return { score };
|
|
@@ -32238,7 +32573,8 @@ async function runEvaluatorList(options) {
|
|
|
32238
32573
|
availableTargets,
|
|
32239
32574
|
fileChanges,
|
|
32240
32575
|
workspacePath,
|
|
32241
|
-
dockerConfig
|
|
32576
|
+
dockerConfig,
|
|
32577
|
+
dependencyResults
|
|
32242
32578
|
} = options;
|
|
32243
32579
|
const scored = [];
|
|
32244
32580
|
const scores = [];
|
|
@@ -32262,7 +32598,8 @@ async function runEvaluatorList(options) {
|
|
|
32262
32598
|
availableTargets,
|
|
32263
32599
|
fileChanges,
|
|
32264
32600
|
workspacePath,
|
|
32265
|
-
dockerConfig
|
|
32601
|
+
dockerConfig,
|
|
32602
|
+
dependencyResults
|
|
32266
32603
|
};
|
|
32267
32604
|
const evalFileDir = evalCase.file_paths[0] ? path45.dirname(evalCase.file_paths[0]) : process.cwd();
|
|
32268
32605
|
const dispatchContext = {
|
|
@@ -33009,7 +33346,7 @@ async function scanRepoDeps(evalFilePaths) {
|
|
|
33009
33346
|
return { repos: [...seen.values()], errors };
|
|
33010
33347
|
}
|
|
33011
33348
|
async function extractReposFromEvalFile(filePath) {
|
|
33012
|
-
const content = await
|
|
33349
|
+
const content = await readFile16(filePath, "utf8");
|
|
33013
33350
|
const parsed = interpolateEnv(parse6(content), process.env);
|
|
33014
33351
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
|
|
33015
33352
|
const obj = parsed;
|
|
@@ -33030,7 +33367,7 @@ async function extractReposFromEvalFile(filePath) {
|
|
|
33030
33367
|
async function extractReposFromWorkspaceRaw(raw, evalFileDir) {
|
|
33031
33368
|
if (typeof raw === "string") {
|
|
33032
33369
|
const workspaceFilePath = path47.resolve(evalFileDir, raw);
|
|
33033
|
-
const content = await
|
|
33370
|
+
const content = await readFile16(workspaceFilePath, "utf8");
|
|
33034
33371
|
const parsed = interpolateEnv(parse6(content), process.env);
|
|
33035
33372
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return [];
|
|
33036
33373
|
return extractReposFromObject(parsed);
|
|
@@ -33065,7 +33402,7 @@ var ResponseCache = class {
|
|
|
33065
33402
|
async get(key) {
|
|
33066
33403
|
const filePath = this.keyToPath(key);
|
|
33067
33404
|
try {
|
|
33068
|
-
const data = await
|
|
33405
|
+
const data = await readFile17(filePath, "utf8");
|
|
33069
33406
|
return JSON.parse(data);
|
|
33070
33407
|
} catch {
|
|
33071
33408
|
return void 0;
|
|
@@ -33312,12 +33649,12 @@ function resolveResultsRepoRunsDir(config) {
|
|
|
33312
33649
|
);
|
|
33313
33650
|
}
|
|
33314
33651
|
async function directorySizeBytes(targetPath) {
|
|
33315
|
-
const entry = await
|
|
33652
|
+
const entry = await stat10(targetPath);
|
|
33316
33653
|
if (entry.isFile()) {
|
|
33317
33654
|
return entry.size;
|
|
33318
33655
|
}
|
|
33319
33656
|
let total = 0;
|
|
33320
|
-
for (const child of await
|
|
33657
|
+
for (const child of await readdir9(targetPath, { withFileTypes: true })) {
|
|
33321
33658
|
total += await directorySizeBytes(path49.join(targetPath, child.name));
|
|
33322
33659
|
}
|
|
33323
33660
|
return total;
|
|
@@ -34367,14 +34704,14 @@ function extractResponseItemContent(content) {
|
|
|
34367
34704
|
}
|
|
34368
34705
|
return parts.length > 0 ? parts.join("") : void 0;
|
|
34369
34706
|
}
|
|
34370
|
-
var DEFAULT_SESSIONS_DIR = () => path51.join(
|
|
34707
|
+
var DEFAULT_SESSIONS_DIR = () => path51.join(homedir5(), ".codex", "sessions");
|
|
34371
34708
|
async function discoverCodexSessions(opts) {
|
|
34372
34709
|
const sessionsDir = opts?.sessionsDir ?? DEFAULT_SESSIONS_DIR();
|
|
34373
34710
|
const limit = opts?.latest ? 1 : opts?.limit ?? 10;
|
|
34374
34711
|
const sessions = [];
|
|
34375
34712
|
let yearDirs;
|
|
34376
34713
|
try {
|
|
34377
|
-
yearDirs = await
|
|
34714
|
+
yearDirs = await readdir10(sessionsDir);
|
|
34378
34715
|
} catch {
|
|
34379
34716
|
return [];
|
|
34380
34717
|
}
|
|
@@ -34382,7 +34719,7 @@ async function discoverCodexSessions(opts) {
|
|
|
34382
34719
|
const yearPath = path51.join(sessionsDir, year);
|
|
34383
34720
|
let monthDirs;
|
|
34384
34721
|
try {
|
|
34385
|
-
monthDirs = await
|
|
34722
|
+
monthDirs = await readdir10(yearPath);
|
|
34386
34723
|
} catch {
|
|
34387
34724
|
continue;
|
|
34388
34725
|
}
|
|
@@ -34390,7 +34727,7 @@ async function discoverCodexSessions(opts) {
|
|
|
34390
34727
|
const monthPath = path51.join(yearPath, month);
|
|
34391
34728
|
let dayDirs;
|
|
34392
34729
|
try {
|
|
34393
|
-
dayDirs = await
|
|
34730
|
+
dayDirs = await readdir10(monthPath);
|
|
34394
34731
|
} catch {
|
|
34395
34732
|
continue;
|
|
34396
34733
|
}
|
|
@@ -34402,7 +34739,7 @@ async function discoverCodexSessions(opts) {
|
|
|
34402
34739
|
const dayPath = path51.join(monthPath, day);
|
|
34403
34740
|
let files;
|
|
34404
34741
|
try {
|
|
34405
|
-
files = await
|
|
34742
|
+
files = await readdir10(dayPath);
|
|
34406
34743
|
} catch {
|
|
34407
34744
|
continue;
|
|
34408
34745
|
}
|
|
@@ -34414,7 +34751,7 @@ async function discoverCodexSessions(opts) {
|
|
|
34414
34751
|
const sessionId = parts.length >= 6 ? parts.slice(-5).join("-") : nameWithoutExt;
|
|
34415
34752
|
let updatedAt;
|
|
34416
34753
|
try {
|
|
34417
|
-
const fileStat = await
|
|
34754
|
+
const fileStat = await stat11(filePath);
|
|
34418
34755
|
updatedAt = fileStat.mtime;
|
|
34419
34756
|
} catch {
|
|
34420
34757
|
updatedAt = /* @__PURE__ */ new Date(0);
|
|
@@ -34427,7 +34764,7 @@ async function discoverCodexSessions(opts) {
|
|
|
34427
34764
|
sessions.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime());
|
|
34428
34765
|
return sessions.slice(0, limit);
|
|
34429
34766
|
}
|
|
34430
|
-
var DEFAULT_PROJECTS_DIR = () => path52.join(
|
|
34767
|
+
var DEFAULT_PROJECTS_DIR = () => path52.join(homedir6(), ".claude", "projects");
|
|
34431
34768
|
function encodeProjectPath(projectPath) {
|
|
34432
34769
|
return projectPath.replace(/\//g, "-");
|
|
34433
34770
|
}
|
|
@@ -34436,7 +34773,7 @@ async function discoverClaudeSessions(opts) {
|
|
|
34436
34773
|
const limit = opts?.latest ? 1 : opts?.limit ?? 10;
|
|
34437
34774
|
let projectDirs;
|
|
34438
34775
|
try {
|
|
34439
|
-
projectDirs = await
|
|
34776
|
+
projectDirs = await readdir11(projectsDir);
|
|
34440
34777
|
} catch {
|
|
34441
34778
|
return [];
|
|
34442
34779
|
}
|
|
@@ -34449,7 +34786,7 @@ async function discoverClaudeSessions(opts) {
|
|
|
34449
34786
|
const dirPath = path52.join(projectsDir, projectDir);
|
|
34450
34787
|
let entries;
|
|
34451
34788
|
try {
|
|
34452
|
-
entries = await
|
|
34789
|
+
entries = await readdir11(dirPath);
|
|
34453
34790
|
} catch {
|
|
34454
34791
|
continue;
|
|
34455
34792
|
}
|
|
@@ -34460,7 +34797,7 @@ async function discoverClaudeSessions(opts) {
|
|
|
34460
34797
|
const filePath = path52.join(dirPath, entry);
|
|
34461
34798
|
let updatedAt;
|
|
34462
34799
|
try {
|
|
34463
|
-
const fileStat = await
|
|
34800
|
+
const fileStat = await stat12(filePath);
|
|
34464
34801
|
updatedAt = fileStat.mtime;
|
|
34465
34802
|
} catch {
|
|
34466
34803
|
updatedAt = /* @__PURE__ */ new Date(0);
|
|
@@ -34501,11 +34838,11 @@ function toTranscriptJsonLine(entry) {
|
|
|
34501
34838
|
};
|
|
34502
34839
|
}
|
|
34503
34840
|
async function readTranscriptJsonl(filePath) {
|
|
34504
|
-
const text2 = await
|
|
34841
|
+
const text2 = await readFile18(filePath, "utf8");
|
|
34505
34842
|
return text2.split("\n").filter((line) => line.trim().length > 0).map((line) => JSON.parse(line));
|
|
34506
34843
|
}
|
|
34507
34844
|
async function readTranscriptFile(filePath) {
|
|
34508
|
-
return
|
|
34845
|
+
return readFile18(filePath, "utf8");
|
|
34509
34846
|
}
|
|
34510
34847
|
var TranscriptProvider = class _TranscriptProvider {
|
|
34511
34848
|
id;
|
|
@@ -34618,6 +34955,8 @@ export {
|
|
|
34618
34955
|
subscribeToClaudeLogEntries,
|
|
34619
34956
|
consumeCodexLogEntries,
|
|
34620
34957
|
subscribeToCodexLogEntries,
|
|
34958
|
+
initializeBaseline,
|
|
34959
|
+
captureFileChanges,
|
|
34621
34960
|
consumeCopilotCliLogEntries,
|
|
34622
34961
|
subscribeToCopilotCliLogEntries,
|
|
34623
34962
|
parseCopilotEvents,
|
|
@@ -34688,8 +35027,6 @@ export {
|
|
|
34688
35027
|
createBuiltinRegistry,
|
|
34689
35028
|
discoverAssertions,
|
|
34690
35029
|
discoverGraders,
|
|
34691
|
-
initializeBaseline,
|
|
34692
|
-
captureFileChanges,
|
|
34693
35030
|
TemplateNotFoundError,
|
|
34694
35031
|
TemplateNotDirectoryError,
|
|
34695
35032
|
WorkspaceCreationError,
|
|
@@ -34751,4 +35088,4 @@ export {
|
|
|
34751
35088
|
TranscriptProvider,
|
|
34752
35089
|
createAgentKernel
|
|
34753
35090
|
};
|
|
34754
|
-
//# sourceMappingURL=chunk-
|
|
35091
|
+
//# sourceMappingURL=chunk-HP3ZUKYB.js.map
|