agentv 2.14.2 → 2.14.3

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.
@@ -632,8 +632,8 @@ function getErrorMap() {
632
632
 
633
633
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
634
634
  var makeIssue = (params) => {
635
- const { data, path: path40, errorMaps, issueData } = params;
636
- const fullPath = [...path40, ...issueData.path || []];
635
+ const { data, path: path41, errorMaps, issueData } = params;
636
+ const fullPath = [...path41, ...issueData.path || []];
637
637
  const fullIssue = {
638
638
  ...issueData,
639
639
  path: fullPath
@@ -749,11 +749,11 @@ var errorUtil;
749
749
 
750
750
  // ../../node_modules/.bun/zod@3.25.76/node_modules/zod/v3/types.js
751
751
  var ParseInputLazyPath = class {
752
- constructor(parent, value, path40, key) {
752
+ constructor(parent, value, path41, key) {
753
753
  this._cachedPath = [];
754
754
  this.parent = parent;
755
755
  this.data = value;
756
- this._path = path40;
756
+ this._path = path41;
757
757
  this._key = key;
758
758
  }
759
759
  get path() {
@@ -6661,10 +6661,10 @@ function assignProp(target, prop, value) {
6661
6661
  configurable: true
6662
6662
  });
6663
6663
  }
6664
- function getElementAtPath(obj, path40) {
6665
- if (!path40)
6664
+ function getElementAtPath(obj, path41) {
6665
+ if (!path41)
6666
6666
  return obj;
6667
- return path40.reduce((acc, key) => acc?.[key], obj);
6667
+ return path41.reduce((acc, key) => acc?.[key], obj);
6668
6668
  }
6669
6669
  function promiseAllObject(promisesObj) {
6670
6670
  const keys = Object.keys(promisesObj);
@@ -6984,11 +6984,11 @@ function aborted(x, startIndex = 0) {
6984
6984
  }
6985
6985
  return false;
6986
6986
  }
6987
- function prefixIssues(path40, issues) {
6987
+ function prefixIssues(path41, issues) {
6988
6988
  return issues.map((iss) => {
6989
6989
  var _a17;
6990
6990
  (_a17 = iss).path ?? (_a17.path = []);
6991
- iss.path.unshift(path40);
6991
+ iss.path.unshift(path41);
6992
6992
  return iss;
6993
6993
  });
6994
6994
  }
@@ -7125,7 +7125,7 @@ function treeifyError(error40, _mapper) {
7125
7125
  return issue2.message;
7126
7126
  };
7127
7127
  const result = { errors: [] };
7128
- const processError = (error41, path40 = []) => {
7128
+ const processError = (error41, path41 = []) => {
7129
7129
  var _a17, _b8;
7130
7130
  for (const issue2 of error41.issues) {
7131
7131
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -7135,7 +7135,7 @@ function treeifyError(error40, _mapper) {
7135
7135
  } else if (issue2.code === "invalid_element") {
7136
7136
  processError({ issues: issue2.issues }, issue2.path);
7137
7137
  } else {
7138
- const fullpath = [...path40, ...issue2.path];
7138
+ const fullpath = [...path41, ...issue2.path];
7139
7139
  if (fullpath.length === 0) {
7140
7140
  result.errors.push(mapper(issue2));
7141
7141
  continue;
@@ -7165,9 +7165,9 @@ function treeifyError(error40, _mapper) {
7165
7165
  processError(error40);
7166
7166
  return result;
7167
7167
  }
7168
- function toDotPath(path40) {
7168
+ function toDotPath(path41) {
7169
7169
  const segs = [];
7170
- for (const seg of path40) {
7170
+ for (const seg of path41) {
7171
7171
  if (typeof seg === "number")
7172
7172
  segs.push(`[${seg}]`);
7173
7173
  else if (typeof seg === "symbol")
@@ -26720,14 +26720,14 @@ function createAzure(options = {}) {
26720
26720
  description: "Azure OpenAI resource name"
26721
26721
  });
26722
26722
  const apiVersion = (_a17 = options.apiVersion) != null ? _a17 : "v1";
26723
- const url2 = ({ path: path40, modelId }) => {
26723
+ const url2 = ({ path: path41, modelId }) => {
26724
26724
  var _a24;
26725
26725
  const baseUrlPrefix = (_a24 = options.baseURL) != null ? _a24 : `https://${getResourceName()}.openai.azure.com/openai`;
26726
26726
  let fullUrl;
26727
26727
  if (options.useDeploymentBasedUrls) {
26728
- fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path40}`);
26728
+ fullUrl = new URL(`${baseUrlPrefix}/deployments/${modelId}${path41}`);
26729
26729
  } else {
26730
- fullUrl = new URL(`${baseUrlPrefix}/v1${path40}`);
26730
+ fullUrl = new URL(`${baseUrlPrefix}/v1${path41}`);
26731
26731
  }
26732
26732
  fullUrl.searchParams.set("api-version", apiVersion);
26733
26733
  return fullUrl.toString();
@@ -33923,10 +33923,10 @@ import { tmpdir } from "node:os";
33923
33923
  import path16 from "node:path";
33924
33924
  import { exec as exec2 } from "node:child_process";
33925
33925
  import { constants as constants3, access as access3, stat as stat4 } from "node:fs/promises";
33926
- import path27 from "node:path";
33926
+ import path28 from "node:path";
33927
33927
  import { promisify as promisify3 } from "node:util";
33928
33928
  import { stat as stat3, writeFile as writeFile4 } from "node:fs/promises";
33929
- import path25 from "node:path";
33929
+ import path26 from "node:path";
33930
33930
  import { constants as constants22 } from "node:fs";
33931
33931
  import { access as access22, mkdir as mkdir6, readdir, rm as rm2, stat } from "node:fs/promises";
33932
33932
  import path17 from "node:path";
@@ -33936,21 +33936,22 @@ import { readFile as readFile8 } from "node:fs/promises";
33936
33936
  import path20 from "node:path";
33937
33937
  import { exec, spawn as spawn3 } from "node:child_process";
33938
33938
  import { mkdir as mkdir7, writeFile as writeFile2 } from "node:fs/promises";
33939
- import path222 from "node:path";
33939
+ import path23 from "node:path";
33940
33940
  import { promisify as promisify2 } from "node:util";
33941
+ import path222 from "node:path";
33941
33942
  import os2 from "node:os";
33942
33943
  import path21 from "node:path";
33943
33944
  import { copyFile, mkdir as mkdir8, readFile as readFile9, readdir as readdir2, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
33945
+ import path25 from "node:path";
33944
33946
  import path24 from "node:path";
33945
- import path23 from "node:path";
33946
33947
  import JSON5 from "json5";
33947
33948
  import { writeFile as writeFile5 } from "node:fs/promises";
33948
- import path26 from "node:path";
33949
+ import path27 from "node:path";
33949
33950
  import { constants as constants4 } from "node:fs";
33950
33951
  import { access as access4, readFile as readFile10 } from "node:fs/promises";
33951
- import path28 from "node:path";
33952
- import { parse as parse32 } from "yaml";
33953
33952
  import path29 from "node:path";
33953
+ import { parse as parse32 } from "yaml";
33954
+ import path30 from "node:path";
33954
33955
  import fg2 from "fast-glob";
33955
33956
  import { mkdtemp as mkdtemp2, rm as rm3, writeFile as writeFile6 } from "node:fs/promises";
33956
33957
  import { tmpdir as tmpdir2 } from "node:os";
@@ -33958,35 +33959,33 @@ import { dirname, join } from "node:path";
33958
33959
  import { randomBytes } from "node:crypto";
33959
33960
  import { createServer } from "node:http";
33960
33961
  import fs2 from "node:fs/promises";
33961
- import path30 from "node:path";
33962
+ import path31 from "node:path";
33962
33963
  import { createHash as createHash2, randomUUID as randomUUID7 } from "node:crypto";
33963
33964
  import { mkdir as mkdir12, stat as stat7 } from "node:fs/promises";
33964
- import path37 from "node:path";
33965
+ import path38 from "node:path";
33965
33966
  import micromatch4 from "micromatch";
33966
33967
  import { readFileSync } from "node:fs";
33967
- import path31 from "node:path";
33968
33968
  import path322 from "node:path";
33969
+ import path33 from "node:path";
33969
33970
  import fg3 from "fast-glob";
33970
33971
  import { exec as execCallback } from "node:child_process";
33971
33972
  import { readdirSync as readdirSync2, statSync } from "node:fs";
33972
- import path33 from "node:path";
33973
+ import path34 from "node:path";
33973
33974
  import { promisify as promisify4 } from "node:util";
33974
33975
  import { cp, mkdir as mkdir10, readdir as readdir3, rm as rm4, stat as stat5 } from "node:fs/promises";
33975
- import os3 from "node:os";
33976
- import path34 from "node:path";
33976
+ import path35 from "node:path";
33977
33977
  import { execFile } from "node:child_process";
33978
33978
  import { createHash } from "node:crypto";
33979
33979
  import { existsSync as existsSync2 } from "node:fs";
33980
33980
  import { mkdir as mkdir11, rm as rm5, unlink, writeFile as writeFile7 } from "node:fs/promises";
33981
- import os4 from "node:os";
33982
- import path35 from "node:path";
33981
+ import path36 from "node:path";
33983
33982
  import { promisify as promisify5 } from "node:util";
33984
33983
  import { readdir as readdir4, stat as stat6 } from "node:fs/promises";
33985
- import path36 from "node:path";
33984
+ import path37 from "node:path";
33986
33985
  import { existsSync as existsSync3 } from "node:fs";
33987
- import path38 from "node:path";
33988
- import { mkdir as mkdir13, readFile as readFile11, writeFile as writeFile8 } from "node:fs/promises";
33989
33986
  import path39 from "node:path";
33987
+ import { mkdir as mkdir13, readFile as readFile11, writeFile as writeFile8 } from "node:fs/promises";
33988
+ import path40 from "node:path";
33990
33989
  function computeTraceSummary(messages) {
33991
33990
  const toolCallCounts = {};
33992
33991
  const toolDurations = {};
@@ -34183,7 +34182,7 @@ async function resolveFileReference2(ref, evalFileDir) {
34183
34182
  const rawPath = extractFilePath(ref);
34184
34183
  const absolutePattern = path3.resolve(evalFileDir, rawPath);
34185
34184
  if (isGlobPattern(rawPath)) {
34186
- const matches = await fg(absolutePattern, {
34185
+ const matches = await fg(absolutePattern.replaceAll("\\", "/"), {
34187
34186
  onlyFiles: true,
34188
34187
  absolute: true
34189
34188
  });
@@ -38891,7 +38890,7 @@ function subscribeToCopilotCliLogEntries(listener) {
38891
38890
  };
38892
38891
  }
38893
38892
  function resolvePlatformCliPath() {
38894
- const os5 = platform();
38893
+ const os3 = platform();
38895
38894
  const cpu = arch();
38896
38895
  const platformMap = {
38897
38896
  linux: "linux",
@@ -38902,13 +38901,13 @@ function resolvePlatformCliPath() {
38902
38901
  x64: "x64",
38903
38902
  arm64: "arm64"
38904
38903
  };
38905
- const osPart = platformMap[os5];
38904
+ const osPart = platformMap[os3];
38906
38905
  const archPart = archMap[cpu];
38907
38906
  if (!osPart || !archPart) {
38908
38907
  return void 0;
38909
38908
  }
38910
38909
  const packageName = `@github/copilot-${osPart}-${archPart}`;
38911
- const binaryName = os5 === "win32" ? "copilot.exe" : "copilot";
38910
+ const binaryName = os3 === "win32" ? "copilot.exe" : "copilot";
38912
38911
  try {
38913
38912
  const resolved = import.meta.resolve(`${packageName}/package.json`);
38914
38913
  const packageJsonPath = resolved.startsWith("file:") ? fileURLToPath2(resolved) : resolved;
@@ -40915,11 +40914,35 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
40915
40914
  }
40916
40915
  return true;
40917
40916
  }
40917
+ var logged = false;
40918
+ function getAgentvHome() {
40919
+ const envHome = process.env.AGENTV_HOME;
40920
+ if (envHome) {
40921
+ if (!logged) {
40922
+ logged = true;
40923
+ console.warn(`Using AGENTV_HOME: ${envHome}`);
40924
+ }
40925
+ return envHome;
40926
+ }
40927
+ return path21.join(os2.homedir(), ".agentv");
40928
+ }
40929
+ function getWorkspacesRoot() {
40930
+ return path21.join(getAgentvHome(), "workspaces");
40931
+ }
40932
+ function getGitCacheRoot() {
40933
+ return path21.join(getAgentvHome(), "git-cache");
40934
+ }
40935
+ function getSubagentsRoot() {
40936
+ return path21.join(getAgentvHome(), "subagents");
40937
+ }
40938
+ function getTraceStateRoot() {
40939
+ return path21.join(getAgentvHome(), "trace-state");
40940
+ }
40918
40941
  var DEFAULT_LOCK_NAME = "subagent.lock";
40919
40942
  var DEFAULT_ALIVE_FILENAME = ".alive";
40920
40943
  function getDefaultSubagentRoot(vscodeCmd = "code") {
40921
40944
  const folder = vscodeCmd === "code-insiders" ? "vscode-insiders-agents" : "vscode-agents";
40922
- return path21.join(os2.homedir(), ".agentv", "subagents", folder);
40945
+ return path222.join(getSubagentsRoot(), folder);
40923
40946
  }
40924
40947
  var DEFAULT_SUBAGENT_ROOT = getDefaultSubagentRoot();
40925
40948
  var execAsync2 = promisify2(exec);
@@ -40931,12 +40954,19 @@ description: 'Wake-up Signal'
40931
40954
  model: Grok Code Fast 1 (copilot)
40932
40955
  ---`;
40933
40956
  function spawnVsCode(vscodeCmd, args, options) {
40934
- const child = spawn3(vscodeCmd, args, {
40957
+ const useShell = options?.shell ?? true;
40958
+ const command = useShell ? shellQuote(vscodeCmd) : vscodeCmd;
40959
+ const child = spawn3(command, args, {
40935
40960
  windowsHide: true,
40936
- shell: options?.shell ?? true,
40961
+ shell: useShell,
40937
40962
  detached: false
40938
40963
  });
40939
- child.on("error", () => {
40964
+ child.on("error", (error40) => {
40965
+ const label = options?.label ?? "spawn";
40966
+ const renderedArgs = args.map((value) => JSON.stringify(value)).join(" ");
40967
+ console.error(
40968
+ `[vscode] ${label} failed: command=${JSON.stringify(vscodeCmd)} args=${renderedArgs} error=${error40.message}`
40969
+ );
40940
40970
  });
40941
40971
  return child;
40942
40972
  }
@@ -40973,16 +41003,20 @@ async function checkWorkspaceOpened(workspaceName, vscodeCmd) {
40973
41003
  async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir, vscodeCmd, pollInterval = 1, timeout = 60) {
40974
41004
  const alreadyOpen = await checkWorkspaceOpened(workspaceName, vscodeCmd);
40975
41005
  if (alreadyOpen) {
40976
- spawnVsCode(shellQuote(vscodeCmd), [workspacePath]);
41006
+ const child = spawnVsCode(vscodeCmd, [workspacePath], { label: "focus-existing-workspace" });
41007
+ await raceSpawnError(child);
40977
41008
  return true;
40978
41009
  }
40979
- const aliveFile = path222.join(subagentDir, DEFAULT_ALIVE_FILENAME);
41010
+ const aliveFile = path23.join(subagentDir, DEFAULT_ALIVE_FILENAME);
40980
41011
  await removeIfExists(aliveFile);
40981
- const githubAgentsDir = path222.join(subagentDir, ".github", "agents");
41012
+ const githubAgentsDir = path23.join(subagentDir, ".github", "agents");
40982
41013
  await mkdir7(githubAgentsDir, { recursive: true });
40983
- const wakeupDst = path222.join(githubAgentsDir, "wakeup.md");
41014
+ const wakeupDst = path23.join(githubAgentsDir, "wakeup.md");
40984
41015
  await writeFile2(wakeupDst, DEFAULT_WAKEUP_CONTENT, "utf8");
40985
- spawnVsCode(shellQuote(vscodeCmd), [workspacePath]);
41016
+ const workspaceChild = spawnVsCode(vscodeCmd, [workspacePath], {
41017
+ label: "open-workspace"
41018
+ });
41019
+ await raceSpawnError(workspaceChild);
40986
41020
  await sleep2(100);
40987
41021
  const wakeupChatId = "wakeup";
40988
41022
  const chatArgs = [
@@ -40990,9 +41024,10 @@ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir,
40990
41024
  "chat",
40991
41025
  "-m",
40992
41026
  wakeupChatId,
40993
- `create a file named .alive in the ${path222.basename(subagentDir)} folder`
41027
+ `create a file named .alive in the ${path23.basename(subagentDir)} folder`
40994
41028
  ];
40995
- spawnVsCode(shellQuote(vscodeCmd), chatArgs);
41029
+ const wakeupChild = spawnVsCode(vscodeCmd, chatArgs, { label: "send-wakeup-chat" });
41030
+ await raceSpawnError(wakeupChild);
40996
41031
  const start = Date.now();
40997
41032
  while (!await pathExists(aliveFile)) {
40998
41033
  if (Date.now() - start > timeout * 1e3) {
@@ -41004,10 +41039,10 @@ async function ensureWorkspaceFocused(workspacePath, workspaceName, subagentDir,
41004
41039
  return true;
41005
41040
  }
41006
41041
  async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, requestInstructions, timestamp, vscodeCmd) {
41007
- const workspacePath = path222.join(subagentDir, `${path222.basename(subagentDir)}.code-workspace`);
41008
- const messagesDir = path222.join(subagentDir, "messages");
41042
+ const workspacePath = path23.join(subagentDir, `${path23.basename(subagentDir)}.code-workspace`);
41043
+ const messagesDir = path23.join(subagentDir, "messages");
41009
41044
  await mkdir7(messagesDir, { recursive: true });
41010
- const reqFile = path222.join(messagesDir, `${timestamp}_req.md`);
41045
+ const reqFile = path23.join(messagesDir, `${timestamp}_req.md`);
41011
41046
  await writeFile2(reqFile, requestInstructions, { encoding: "utf8" });
41012
41047
  const reqUri = pathToFileUri2(reqFile);
41013
41048
  const chatArgs = ["-r", "chat", "-m", chatId];
@@ -41015,25 +41050,25 @@ async function launchVsCodeWithChat(subagentDir, chatId, attachmentPaths, reques
41015
41050
  chatArgs.push("-a", attachment);
41016
41051
  }
41017
41052
  chatArgs.push("-a", reqFile);
41018
- chatArgs.push(`Follow instructions in [${path222.basename(reqFile)}](${reqUri})`);
41053
+ chatArgs.push(`Follow instructions in [${path23.basename(reqFile)}](${reqUri})`);
41019
41054
  const workspaceReady = await ensureWorkspaceFocused(
41020
41055
  workspacePath,
41021
- path222.basename(subagentDir),
41056
+ path23.basename(subagentDir),
41022
41057
  subagentDir,
41023
41058
  vscodeCmd
41024
41059
  );
41025
41060
  if (!workspaceReady) {
41026
41061
  throw new Error(
41027
- `VS Code workspace '${path222.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
41062
+ `VS Code workspace '${path23.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
41028
41063
  );
41029
41064
  }
41030
41065
  await sleep2(500);
41031
- const child = spawnVsCode(shellQuote(vscodeCmd), chatArgs);
41066
+ const child = spawnVsCode(vscodeCmd, chatArgs, { label: "send-chat" });
41032
41067
  await raceSpawnError(child);
41033
41068
  }
41034
41069
  async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, chatInstruction, vscodeCmd) {
41035
- const workspacePath = path222.join(subagentDir, `${path222.basename(subagentDir)}.code-workspace`);
41036
- const messagesDir = path222.join(subagentDir, "messages");
41070
+ const workspacePath = path23.join(subagentDir, `${path23.basename(subagentDir)}.code-workspace`);
41071
+ const messagesDir = path23.join(subagentDir, "messages");
41037
41072
  await mkdir7(messagesDir, { recursive: true });
41038
41073
  const chatArgs = ["-r", "chat", "-m", chatId];
41039
41074
  for (const attachment of attachmentPaths) {
@@ -41042,17 +41077,17 @@ async function launchVsCodeWithBatchChat(subagentDir, chatId, attachmentPaths, c
41042
41077
  chatArgs.push(chatInstruction);
41043
41078
  const workspaceReady = await ensureWorkspaceFocused(
41044
41079
  workspacePath,
41045
- path222.basename(subagentDir),
41080
+ path23.basename(subagentDir),
41046
41081
  subagentDir,
41047
41082
  vscodeCmd
41048
41083
  );
41049
41084
  if (!workspaceReady) {
41050
41085
  throw new Error(
41051
- `VS Code workspace '${path222.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
41086
+ `VS Code workspace '${path23.basename(subagentDir)}' failed to become ready within the timeout. Check that '${vscodeCmd}' can open workspaces.`
41052
41087
  );
41053
41088
  }
41054
41089
  await sleep2(500);
41055
- const child = spawnVsCode(shellQuote(vscodeCmd), chatArgs);
41090
+ const child = spawnVsCode(vscodeCmd, chatArgs, { label: "send-batch-chat" });
41056
41091
  await raceSpawnError(child);
41057
41092
  }
41058
41093
  function transformWorkspacePaths(workspaceContent, templateDir) {
@@ -41070,10 +41105,10 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
41070
41105
  }
41071
41106
  const transformedFolders = workspace.folders.map((folder) => {
41072
41107
  const folderPath = folder.path;
41073
- if (path23.isAbsolute(folderPath)) {
41108
+ if (path24.isAbsolute(folderPath)) {
41074
41109
  return folder;
41075
41110
  }
41076
- const absolutePath = path23.resolve(templateDir, folderPath);
41111
+ const absolutePath = path24.resolve(templateDir, folderPath);
41077
41112
  return {
41078
41113
  ...folder,
41079
41114
  path: absolutePath
@@ -41095,19 +41130,19 @@ function transformWorkspacePaths(workspaceContent, templateDir) {
41095
41130
  if (locationMap && typeof locationMap === "object") {
41096
41131
  const transformedMap = {};
41097
41132
  for (const [locationPath, value] of Object.entries(locationMap)) {
41098
- const isAbsolute = path23.isAbsolute(locationPath);
41133
+ const isAbsolute = path24.isAbsolute(locationPath);
41099
41134
  if (isAbsolute) {
41100
41135
  transformedMap[locationPath] = value;
41101
41136
  } else {
41102
41137
  const firstGlobIndex = locationPath.search(/[*]/);
41103
41138
  if (firstGlobIndex === -1) {
41104
- const resolvedPath = path23.resolve(templateDir, locationPath).replace(/\\/g, "/");
41139
+ const resolvedPath = path24.resolve(templateDir, locationPath).replace(/\\/g, "/");
41105
41140
  transformedMap[resolvedPath] = value;
41106
41141
  } else {
41107
41142
  const basePathEnd = locationPath.lastIndexOf("/", firstGlobIndex);
41108
41143
  const basePath = basePathEnd !== -1 ? locationPath.substring(0, basePathEnd) : ".";
41109
41144
  const patternPath = locationPath.substring(basePathEnd !== -1 ? basePathEnd : 0);
41110
- const resolvedPath = (path23.resolve(templateDir, basePath) + patternPath).replace(
41145
+ const resolvedPath = (path24.resolve(templateDir, basePath) + patternPath).replace(
41111
41146
  /\\/g,
41112
41147
  "/"
41113
41148
  );
@@ -41146,7 +41181,7 @@ async function findUnlockedSubagent(subagentRoot) {
41146
41181
  number: Number.parseInt(entry.name.split("-")[1] ?? "", 10)
41147
41182
  })).filter((entry) => Number.isInteger(entry.number)).sort((a, b) => a.number - b.number);
41148
41183
  for (const subagent of subagents) {
41149
- const lockFile = path24.join(subagent.absolutePath, DEFAULT_LOCK_NAME);
41184
+ const lockFile = path25.join(subagent.absolutePath, DEFAULT_LOCK_NAME);
41150
41185
  if (!await pathExists(lockFile)) {
41151
41186
  return subagent.absolutePath;
41152
41187
  }
@@ -41156,7 +41191,7 @@ async function findUnlockedSubagent(subagentRoot) {
41156
41191
  async function copyAgentConfig(subagentDir, workspaceTemplate, cwd) {
41157
41192
  let workspaceContent;
41158
41193
  if (workspaceTemplate) {
41159
- const workspaceSrc = path24.resolve(workspaceTemplate);
41194
+ const workspaceSrc = path25.resolve(workspaceTemplate);
41160
41195
  if (!await pathExists(workspaceSrc)) {
41161
41196
  throw new Error(`workspace template not found: ${workspaceSrc}`);
41162
41197
  }
@@ -41169,13 +41204,13 @@ async function copyAgentConfig(subagentDir, workspaceTemplate, cwd) {
41169
41204
  } else {
41170
41205
  workspaceContent = DEFAULT_WORKSPACE_TEMPLATE;
41171
41206
  }
41172
- const workspaceName = `${path24.basename(subagentDir)}.code-workspace`;
41173
- const workspaceDst = path24.join(subagentDir, workspaceName);
41174
- const templateDir = workspaceTemplate ? path24.dirname(path24.resolve(workspaceTemplate)) : subagentDir;
41207
+ const workspaceName = `${path25.basename(subagentDir)}.code-workspace`;
41208
+ const workspaceDst = path25.join(subagentDir, workspaceName);
41209
+ const templateDir = workspaceTemplate ? path25.dirname(path25.resolve(workspaceTemplate)) : subagentDir;
41175
41210
  const workspaceJson = JSON.stringify(workspaceContent, null, 2);
41176
41211
  let transformedContent = transformWorkspacePaths(workspaceJson, templateDir);
41177
41212
  if (cwd) {
41178
- const absCwd = path24.resolve(cwd);
41213
+ const absCwd = path25.resolve(cwd);
41179
41214
  const parsed = JSON.parse(transformedContent);
41180
41215
  const alreadyPresent = parsed.folders.some((f) => f.path === absCwd);
41181
41216
  if (!alreadyPresent) {
@@ -41184,35 +41219,35 @@ async function copyAgentConfig(subagentDir, workspaceTemplate, cwd) {
41184
41219
  }
41185
41220
  }
41186
41221
  await writeFile3(workspaceDst, transformedContent, "utf8");
41187
- const messagesDir = path24.join(subagentDir, "messages");
41222
+ const messagesDir = path25.join(subagentDir, "messages");
41188
41223
  await mkdir8(messagesDir, { recursive: true });
41189
41224
  return { workspace: workspaceDst, messagesDir };
41190
41225
  }
41191
41226
  async function createSubagentLock(subagentDir) {
41192
- const messagesDir = path24.join(subagentDir, "messages");
41227
+ const messagesDir = path25.join(subagentDir, "messages");
41193
41228
  if (await pathExists(messagesDir)) {
41194
41229
  const files = await readdir2(messagesDir);
41195
41230
  await Promise.all(
41196
41231
  files.map(async (file2) => {
41197
- const target = path24.join(messagesDir, file2);
41232
+ const target = path25.join(messagesDir, file2);
41198
41233
  await removeIfExists(target);
41199
41234
  })
41200
41235
  );
41201
41236
  }
41202
- const githubAgentsDir = path24.join(subagentDir, ".github", "agents");
41237
+ const githubAgentsDir = path25.join(subagentDir, ".github", "agents");
41203
41238
  if (await pathExists(githubAgentsDir)) {
41204
41239
  const agentFiles = await readdir2(githubAgentsDir);
41205
41240
  const preservedFiles = /* @__PURE__ */ new Set(["wakeup.md", "subagent.md"]);
41206
41241
  await Promise.all(
41207
- agentFiles.filter((file2) => file2.endsWith(".md") && !preservedFiles.has(file2)).map((file2) => removeIfExists(path24.join(githubAgentsDir, file2)))
41242
+ agentFiles.filter((file2) => file2.endsWith(".md") && !preservedFiles.has(file2)).map((file2) => removeIfExists(path25.join(githubAgentsDir, file2)))
41208
41243
  );
41209
41244
  }
41210
- const lockFile = path24.join(subagentDir, DEFAULT_LOCK_NAME);
41245
+ const lockFile = path25.join(subagentDir, DEFAULT_LOCK_NAME);
41211
41246
  await writeFile3(lockFile, "", { encoding: "utf8" });
41212
41247
  return lockFile;
41213
41248
  }
41214
41249
  async function removeSubagentLock(subagentDir) {
41215
- const lockFile = path24.join(subagentDir, DEFAULT_LOCK_NAME);
41250
+ const lockFile = path25.join(subagentDir, DEFAULT_LOCK_NAME);
41216
41251
  await removeIfExists(lockFile);
41217
41252
  }
41218
41253
  async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspaceTemplate, dryRun, cwd) {
@@ -41232,9 +41267,9 @@ async function prepareSubagentDirectory(subagentDir, promptFile, chatId, workspa
41232
41267
  return 1;
41233
41268
  }
41234
41269
  if (promptFile) {
41235
- const githubAgentsDir = path24.join(subagentDir, ".github", "agents");
41270
+ const githubAgentsDir = path25.join(subagentDir, ".github", "agents");
41236
41271
  await mkdir8(githubAgentsDir, { recursive: true });
41237
- const agentFile = path24.join(githubAgentsDir, `${chatId}.md`);
41272
+ const agentFile = path25.join(githubAgentsDir, `${chatId}.md`);
41238
41273
  try {
41239
41274
  await copyFile(promptFile, agentFile);
41240
41275
  } catch (error40) {
@@ -41251,7 +41286,7 @@ async function resolvePromptFile(promptFile) {
41251
41286
  if (!promptFile) {
41252
41287
  return void 0;
41253
41288
  }
41254
- const resolvedPrompt = path25.resolve(promptFile);
41289
+ const resolvedPrompt = path26.resolve(promptFile);
41255
41290
  if (!await pathExists(resolvedPrompt)) {
41256
41291
  throw new Error(`Prompt file not found: ${resolvedPrompt}`);
41257
41292
  }
@@ -41267,7 +41302,7 @@ async function resolveAttachments(extraAttachments) {
41267
41302
  }
41268
41303
  const resolved = [];
41269
41304
  for (const attachment of extraAttachments) {
41270
- const resolvedPath = path25.resolve(attachment);
41305
+ const resolvedPath = path26.resolve(attachment);
41271
41306
  if (!await pathExists(resolvedPath)) {
41272
41307
  throw new Error(`Attachment not found: ${resolvedPath}`);
41273
41308
  }
@@ -41309,7 +41344,7 @@ async function dispatchAgentSession(options) {
41309
41344
  error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
41310
41345
  };
41311
41346
  }
41312
- const subagentName = path25.basename(subagentDir);
41347
+ const subagentName = path26.basename(subagentDir);
41313
41348
  const chatId = Math.random().toString(16).slice(2, 10);
41314
41349
  const preparationResult = await prepareSubagentDirectory(
41315
41350
  subagentDir,
@@ -41337,9 +41372,9 @@ async function dispatchAgentSession(options) {
41337
41372
  };
41338
41373
  }
41339
41374
  const timestamp = generateTimestamp();
41340
- const messagesDir = path25.join(subagentDir, "messages");
41341
- const responseFileTmp = path25.join(messagesDir, `${timestamp}_res.tmp.md`);
41342
- const responseFileFinal = path25.join(messagesDir, `${timestamp}_res.md`);
41375
+ const messagesDir = path26.join(subagentDir, "messages");
41376
+ const responseFileTmp = path26.join(messagesDir, `${timestamp}_res.tmp.md`);
41377
+ const responseFileFinal = path26.join(messagesDir, `${timestamp}_res.md`);
41343
41378
  const requestInstructions = createRequestPrompt(
41344
41379
  userQuery,
41345
41380
  responseFileTmp,
@@ -41444,7 +41479,7 @@ async function dispatchBatchAgent(options) {
41444
41479
  error: "No unlocked subagents available. Provision additional subagents with: subagent code provision --subagents <desired_total>"
41445
41480
  };
41446
41481
  }
41447
- subagentName = path25.basename(subagentDir);
41482
+ subagentName = path26.basename(subagentDir);
41448
41483
  const chatId = Math.random().toString(16).slice(2, 10);
41449
41484
  const preparationResult = await prepareSubagentDirectory(
41450
41485
  subagentDir,
@@ -41475,17 +41510,17 @@ async function dispatchBatchAgent(options) {
41475
41510
  };
41476
41511
  }
41477
41512
  const timestamp = generateTimestamp();
41478
- const messagesDir = path25.join(subagentDir, "messages");
41513
+ const messagesDir = path26.join(subagentDir, "messages");
41479
41514
  requestFiles = userQueries.map(
41480
- (_, index) => path25.join(messagesDir, `${timestamp}_${index}_req.md`)
41515
+ (_, index) => path26.join(messagesDir, `${timestamp}_${index}_req.md`)
41481
41516
  );
41482
41517
  const responseTmpFiles = userQueries.map(
41483
- (_, index) => path25.join(messagesDir, `${timestamp}_${index}_res.tmp.md`)
41518
+ (_, index) => path26.join(messagesDir, `${timestamp}_${index}_res.tmp.md`)
41484
41519
  );
41485
41520
  responseFilesFinal = userQueries.map(
41486
- (_, index) => path25.join(messagesDir, `${timestamp}_${index}_res.md`)
41521
+ (_, index) => path26.join(messagesDir, `${timestamp}_${index}_res.md`)
41487
41522
  );
41488
- const orchestratorFile = path25.join(messagesDir, `${timestamp}_orchestrator.md`);
41523
+ const orchestratorFile = path26.join(messagesDir, `${timestamp}_orchestrator.md`);
41489
41524
  if (!dryRun) {
41490
41525
  await Promise.all(
41491
41526
  userQueries.map((query, index) => {
@@ -41598,7 +41633,7 @@ async function provisionSubagents(options) {
41598
41633
  if (!Number.isInteger(subagents) || subagents < 1) {
41599
41634
  throw new Error("subagents must be a positive integer");
41600
41635
  }
41601
- const targetPath = path26.resolve(targetRoot);
41636
+ const targetPath = path27.resolve(targetRoot);
41602
41637
  if (!dryRun) {
41603
41638
  await ensureDir(targetPath);
41604
41639
  }
@@ -41618,7 +41653,7 @@ async function provisionSubagents(options) {
41618
41653
  continue;
41619
41654
  }
41620
41655
  highestNumber = Math.max(highestNumber, parsed);
41621
- const lockFile = path26.join(entry.absolutePath, lockName);
41656
+ const lockFile = path27.join(entry.absolutePath, lockName);
41622
41657
  const locked = await pathExists(lockFile);
41623
41658
  if (locked) {
41624
41659
  lockedSubagents.add(entry.absolutePath);
@@ -41635,10 +41670,10 @@ async function provisionSubagents(options) {
41635
41670
  break;
41636
41671
  }
41637
41672
  const subagentDir = subagent.absolutePath;
41638
- const githubAgentsDir = path26.join(subagentDir, ".github", "agents");
41639
- const lockFile = path26.join(subagentDir, lockName);
41640
- const workspaceDst = path26.join(subagentDir, `${path26.basename(subagentDir)}.code-workspace`);
41641
- const wakeupDst = path26.join(githubAgentsDir, "wakeup.md");
41673
+ const githubAgentsDir = path27.join(subagentDir, ".github", "agents");
41674
+ const lockFile = path27.join(subagentDir, lockName);
41675
+ const workspaceDst = path27.join(subagentDir, `${path27.basename(subagentDir)}.code-workspace`);
41676
+ const wakeupDst = path27.join(githubAgentsDir, "wakeup.md");
41642
41677
  const isLocked = await pathExists(lockFile);
41643
41678
  if (isLocked && !force) {
41644
41679
  continue;
@@ -41676,10 +41711,10 @@ async function provisionSubagents(options) {
41676
41711
  let nextIndex = highestNumber;
41677
41712
  while (subagentsProvisioned < subagents) {
41678
41713
  nextIndex += 1;
41679
- const subagentDir = path26.join(targetPath, `subagent-${nextIndex}`);
41680
- const githubAgentsDir = path26.join(subagentDir, ".github", "agents");
41681
- const workspaceDst = path26.join(subagentDir, `${path26.basename(subagentDir)}.code-workspace`);
41682
- const wakeupDst = path26.join(githubAgentsDir, "wakeup.md");
41714
+ const subagentDir = path27.join(targetPath, `subagent-${nextIndex}`);
41715
+ const githubAgentsDir = path27.join(subagentDir, ".github", "agents");
41716
+ const workspaceDst = path27.join(subagentDir, `${path27.basename(subagentDir)}.code-workspace`);
41717
+ const wakeupDst = path27.join(githubAgentsDir, "wakeup.md");
41683
41718
  if (!dryRun) {
41684
41719
  await ensureDir(subagentDir);
41685
41720
  await ensureDir(githubAgentsDir);
@@ -41869,7 +41904,7 @@ var VSCodeProvider = class {
41869
41904
  async function locateVSCodeExecutable(candidate) {
41870
41905
  const includesPathSeparator = candidate.includes("/") || candidate.includes("\\");
41871
41906
  if (includesPathSeparator) {
41872
- const resolved = path27.isAbsolute(candidate) ? candidate : path27.resolve(candidate);
41907
+ const resolved = path28.isAbsolute(candidate) ? candidate : path28.resolve(candidate);
41873
41908
  try {
41874
41909
  await access3(resolved, constants3.F_OK);
41875
41910
  return resolved;
@@ -41898,7 +41933,7 @@ async function resolveWorkspaceTemplateFile(template) {
41898
41933
  return void 0;
41899
41934
  }
41900
41935
  try {
41901
- const stats = await stat4(path27.resolve(template));
41936
+ const stats = await stat4(path28.resolve(template));
41902
41937
  return stats.isFile() ? template : void 0;
41903
41938
  } catch {
41904
41939
  return template;
@@ -41924,7 +41959,7 @@ function buildMandatoryPrereadBlock2(guidelineFiles, attachmentFiles) {
41924
41959
  return "";
41925
41960
  }
41926
41961
  const buildList = (files) => files.map((absolutePath) => {
41927
- const fileName = path27.basename(absolutePath);
41962
+ const fileName = path28.basename(absolutePath);
41928
41963
  const fileUri = pathToFileUri3(absolutePath);
41929
41964
  return `* [${fileName}](${fileUri})`;
41930
41965
  });
@@ -41949,8 +41984,8 @@ function collectGuidelineFiles2(attachments, guidelinePatterns) {
41949
41984
  }
41950
41985
  const unique = /* @__PURE__ */ new Map();
41951
41986
  for (const attachment of attachments) {
41952
- const absolutePath = path27.resolve(attachment);
41953
- const normalized = absolutePath.split(path27.sep).join("/");
41987
+ const absolutePath = path28.resolve(attachment);
41988
+ const normalized = absolutePath.split(path28.sep).join("/");
41954
41989
  if (isGuidelineFile(normalized, guidelinePatterns)) {
41955
41990
  if (!unique.has(absolutePath)) {
41956
41991
  unique.set(absolutePath, absolutePath);
@@ -41965,7 +42000,7 @@ function collectAttachmentFiles(attachments) {
41965
42000
  }
41966
42001
  const unique = /* @__PURE__ */ new Map();
41967
42002
  for (const attachment of attachments) {
41968
- const absolutePath = path27.resolve(attachment);
42003
+ const absolutePath = path28.resolve(attachment);
41969
42004
  if (!unique.has(absolutePath)) {
41970
42005
  unique.set(absolutePath, absolutePath);
41971
42006
  }
@@ -41973,7 +42008,7 @@ function collectAttachmentFiles(attachments) {
41973
42008
  return Array.from(unique.values());
41974
42009
  }
41975
42010
  function pathToFileUri3(filePath) {
41976
- const absolutePath = path27.isAbsolute(filePath) ? filePath : path27.resolve(filePath);
42011
+ const absolutePath = path28.isAbsolute(filePath) ? filePath : path28.resolve(filePath);
41977
42012
  const normalizedPath = absolutePath.replace(/\\/g, "/");
41978
42013
  if (/^[a-zA-Z]:\//.test(normalizedPath)) {
41979
42014
  return `file:///${normalizedPath}`;
@@ -41986,7 +42021,7 @@ function normalizeAttachments(attachments) {
41986
42021
  }
41987
42022
  const deduped = /* @__PURE__ */ new Set();
41988
42023
  for (const attachment of attachments) {
41989
- deduped.add(path27.resolve(attachment));
42024
+ deduped.add(path28.resolve(attachment));
41990
42025
  }
41991
42026
  return Array.from(deduped);
41992
42027
  }
@@ -41995,7 +42030,7 @@ function mergeAttachments(all) {
41995
42030
  for (const list of all) {
41996
42031
  if (!list) continue;
41997
42032
  for (const inputFile of list) {
41998
- deduped.add(path27.resolve(inputFile));
42033
+ deduped.add(path28.resolve(inputFile));
41999
42034
  }
42000
42035
  }
42001
42036
  return deduped.size > 0 ? Array.from(deduped) : void 0;
@@ -42075,7 +42110,7 @@ async function fileExists3(filePath) {
42075
42110
  }
42076
42111
  }
42077
42112
  async function readTargetDefinitions(filePath) {
42078
- const absolutePath = path28.resolve(filePath);
42113
+ const absolutePath = path29.resolve(filePath);
42079
42114
  if (!await fileExists3(absolutePath)) {
42080
42115
  throw new Error(`targets.yaml not found at ${absolutePath}`);
42081
42116
  }
@@ -42096,11 +42131,11 @@ function listTargetNames(definitions) {
42096
42131
  async function discoverProviders(registry2, baseDir) {
42097
42132
  const patterns = ["*.ts", "*.js", "*.mts", "*.mjs"];
42098
42133
  const candidateDirs = [];
42099
- let dir = path29.resolve(baseDir);
42100
- const root = path29.parse(dir).root;
42134
+ let dir = path30.resolve(baseDir);
42135
+ const root = path30.parse(dir).root;
42101
42136
  while (dir !== root) {
42102
- candidateDirs.push(path29.join(dir, ".agentv", "providers"));
42103
- dir = path29.dirname(dir);
42137
+ candidateDirs.push(path30.join(dir, ".agentv", "providers"));
42138
+ dir = path30.dirname(dir);
42104
42139
  }
42105
42140
  let files = [];
42106
42141
  for (const providersDir of candidateDirs) {
@@ -42116,7 +42151,7 @@ async function discoverProviders(registry2, baseDir) {
42116
42151
  }
42117
42152
  const discoveredKinds = [];
42118
42153
  for (const filePath of files) {
42119
- const basename = path29.basename(filePath);
42154
+ const basename = path30.basename(filePath);
42120
42155
  const kindName = basename.replace(/\.(ts|js|mts|mjs)$/, "");
42121
42156
  if (registry2.has(kindName)) {
42122
42157
  continue;
@@ -42314,13 +42349,13 @@ async function execFileWithStdinNode(argv, stdinPayload, options) {
42314
42349
  async function execShellWithStdin(command, stdinPayload, options = {}) {
42315
42350
  const { mkdir: mkdir14, readFile: readFile12, rm: rm6, writeFile: writeFile9 } = await import("node:fs/promises");
42316
42351
  const { tmpdir: tmpdir3 } = await import("node:os");
42317
- const path40 = await import("node:path");
42352
+ const path41 = await import("node:path");
42318
42353
  const { randomUUID: randomUUID8 } = await import("node:crypto");
42319
- const dir = path40.join(tmpdir3(), `agentv-exec-${randomUUID8()}`);
42354
+ const dir = path41.join(tmpdir3(), `agentv-exec-${randomUUID8()}`);
42320
42355
  await mkdir14(dir, { recursive: true });
42321
- const stdinPath = path40.join(dir, "stdin.txt");
42322
- const stdoutPath = path40.join(dir, "stdout.txt");
42323
- const stderrPath = path40.join(dir, "stderr.txt");
42356
+ const stdinPath = path41.join(dir, "stdin.txt");
42357
+ const stdoutPath = path41.join(dir, "stdout.txt");
42358
+ const stderrPath = path41.join(dir, "stderr.txt");
42324
42359
  await writeFile9(stdinPath, stdinPayload, "utf8");
42325
42360
  const wrappedCommand = process.platform === "win32" ? `(${command}) < ${shellEscapePath(stdinPath)} > ${shellEscapePath(stdoutPath)} 2> ${shellEscapePath(stderrPath)}` : `(${command}) < ${shellEscapePath(stdinPath)} > ${shellEscapePath(stdoutPath)} 2> ${shellEscapePath(stderrPath)}`;
42326
42361
  const { spawn: spawn4 } = await import("node:child_process");
@@ -42664,7 +42699,7 @@ var CodeEvaluator = class {
42664
42699
  outputPath,
42665
42700
  guidelineFiles: context.evalCase.guideline_paths,
42666
42701
  inputFiles: context.evalCase.file_paths.filter(
42667
- (path40) => !context.evalCase.guideline_paths.includes(path40)
42702
+ (path41) => !context.evalCase.guideline_paths.includes(path41)
42668
42703
  ),
42669
42704
  input: context.evalCase.input,
42670
42705
  trace: context.trace ?? null,
@@ -43847,115 +43882,115 @@ var FieldAccuracyEvaluator = class {
43847
43882
  * Evaluate a single field against the expected value.
43848
43883
  */
43849
43884
  evaluateField(fieldConfig, candidateData, expectedData) {
43850
- const { path: path40, match, required: required2 = true, weight = 1 } = fieldConfig;
43851
- const candidateValue = resolvePath(candidateData, path40);
43852
- const expectedValue = resolvePath(expectedData, path40);
43885
+ const { path: path41, match, required: required2 = true, weight = 1 } = fieldConfig;
43886
+ const candidateValue = resolvePath(candidateData, path41);
43887
+ const expectedValue = resolvePath(expectedData, path41);
43853
43888
  if (expectedValue === void 0) {
43854
43889
  return {
43855
- path: path40,
43890
+ path: path41,
43856
43891
  score: 1,
43857
43892
  // No expected value means no comparison needed
43858
43893
  weight,
43859
43894
  hit: true,
43860
- message: `${path40}: no expected value`
43895
+ message: `${path41}: no expected value`
43861
43896
  };
43862
43897
  }
43863
43898
  if (candidateValue === void 0) {
43864
43899
  if (required2) {
43865
43900
  return {
43866
- path: path40,
43901
+ path: path41,
43867
43902
  score: 0,
43868
43903
  weight,
43869
43904
  hit: false,
43870
- message: `${path40} (required, missing)`
43905
+ message: `${path41} (required, missing)`
43871
43906
  };
43872
43907
  }
43873
43908
  return {
43874
- path: path40,
43909
+ path: path41,
43875
43910
  score: 1,
43876
43911
  // Don't penalize missing optional fields
43877
43912
  weight: 0,
43878
43913
  // Zero weight means it won't affect the score
43879
43914
  hit: true,
43880
- message: `${path40}: optional field missing`
43915
+ message: `${path41}: optional field missing`
43881
43916
  };
43882
43917
  }
43883
43918
  switch (match) {
43884
43919
  case "exact":
43885
- return this.compareExact(path40, candidateValue, expectedValue, weight);
43920
+ return this.compareExact(path41, candidateValue, expectedValue, weight);
43886
43921
  case "numeric_tolerance":
43887
43922
  return this.compareNumericTolerance(
43888
- path40,
43923
+ path41,
43889
43924
  candidateValue,
43890
43925
  expectedValue,
43891
43926
  fieldConfig,
43892
43927
  weight
43893
43928
  );
43894
43929
  case "date":
43895
- return this.compareDate(path40, candidateValue, expectedValue, fieldConfig, weight);
43930
+ return this.compareDate(path41, candidateValue, expectedValue, fieldConfig, weight);
43896
43931
  default:
43897
43932
  return {
43898
- path: path40,
43933
+ path: path41,
43899
43934
  score: 0,
43900
43935
  weight,
43901
43936
  hit: false,
43902
- message: `${path40}: unknown match type "${match}"`
43937
+ message: `${path41}: unknown match type "${match}"`
43903
43938
  };
43904
43939
  }
43905
43940
  }
43906
43941
  /**
43907
43942
  * Exact equality comparison.
43908
43943
  */
43909
- compareExact(path40, candidateValue, expectedValue, weight) {
43944
+ compareExact(path41, candidateValue, expectedValue, weight) {
43910
43945
  if (deepEqual(candidateValue, expectedValue)) {
43911
43946
  return {
43912
- path: path40,
43947
+ path: path41,
43913
43948
  score: 1,
43914
43949
  weight,
43915
43950
  hit: true,
43916
- message: path40
43951
+ message: path41
43917
43952
  };
43918
43953
  }
43919
43954
  if (typeof candidateValue !== typeof expectedValue) {
43920
43955
  return {
43921
- path: path40,
43956
+ path: path41,
43922
43957
  score: 0,
43923
43958
  weight,
43924
43959
  hit: false,
43925
- message: `${path40} (type mismatch: got ${typeof candidateValue}, expected ${typeof expectedValue})`
43960
+ message: `${path41} (type mismatch: got ${typeof candidateValue}, expected ${typeof expectedValue})`
43926
43961
  };
43927
43962
  }
43928
43963
  return {
43929
- path: path40,
43964
+ path: path41,
43930
43965
  score: 0,
43931
43966
  weight,
43932
43967
  hit: false,
43933
- message: `${path40} (value mismatch)`
43968
+ message: `${path41} (value mismatch)`
43934
43969
  };
43935
43970
  }
43936
43971
  /**
43937
43972
  * Numeric comparison with absolute or relative tolerance.
43938
43973
  */
43939
- compareNumericTolerance(path40, candidateValue, expectedValue, fieldConfig, weight) {
43974
+ compareNumericTolerance(path41, candidateValue, expectedValue, fieldConfig, weight) {
43940
43975
  const { tolerance = 0, relative = false } = fieldConfig;
43941
43976
  const candidateNum = toNumber2(candidateValue);
43942
43977
  const expectedNum = toNumber2(expectedValue);
43943
43978
  if (candidateNum === null || expectedNum === null) {
43944
43979
  return {
43945
- path: path40,
43980
+ path: path41,
43946
43981
  score: 0,
43947
43982
  weight,
43948
43983
  hit: false,
43949
- message: `${path40} (non-numeric value)`
43984
+ message: `${path41} (non-numeric value)`
43950
43985
  };
43951
43986
  }
43952
43987
  if (!Number.isFinite(candidateNum) || !Number.isFinite(expectedNum)) {
43953
43988
  return {
43954
- path: path40,
43989
+ path: path41,
43955
43990
  score: 0,
43956
43991
  weight,
43957
43992
  hit: false,
43958
- message: `${path40} (invalid numeric value)`
43993
+ message: `${path41} (invalid numeric value)`
43959
43994
  };
43960
43995
  }
43961
43996
  const diff = Math.abs(candidateNum - expectedNum);
@@ -43968,61 +44003,61 @@ var FieldAccuracyEvaluator = class {
43968
44003
  }
43969
44004
  if (withinTolerance) {
43970
44005
  return {
43971
- path: path40,
44006
+ path: path41,
43972
44007
  score: 1,
43973
44008
  weight,
43974
44009
  hit: true,
43975
- message: `${path40} (within tolerance: diff=${diff.toFixed(2)})`
44010
+ message: `${path41} (within tolerance: diff=${diff.toFixed(2)})`
43976
44011
  };
43977
44012
  }
43978
44013
  return {
43979
- path: path40,
44014
+ path: path41,
43980
44015
  score: 0,
43981
44016
  weight,
43982
44017
  hit: false,
43983
- message: `${path40} (outside tolerance: diff=${diff.toFixed(2)}, tolerance=${tolerance})`
44018
+ message: `${path41} (outside tolerance: diff=${diff.toFixed(2)}, tolerance=${tolerance})`
43984
44019
  };
43985
44020
  }
43986
44021
  /**
43987
44022
  * Date comparison with format normalization.
43988
44023
  */
43989
- compareDate(path40, candidateValue, expectedValue, fieldConfig, weight) {
44024
+ compareDate(path41, candidateValue, expectedValue, fieldConfig, weight) {
43990
44025
  const formats = fieldConfig.formats ?? DEFAULT_DATE_FORMATS;
43991
44026
  const candidateDate = parseDate(String(candidateValue), formats);
43992
44027
  const expectedDate = parseDate(String(expectedValue), formats);
43993
44028
  if (candidateDate === null) {
43994
44029
  return {
43995
- path: path40,
44030
+ path: path41,
43996
44031
  score: 0,
43997
44032
  weight,
43998
44033
  hit: false,
43999
- message: `${path40} (unparseable candidate date)`
44034
+ message: `${path41} (unparseable candidate date)`
44000
44035
  };
44001
44036
  }
44002
44037
  if (expectedDate === null) {
44003
44038
  return {
44004
- path: path40,
44039
+ path: path41,
44005
44040
  score: 0,
44006
44041
  weight,
44007
44042
  hit: false,
44008
- message: `${path40} (unparseable expected date)`
44043
+ message: `${path41} (unparseable expected date)`
44009
44044
  };
44010
44045
  }
44011
44046
  if (candidateDate.getFullYear() === expectedDate.getFullYear() && candidateDate.getMonth() === expectedDate.getMonth() && candidateDate.getDate() === expectedDate.getDate()) {
44012
44047
  return {
44013
- path: path40,
44048
+ path: path41,
44014
44049
  score: 1,
44015
44050
  weight,
44016
44051
  hit: true,
44017
- message: path40
44052
+ message: path41
44018
44053
  };
44019
44054
  }
44020
44055
  return {
44021
- path: path40,
44056
+ path: path41,
44022
44057
  score: 0,
44023
44058
  weight,
44024
44059
  hit: false,
44025
- message: `${path40} (date mismatch: got ${formatDateISO(candidateDate)}, expected ${formatDateISO(expectedDate)})`
44060
+ message: `${path41} (date mismatch: got ${formatDateISO(candidateDate)}, expected ${formatDateISO(expectedDate)})`
44026
44061
  };
44027
44062
  }
44028
44063
  /**
@@ -44063,11 +44098,11 @@ var FieldAccuracyEvaluator = class {
44063
44098
  };
44064
44099
  }
44065
44100
  };
44066
- function resolvePath(obj, path40) {
44067
- if (!path40 || !obj) {
44101
+ function resolvePath(obj, path41) {
44102
+ if (!path41 || !obj) {
44068
44103
  return void 0;
44069
44104
  }
44070
- const parts = path40.split(/\.|\[|\]/).filter((p) => p.length > 0);
44105
+ const parts = path41.split(/\.|\[|\]/).filter((p) => p.length > 0);
44071
44106
  let current = obj;
44072
44107
  for (const part of parts) {
44073
44108
  if (current === null || current === void 0) {
@@ -44540,8 +44575,8 @@ ${outputSchema2}`;
44540
44575
  }
44541
44576
  };
44542
44577
  function resolveSandboxed(basePath, relativePath) {
44543
- const resolved = path30.resolve(basePath, relativePath);
44544
- if (!resolved.startsWith(basePath + path30.sep) && resolved !== basePath) {
44578
+ const resolved = path31.resolve(basePath, relativePath);
44579
+ if (!resolved.startsWith(basePath + path31.sep) && resolved !== basePath) {
44545
44580
  throw new Error(`Path '${relativePath}' is outside the workspace`);
44546
44581
  }
44547
44582
  return resolved;
@@ -44624,11 +44659,11 @@ async function searchDirectory(dirPath, workspacePath, regex, matches) {
44624
44659
  for (const entry of entries) {
44625
44660
  if (matches.length >= MAX_SEARCH_MATCHES) return;
44626
44661
  if (SEARCH_SKIP_DIRS.has(entry.name)) continue;
44627
- const fullPath = path30.join(dirPath, entry.name);
44662
+ const fullPath = path31.join(dirPath, entry.name);
44628
44663
  if (entry.isDirectory()) {
44629
44664
  await searchDirectory(fullPath, workspacePath, regex, matches);
44630
44665
  } else if (entry.isFile()) {
44631
- const ext = path30.extname(entry.name).toLowerCase();
44666
+ const ext = path31.extname(entry.name).toLowerCase();
44632
44667
  if (BINARY_EXTENSIONS.has(ext)) continue;
44633
44668
  try {
44634
44669
  const stat8 = await fs2.stat(fullPath);
@@ -44640,7 +44675,7 @@ async function searchDirectory(dirPath, workspacePath, regex, matches) {
44640
44675
  regex.lastIndex = 0;
44641
44676
  if (regex.test(lines[i])) {
44642
44677
  matches.push({
44643
- file: path30.relative(workspacePath, fullPath),
44678
+ file: path31.relative(workspacePath, fullPath),
44644
44679
  line: i + 1,
44645
44680
  text: lines[i].substring(0, 200)
44646
44681
  });
@@ -44871,8 +44906,8 @@ var TokenUsageEvaluator = class {
44871
44906
  };
44872
44907
  }
44873
44908
  };
44874
- function getNestedValue(obj, path40) {
44875
- const parts = path40.split(".");
44909
+ function getNestedValue(obj, path41) {
44910
+ const parts = path41.split(".");
44876
44911
  let current = obj;
44877
44912
  for (const part of parts) {
44878
44913
  if (current === null || current === void 0 || typeof current !== "object") {
@@ -45655,7 +45690,7 @@ async function executePromptTemplate(script, context, config2, timeoutMs) {
45655
45690
  };
45656
45691
  const inputJson = JSON.stringify(toSnakeCaseDeep(payload), null, 2);
45657
45692
  const scriptPath = script[script.length - 1];
45658
- const cwd = path31.dirname(scriptPath);
45693
+ const cwd = path322.dirname(scriptPath);
45659
45694
  try {
45660
45695
  const stdout = await executeScript(script, inputJson, timeoutMs, cwd);
45661
45696
  const prompt = stdout.trim();
@@ -45947,11 +45982,11 @@ function createBuiltinRegistry() {
45947
45982
  async function discoverAssertions(registry2, baseDir) {
45948
45983
  const patterns = ["*.ts", "*.js", "*.mts", "*.mjs"];
45949
45984
  const candidateDirs = [];
45950
- let dir = path322.resolve(baseDir);
45951
- const root = path322.parse(dir).root;
45985
+ let dir = path33.resolve(baseDir);
45986
+ const root = path33.parse(dir).root;
45952
45987
  while (dir !== root) {
45953
- candidateDirs.push(path322.join(dir, ".agentv", "assertions"));
45954
- dir = path322.dirname(dir);
45988
+ candidateDirs.push(path33.join(dir, ".agentv", "assertions"));
45989
+ dir = path33.dirname(dir);
45955
45990
  }
45956
45991
  let files = [];
45957
45992
  for (const assertionsDir of candidateDirs) {
@@ -45967,7 +46002,7 @@ async function discoverAssertions(registry2, baseDir) {
45967
46002
  }
45968
46003
  const discoveredTypes = [];
45969
46004
  for (const filePath of files) {
45970
- const basename = path322.basename(filePath);
46005
+ const basename = path33.basename(filePath);
45971
46006
  const typeName = basename.replace(/\.(ts|js|mts|mjs)$/, "");
45972
46007
  if (registry2.has(typeName)) {
45973
46008
  continue;
@@ -46153,10 +46188,10 @@ async function stageNestedRepoChanges(workspacePath) {
46153
46188
  }
46154
46189
  for (const entry of entries) {
46155
46190
  if (entry === ".git" || entry === "node_modules") continue;
46156
- const childPath = path33.join(workspacePath, entry);
46191
+ const childPath = path34.join(workspacePath, entry);
46157
46192
  try {
46158
46193
  if (!statSync(childPath).isDirectory()) continue;
46159
- if (!statSync(path33.join(childPath, ".git")).isDirectory()) continue;
46194
+ if (!statSync(path34.join(childPath, ".git")).isDirectory()) continue;
46160
46195
  } catch {
46161
46196
  continue;
46162
46197
  }
@@ -46164,7 +46199,6 @@ async function stageNestedRepoChanges(workspacePath) {
46164
46199
  await execAsync4("git add -A", childOpts);
46165
46200
  }
46166
46201
  }
46167
- var DEFAULT_WORKSPACE_ROOT = path34.join(os3.homedir(), ".agentv", "workspaces");
46168
46202
  var TemplateNotFoundError = class extends Error {
46169
46203
  constructor(templatePath) {
46170
46204
  super(`Workspace template not found: ${templatePath}`);
@@ -46193,15 +46227,15 @@ async function isDirectory(filePath) {
46193
46227
  }
46194
46228
  }
46195
46229
  function getWorkspacePath(evalRunId, caseId, workspaceRoot) {
46196
- const root = workspaceRoot ?? DEFAULT_WORKSPACE_ROOT;
46197
- return path34.join(root, evalRunId, caseId);
46230
+ const root = workspaceRoot ?? getWorkspacesRoot();
46231
+ return path35.join(root, evalRunId, caseId);
46198
46232
  }
46199
46233
  async function copyDirectoryRecursive(src, dest) {
46200
46234
  await mkdir10(dest, { recursive: true });
46201
46235
  const entries = await readdir3(src, { withFileTypes: true });
46202
46236
  for (const entry of entries) {
46203
- const srcPath = path34.join(src, entry.name);
46204
- const destPath = path34.join(dest, entry.name);
46237
+ const srcPath = path35.join(src, entry.name);
46238
+ const destPath = path35.join(dest, entry.name);
46205
46239
  if (entry.name === ".git") {
46206
46240
  continue;
46207
46241
  }
@@ -46213,7 +46247,7 @@ async function copyDirectoryRecursive(src, dest) {
46213
46247
  }
46214
46248
  }
46215
46249
  async function createTempWorkspace(templatePath, evalRunId, caseId, workspaceRoot) {
46216
- const resolvedTemplatePath = path34.resolve(templatePath);
46250
+ const resolvedTemplatePath = path35.resolve(templatePath);
46217
46251
  if (!await fileExists(resolvedTemplatePath)) {
46218
46252
  throw new TemplateNotFoundError(resolvedTemplatePath);
46219
46253
  }
@@ -46261,14 +46295,13 @@ async function cleanupWorkspace(workspacePath) {
46261
46295
  }
46262
46296
  }
46263
46297
  async function cleanupEvalWorkspaces(evalRunId, workspaceRoot) {
46264
- const root = workspaceRoot ?? DEFAULT_WORKSPACE_ROOT;
46265
- const evalDir = path34.join(root, evalRunId);
46298
+ const root = workspaceRoot ?? getWorkspacesRoot();
46299
+ const evalDir = path35.join(root, evalRunId);
46266
46300
  if (await fileExists(evalDir)) {
46267
46301
  await rm4(evalDir, { recursive: true, force: true });
46268
46302
  }
46269
46303
  }
46270
46304
  var execFileAsync = promisify5(execFile);
46271
- var DEFAULT_CACHE_DIR = path35.join(os4.homedir(), ".agentv", "git-cache");
46272
46305
  var DEFAULT_TIMEOUT_MS2 = 3e5;
46273
46306
  var LOCK_TIMEOUT_MS = 6e4;
46274
46307
  function gitEnv() {
@@ -46326,8 +46359,35 @@ async function releaseLock(lockPath) {
46326
46359
  }
46327
46360
  var RepoManager = class {
46328
46361
  cacheDir;
46329
- constructor(cacheDir) {
46330
- this.cacheDir = cacheDir ?? DEFAULT_CACHE_DIR;
46362
+ verbose;
46363
+ constructor(cacheDir, verbose = false) {
46364
+ this.cacheDir = cacheDir ?? getGitCacheRoot();
46365
+ this.verbose = verbose;
46366
+ }
46367
+ async runGit(args, opts) {
46368
+ const startedAt = Date.now();
46369
+ if (this.verbose) {
46370
+ console.log(
46371
+ `[repo] git start cwd=${opts?.cwd ?? process.cwd()} args=${args.join(" ")}`
46372
+ );
46373
+ }
46374
+ try {
46375
+ const output = await git(args, opts);
46376
+ if (this.verbose) {
46377
+ console.log(
46378
+ `[repo] git ok durationMs=${Date.now() - startedAt} args=${args.join(" ")}`
46379
+ );
46380
+ }
46381
+ return output;
46382
+ } catch (error40) {
46383
+ if (this.verbose) {
46384
+ const message = error40 instanceof Error ? error40.message : String(error40);
46385
+ console.log(
46386
+ `[repo] git fail durationMs=${Date.now() - startedAt} args=${args.join(" ")} error=${message}`
46387
+ );
46388
+ }
46389
+ throw error40;
46390
+ }
46331
46391
  }
46332
46392
  /**
46333
46393
  * Ensure a bare mirror cache exists for the given source.
@@ -46336,11 +46396,19 @@ var RepoManager = class {
46336
46396
  */
46337
46397
  async ensureCache(source, depth, resolve2) {
46338
46398
  const key = cacheKey(source);
46339
- const cachePath = path35.join(this.cacheDir, key);
46399
+ const cachePath = path36.join(this.cacheDir, key);
46340
46400
  const lockPath = `${cachePath}.lock`;
46341
- const cacheExists = existsSync2(path35.join(cachePath, "HEAD"));
46401
+ const cacheExists = existsSync2(path36.join(cachePath, "HEAD"));
46402
+ if (this.verbose) {
46403
+ console.log(
46404
+ `[repo] ensureCache source=${getSourceUrl(source)} resolve=${resolve2 ?? "remote"} cache=${cachePath}`
46405
+ );
46406
+ }
46342
46407
  if (resolve2 === "local") {
46343
46408
  if (cacheExists) {
46409
+ if (this.verbose) {
46410
+ console.log(`[repo] using existing local cache ${cachePath}`);
46411
+ }
46344
46412
  return cachePath;
46345
46413
  }
46346
46414
  const url2 = getSourceUrl(source);
@@ -46349,15 +46417,27 @@ var RepoManager = class {
46349
46417
  );
46350
46418
  }
46351
46419
  await mkdir11(this.cacheDir, { recursive: true });
46420
+ const lockStartedAt = Date.now();
46352
46421
  await acquireLock(lockPath);
46422
+ if (this.verbose) {
46423
+ console.log(
46424
+ `[repo] lock acquired path=${lockPath} waitedMs=${Date.now() - lockStartedAt}`
46425
+ );
46426
+ }
46353
46427
  try {
46354
46428
  if (cacheExists) {
46429
+ if (this.verbose) {
46430
+ console.log(`[repo] refreshing existing cache ${cachePath}`);
46431
+ }
46355
46432
  const fetchArgs = ["fetch", "--prune"];
46356
46433
  if (depth) {
46357
46434
  fetchArgs.push("--depth", String(depth));
46358
46435
  }
46359
- await git(fetchArgs, { cwd: cachePath });
46436
+ await this.runGit(fetchArgs, { cwd: cachePath });
46360
46437
  } else {
46438
+ if (this.verbose) {
46439
+ console.log(`[repo] creating new cache ${cachePath}`);
46440
+ }
46361
46441
  const cloneArgs = ["clone", "--mirror", "--bare"];
46362
46442
  if (depth) {
46363
46443
  cloneArgs.push("--depth", String(depth));
@@ -46365,10 +46445,13 @@ var RepoManager = class {
46365
46445
  const sourceUrl = getSourceUrl(source);
46366
46446
  const cloneUrl = depth && source.type === "local" ? `file://${sourceUrl}` : sourceUrl;
46367
46447
  cloneArgs.push(cloneUrl, cachePath);
46368
- await git(cloneArgs);
46448
+ await this.runGit(cloneArgs);
46369
46449
  }
46370
46450
  } finally {
46371
46451
  await releaseLock(lockPath);
46452
+ if (this.verbose) {
46453
+ console.log(`[repo] lock released path=${lockPath}`);
46454
+ }
46372
46455
  }
46373
46456
  return cachePath;
46374
46457
  }
@@ -46377,7 +46460,13 @@ var RepoManager = class {
46377
46460
  * Handles checkout, ref resolution, ancestor walking, shallow clone, sparse checkout.
46378
46461
  */
46379
46462
  async materialize(repo, workspacePath) {
46380
- const targetDir = path35.join(workspacePath, repo.path);
46463
+ const targetDir = path36.join(workspacePath, repo.path);
46464
+ const startedAt = Date.now();
46465
+ if (this.verbose) {
46466
+ console.log(
46467
+ `[repo] materialize start path=${repo.path} source=${getSourceUrl(repo.source)} workspace=${workspacePath}`
46468
+ );
46469
+ }
46381
46470
  const cachePath = await this.ensureCache(
46382
46471
  repo.source,
46383
46472
  repo.clone?.depth,
@@ -46393,10 +46482,10 @@ var RepoManager = class {
46393
46482
  cloneArgs.push("--no-checkout");
46394
46483
  const cloneUrl = repo.clone?.depth || repo.clone?.filter ? `file://${cachePath}` : cachePath;
46395
46484
  cloneArgs.push(cloneUrl, targetDir);
46396
- await git(cloneArgs);
46485
+ await this.runGit(cloneArgs);
46397
46486
  if (repo.clone?.sparse?.length) {
46398
- await git(["sparse-checkout", "init", "--cone"], { cwd: targetDir });
46399
- await git(["sparse-checkout", "set", ...repo.clone.sparse], { cwd: targetDir });
46487
+ await this.runGit(["sparse-checkout", "init", "--cone"], { cwd: targetDir });
46488
+ await this.runGit(["sparse-checkout", "set", ...repo.clone.sparse], { cwd: targetDir });
46400
46489
  }
46401
46490
  const ref = repo.checkout?.ref ?? "HEAD";
46402
46491
  const resolve2 = repo.checkout?.resolve ?? "remote";
@@ -46404,7 +46493,7 @@ var RepoManager = class {
46404
46493
  if (resolve2 === "remote" && repo.source.type === "git") {
46405
46494
  const url2 = getSourceUrl(repo.source);
46406
46495
  try {
46407
- const lsOutput = await git(["ls-remote", url2, ref]);
46496
+ const lsOutput = await this.runGit(["ls-remote", url2, ref]);
46408
46497
  const match = lsOutput.split(" ")[0];
46409
46498
  if (!match) {
46410
46499
  throw new Error(`Ref '${ref}' not found on remote ${url2}`);
@@ -46417,17 +46506,26 @@ var RepoManager = class {
46417
46506
  } else {
46418
46507
  resolvedSha = ref;
46419
46508
  }
46420
- await git(["checkout", resolvedSha], { cwd: targetDir });
46509
+ if (this.verbose) {
46510
+ console.log(
46511
+ `[repo] checkout path=${repo.path} ref=${ref} resolved=${resolvedSha} resolve=${resolve2}`
46512
+ );
46513
+ }
46514
+ await this.runGit(["checkout", resolvedSha], { cwd: targetDir });
46421
46515
  const ancestor = repo.checkout?.ancestor ?? 0;
46422
46516
  if (ancestor > 0) {
46423
46517
  try {
46424
- const ancestorSha = await git(["rev-parse", `HEAD~${ancestor}`], { cwd: targetDir });
46425
- await git(["checkout", ancestorSha], { cwd: targetDir });
46518
+ const ancestorSha = await this.runGit(["rev-parse", `HEAD~${ancestor}`], {
46519
+ cwd: targetDir
46520
+ });
46521
+ await this.runGit(["checkout", ancestorSha], { cwd: targetDir });
46426
46522
  } catch {
46427
46523
  if (repo.clone?.depth) {
46428
- await git(["fetch", "--deepen", String(ancestor)], { cwd: targetDir });
46429
- const ancestorSha = await git(["rev-parse", `HEAD~${ancestor}`], { cwd: targetDir });
46430
- await git(["checkout", ancestorSha], { cwd: targetDir });
46524
+ await this.runGit(["fetch", "--deepen", String(ancestor)], { cwd: targetDir });
46525
+ const ancestorSha = await this.runGit(["rev-parse", `HEAD~${ancestor}`], {
46526
+ cwd: targetDir
46527
+ });
46528
+ await this.runGit(["checkout", ancestorSha], { cwd: targetDir });
46431
46529
  } else {
46432
46530
  throw new Error(
46433
46531
  `Cannot resolve ancestor ${ancestor} of ref '${ref}'. If using shallow clone, increase clone.depth to at least ${ancestor + 1}.`
@@ -46435,27 +46533,38 @@ var RepoManager = class {
46435
46533
  }
46436
46534
  }
46437
46535
  }
46536
+ if (this.verbose) {
46537
+ console.log(
46538
+ `[repo] materialize done path=${repo.path} target=${targetDir} durationMs=${Date.now() - startedAt}`
46539
+ );
46540
+ }
46438
46541
  }
46439
46542
  /** Materialize all repos into the workspace. */
46440
46543
  async materializeAll(repos, workspacePath) {
46544
+ if (this.verbose) {
46545
+ console.log(`[repo] materializeAll count=${repos.length} workspace=${workspacePath}`);
46546
+ }
46441
46547
  for (const repo of repos) {
46442
46548
  await this.materialize(repo, workspacePath);
46443
46549
  }
46550
+ if (this.verbose) {
46551
+ console.log("[repo] materializeAll complete");
46552
+ }
46444
46553
  }
46445
46554
  /** Reset repos in workspace to their checkout state. */
46446
46555
  async reset(repos, workspacePath, strategy) {
46447
46556
  if (strategy === "recreate") {
46448
46557
  for (const repo of repos) {
46449
- const targetDir = path35.join(workspacePath, repo.path);
46558
+ const targetDir = path36.join(workspacePath, repo.path);
46450
46559
  await rm5(targetDir, { recursive: true, force: true });
46451
46560
  }
46452
46561
  await this.materializeAll(repos, workspacePath);
46453
46562
  return;
46454
46563
  }
46455
46564
  for (const repo of repos) {
46456
- const targetDir = path35.join(workspacePath, repo.path);
46457
- await git(["reset", "--hard", "HEAD"], { cwd: targetDir });
46458
- await git(["clean", "-fd"], { cwd: targetDir });
46565
+ const targetDir = path36.join(workspacePath, repo.path);
46566
+ await this.runGit(["reset", "--hard", "HEAD"], { cwd: targetDir });
46567
+ await this.runGit(["clean", "-fd"], { cwd: targetDir });
46459
46568
  }
46460
46569
  }
46461
46570
  /**
@@ -46465,12 +46574,12 @@ var RepoManager = class {
46465
46574
  async seedCache(localPath, remoteUrl, opts) {
46466
46575
  const source = { type: "git", url: remoteUrl };
46467
46576
  const key = cacheKey(source);
46468
- const cachePath = path35.join(this.cacheDir, key);
46577
+ const cachePath = path36.join(this.cacheDir, key);
46469
46578
  const lockPath = `${cachePath}.lock`;
46470
46579
  await mkdir11(this.cacheDir, { recursive: true });
46471
46580
  await acquireLock(lockPath);
46472
46581
  try {
46473
- if (existsSync2(path35.join(cachePath, "HEAD"))) {
46582
+ if (existsSync2(path36.join(cachePath, "HEAD"))) {
46474
46583
  if (!opts?.force) {
46475
46584
  throw new Error(
46476
46585
  `Cache already exists for ${remoteUrl} at ${cachePath}. Use force to overwrite.`
@@ -46494,11 +46603,11 @@ async function resolveWorkspaceTemplate(templatePath) {
46494
46603
  if (!templatePath) {
46495
46604
  return void 0;
46496
46605
  }
46497
- const resolved = path36.resolve(templatePath);
46606
+ const resolved = path37.resolve(templatePath);
46498
46607
  const stats = await stat6(resolved);
46499
46608
  if (stats.isFile()) {
46500
46609
  return {
46501
- dir: path36.dirname(resolved),
46610
+ dir: path37.dirname(resolved),
46502
46611
  workspaceFile: resolved
46503
46612
  };
46504
46613
  }
@@ -46510,14 +46619,14 @@ async function resolveWorkspaceTemplate(templatePath) {
46510
46619
  if (workspaceFiles.length === 1) {
46511
46620
  return {
46512
46621
  dir: resolved,
46513
- workspaceFile: path36.join(resolved, workspaceFiles[0])
46622
+ workspaceFile: path37.join(resolved, workspaceFiles[0])
46514
46623
  };
46515
46624
  }
46516
46625
  if (workspaceFiles.length > 1) {
46517
46626
  const conventionFile = workspaceFiles.find((f) => f === "template.code-workspace");
46518
46627
  return {
46519
46628
  dir: resolved,
46520
- workspaceFile: conventionFile ? path36.join(resolved, conventionFile) : void 0
46629
+ workspaceFile: conventionFile ? path37.join(resolved, conventionFile) : void 0
46521
46630
  };
46522
46631
  }
46523
46632
  return { dir: resolved };
@@ -46669,7 +46778,7 @@ async function runEvaluation(options) {
46669
46778
  ];
46670
46779
  const evaluatorRegistry = buildEvaluatorRegistry(evaluators, resolveJudgeProvider);
46671
46780
  const typeRegistry = createBuiltinRegistry();
46672
- const discoveryBaseDir = evalFilePath ? path37.dirname(path37.resolve(evalFilePath)) : process.cwd();
46781
+ const discoveryBaseDir = evalFilePath ? path38.dirname(path38.resolve(evalFilePath)) : process.cwd();
46673
46782
  const evalDir = discoveryBaseDir;
46674
46783
  await discoverAssertions(typeRegistry, discoveryBaseDir);
46675
46784
  const providerRegistry = createBuiltinProviderRegistry();
@@ -46725,10 +46834,18 @@ async function runEvaluation(options) {
46725
46834
  const resolvedTemplate = await resolveWorkspaceTemplate(rawTemplate);
46726
46835
  const workspaceTemplate = resolvedTemplate?.dir;
46727
46836
  let suiteWorkspaceFile = resolvedTemplate?.workspaceFile;
46837
+ const setupLog = (message) => {
46838
+ if (verbose) {
46839
+ console.log(`[setup] ${message}`);
46840
+ }
46841
+ };
46728
46842
  const isPerTestIsolation = suiteWorkspace?.isolation === "per_test";
46729
46843
  const hasSharedWorkspace = !!(workspaceTemplate || suiteWorkspace?.before_all || suiteWorkspace?.repos?.length && !isPerTestIsolation);
46730
46844
  const requestedWorkers = options.maxConcurrency ?? target.workers ?? 1;
46731
46845
  const workers = hasSharedWorkspace ? 1 : requestedWorkers;
46846
+ setupLog(
46847
+ `sharedWorkspace=${hasSharedWorkspace} perTestIsolation=${isPerTestIsolation} requestedWorkers=${requestedWorkers} effectiveWorkers=${workers}`
46848
+ );
46732
46849
  if (hasSharedWorkspace && requestedWorkers > 1) {
46733
46850
  console.warn(
46734
46851
  `Warning: Shared workspace requires sequential execution. Overriding workers from ${requestedWorkers} to 1.`
@@ -46739,14 +46856,16 @@ async function runEvaluation(options) {
46739
46856
  let sharedBaselineCommit;
46740
46857
  let beforeAllOutput;
46741
46858
  if (workspaceTemplate) {
46859
+ setupLog(`creating shared workspace from template: ${workspaceTemplate}`);
46742
46860
  try {
46743
46861
  sharedWorkspacePath = await createTempWorkspace(workspaceTemplate, evalRunId, "shared");
46862
+ setupLog(`shared workspace created at: ${sharedWorkspacePath}`);
46744
46863
  } catch (error40) {
46745
46864
  const message = error40 instanceof Error ? error40.message : String(error40);
46746
46865
  throw new Error(`Failed to create shared workspace: ${message}`);
46747
46866
  }
46748
46867
  if (suiteWorkspaceFile && sharedWorkspacePath) {
46749
- const copiedWorkspaceFile = path37.join(sharedWorkspacePath, path37.basename(suiteWorkspaceFile));
46868
+ const copiedWorkspaceFile = path38.join(sharedWorkspacePath, path38.basename(suiteWorkspaceFile));
46750
46869
  try {
46751
46870
  await stat7(copiedWorkspaceFile);
46752
46871
  suiteWorkspaceFile = copiedWorkspaceFile;
@@ -46756,11 +46875,14 @@ async function runEvaluation(options) {
46756
46875
  } else if (suiteWorkspace?.before_all || suiteWorkspace?.repos?.length && !isPerTestIsolation) {
46757
46876
  sharedWorkspacePath = getWorkspacePath(evalRunId, "shared");
46758
46877
  await mkdir12(sharedWorkspacePath, { recursive: true });
46878
+ setupLog(`created empty shared workspace at: ${sharedWorkspacePath}`);
46759
46879
  }
46760
- const repoManager = suiteWorkspace?.repos?.length ? new RepoManager() : void 0;
46880
+ const repoManager = suiteWorkspace?.repos?.length ? new RepoManager(void 0, verbose) : void 0;
46761
46881
  if (repoManager && sharedWorkspacePath && suiteWorkspace?.repos && !isPerTestIsolation) {
46882
+ setupLog(`materializing ${suiteWorkspace.repos.length} shared repo(s) into ${sharedWorkspacePath}`);
46762
46883
  try {
46763
46884
  await repoManager.materializeAll(suiteWorkspace.repos, sharedWorkspacePath);
46885
+ setupLog("shared repo materialization complete");
46764
46886
  } catch (error40) {
46765
46887
  const message = error40 instanceof Error ? error40.message : String(error40);
46766
46888
  if (sharedWorkspacePath) {
@@ -46771,6 +46893,10 @@ async function runEvaluation(options) {
46771
46893
  }
46772
46894
  }
46773
46895
  if (sharedWorkspacePath && suiteWorkspace?.before_all) {
46896
+ const beforeAllCommand = (suiteWorkspace.before_all.command ?? suiteWorkspace.before_all.script ?? []).join(" ");
46897
+ setupLog(
46898
+ `running shared before_all in cwd=${suiteWorkspace.before_all.cwd ?? evalDir} command=${beforeAllCommand}`
46899
+ );
46774
46900
  const scriptContext = {
46775
46901
  workspacePath: sharedWorkspacePath,
46776
46902
  testId: "__before_all__",
@@ -46779,6 +46905,7 @@ async function runEvaluation(options) {
46779
46905
  };
46780
46906
  try {
46781
46907
  beforeAllOutput = await executeWorkspaceScript(suiteWorkspace.before_all, scriptContext);
46908
+ setupLog("shared before_all completed");
46782
46909
  } catch (error40) {
46783
46910
  const message = error40 instanceof Error ? error40.message : String(error40);
46784
46911
  if (sharedWorkspacePath) {
@@ -46791,7 +46918,9 @@ async function runEvaluation(options) {
46791
46918
  if (sharedWorkspacePath) {
46792
46919
  try {
46793
46920
  sharedBaselineCommit = await initializeBaseline(sharedWorkspacePath);
46921
+ setupLog(`shared baseline initialized: ${sharedBaselineCommit}`);
46794
46922
  } catch {
46923
+ setupLog("shared baseline initialization skipped (non-fatal)");
46795
46924
  }
46796
46925
  }
46797
46926
  let nextWorkerId = 1;
@@ -47195,6 +47324,7 @@ async function runEvalCase(options) {
47195
47324
  repoManager,
47196
47325
  evalDir
47197
47326
  } = options;
47327
+ const setupDebug = process.env.AGENTV_SETUP_DEBUG === "1";
47198
47328
  const formattingMode = usesFileReferencePrompt(provider) ? "agent" : "lm";
47199
47329
  const promptInputs = await buildPromptInputs(evalCase, formattingMode);
47200
47330
  const typeRegistry = providedTypeRegistry ?? createBuiltinRegistry();
@@ -47232,7 +47362,7 @@ async function runEvalCase(options) {
47232
47362
  );
47233
47363
  }
47234
47364
  if (caseWorkspaceFile && workspacePath) {
47235
- const copiedFile = path37.join(workspacePath, path37.basename(caseWorkspaceFile));
47365
+ const copiedFile = path38.join(workspacePath, path38.basename(caseWorkspaceFile));
47236
47366
  try {
47237
47367
  await stat7(copiedFile);
47238
47368
  caseWorkspaceFile = copiedFile;
@@ -47245,9 +47375,17 @@ async function runEvalCase(options) {
47245
47375
  await mkdir12(workspacePath, { recursive: true });
47246
47376
  }
47247
47377
  if (evalCase.workspace?.repos?.length && workspacePath) {
47248
- const perCaseRepoManager = new RepoManager();
47378
+ const perCaseRepoManager = new RepoManager(void 0, setupDebug);
47249
47379
  try {
47380
+ if (setupDebug) {
47381
+ console.log(
47382
+ `[setup] test=${evalCase.id} materializing ${evalCase.workspace.repos.length} per-test repo(s) into ${workspacePath}`
47383
+ );
47384
+ }
47250
47385
  await perCaseRepoManager.materializeAll(evalCase.workspace.repos, workspacePath);
47386
+ if (setupDebug) {
47387
+ console.log(`[setup] test=${evalCase.id} per-test repo materialization complete`);
47388
+ }
47251
47389
  } catch (error40) {
47252
47390
  const message = error40 instanceof Error ? error40.message : String(error40);
47253
47391
  return buildErrorResult(
@@ -47263,6 +47401,12 @@ async function runEvalCase(options) {
47263
47401
  }
47264
47402
  }
47265
47403
  if (workspacePath && evalCase.workspace?.before_all) {
47404
+ const beforeAllCommand = (evalCase.workspace.before_all.command ?? evalCase.workspace.before_all.script ?? []).join(" ");
47405
+ if (setupDebug) {
47406
+ console.log(
47407
+ `[setup] test=${evalCase.id} running before_all in cwd=${evalCase.workspace.before_all.cwd ?? evalDir} command=${beforeAllCommand}`
47408
+ );
47409
+ }
47266
47410
  const scriptContext = {
47267
47411
  workspacePath,
47268
47412
  testId: evalCase.id,
@@ -47276,6 +47420,9 @@ async function runEvalCase(options) {
47276
47420
  evalCase.workspace.before_all,
47277
47421
  scriptContext
47278
47422
  );
47423
+ if (setupDebug) {
47424
+ console.log(`[setup] test=${evalCase.id} before_all completed`);
47425
+ }
47279
47426
  } catch (error40) {
47280
47427
  const message = error40 instanceof Error ? error40.message : String(error40);
47281
47428
  if (forceCleanup && workspacePath) {
@@ -47825,7 +47972,7 @@ async function runEvaluatorList(options) {
47825
47972
  fileChanges,
47826
47973
  workspacePath
47827
47974
  };
47828
- const evalFileDir = evalCase.guideline_paths[0] ? path37.dirname(evalCase.guideline_paths[0]) : process.cwd();
47975
+ const evalFileDir = evalCase.guideline_paths[0] ? path38.dirname(evalCase.guideline_paths[0]) : process.cwd();
47829
47976
  const dispatchContext = {
47830
47977
  judgeProvider,
47831
47978
  targetResolver,
@@ -48146,13 +48293,13 @@ async function evaluate(config2) {
48146
48293
  let evalCases;
48147
48294
  let testFilePath;
48148
48295
  if (config2.specFile) {
48149
- testFilePath = path38.resolve(config2.specFile);
48296
+ testFilePath = path39.resolve(config2.specFile);
48150
48297
  evalCases = await loadTests(testFilePath, repoRoot, {
48151
48298
  verbose: config2.verbose,
48152
48299
  filter: config2.filter
48153
48300
  });
48154
48301
  } else {
48155
- testFilePath = path38.join(process.cwd(), "__programmatic__.yaml");
48302
+ testFilePath = path39.join(process.cwd(), "__programmatic__.yaml");
48156
48303
  evalCases = (config2.tests ?? []).map((test) => {
48157
48304
  const input = typeof test.input === "string" ? [{ role: "user", content: test.input }] : test.input;
48158
48305
  const question = typeof test.input === "string" ? test.input : test.input.find((m) => m.role === "user")?.content ?? "";
@@ -48238,10 +48385,10 @@ function computeSummary(results, durationMs) {
48238
48385
  var TARGET_FILE_CANDIDATES = [".agentv/targets.yaml", ".agentv/targets.yml"];
48239
48386
  async function discoverDefaultTarget(repoRoot) {
48240
48387
  const cwd = process.cwd();
48241
- const chain = buildDirectoryChain(path38.join(cwd, "_placeholder"), repoRoot);
48388
+ const chain = buildDirectoryChain(path39.join(cwd, "_placeholder"), repoRoot);
48242
48389
  for (const dir of chain) {
48243
48390
  for (const candidate of TARGET_FILE_CANDIDATES) {
48244
- const targetsPath = path38.join(dir, candidate);
48391
+ const targetsPath = path39.join(dir, candidate);
48245
48392
  if (!existsSync3(targetsPath)) continue;
48246
48393
  try {
48247
48394
  const definitions = await readTargetDefinitions(targetsPath);
@@ -48256,10 +48403,10 @@ async function discoverDefaultTarget(repoRoot) {
48256
48403
  async function loadEnvHierarchy(repoRoot) {
48257
48404
  const { readFileSync: readFileSync2 } = await import("node:fs");
48258
48405
  const cwd = process.cwd();
48259
- const chain = buildDirectoryChain(path38.join(cwd, "_placeholder"), repoRoot);
48406
+ const chain = buildDirectoryChain(path39.join(cwd, "_placeholder"), repoRoot);
48260
48407
  const envFiles = [];
48261
48408
  for (const dir of chain) {
48262
- const envPath = path38.join(dir, ".env");
48409
+ const envPath = path39.join(dir, ".env");
48263
48410
  if (existsSync3(envPath)) envFiles.push(envPath);
48264
48411
  }
48265
48412
  for (let i = envFiles.length - 1; i >= 0; i--) {
@@ -48448,13 +48595,13 @@ var ResponseCache = class {
48448
48595
  }
48449
48596
  async set(key, value) {
48450
48597
  const filePath = this.keyToPath(key);
48451
- const dir = path39.dirname(filePath);
48598
+ const dir = path40.dirname(filePath);
48452
48599
  await mkdir13(dir, { recursive: true });
48453
48600
  await writeFile8(filePath, JSON.stringify(value, null, 2), "utf8");
48454
48601
  }
48455
48602
  keyToPath(key) {
48456
48603
  const prefix = key.slice(0, 2);
48457
- return path39.join(this.cachePath, prefix, `${key}.json`);
48604
+ return path40.join(this.cachePath, prefix, `${key}.json`);
48458
48605
  }
48459
48606
  };
48460
48607
  function shouldEnableCache(params) {
@@ -48958,6 +49105,11 @@ export {
48958
49105
  consumePiLogEntries,
48959
49106
  subscribeToPiLogEntries,
48960
49107
  ProviderRegistry,
49108
+ getAgentvHome,
49109
+ getWorkspacesRoot,
49110
+ getGitCacheRoot,
49111
+ getSubagentsRoot,
49112
+ getTraceStateRoot,
48961
49113
  ensureVSCodeSubagents,
48962
49114
  readTargetDefinitions,
48963
49115
  listTargetNames,
@@ -49037,4 +49189,4 @@ export {
49037
49189
  OtelStreamingObserver,
49038
49190
  createAgentKernel
49039
49191
  };
49040
- //# sourceMappingURL=chunk-OQN2GDEU.js.map
49192
+ //# sourceMappingURL=chunk-TK4PB62M.js.map