agentv 2.18.1 → 2.18.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.
@@ -148,7 +148,7 @@ var require_dist = __commonJS({
148
148
  }
149
149
  });
150
150
 
151
- // ../../packages/core/dist/chunk-I4VQY3XJ.js
151
+ // ../../packages/core/dist/chunk-V42NUK73.js
152
152
  import { constants } from "node:fs";
153
153
  import { access, readFile } from "node:fs/promises";
154
154
  import path from "node:path";
@@ -4195,7 +4195,7 @@ var coerce = {
4195
4195
  };
4196
4196
  var NEVER = INVALID;
4197
4197
 
4198
- // ../../packages/core/dist/chunk-I4VQY3XJ.js
4198
+ // ../../packages/core/dist/chunk-V42NUK73.js
4199
4199
  var TEST_MESSAGE_ROLE_VALUES = ["system", "user", "assistant", "tool"];
4200
4200
  var TEST_MESSAGE_ROLES = TEST_MESSAGE_ROLE_VALUES;
4201
4201
  var TEST_MESSAGE_ROLE_SET = new Set(TEST_MESSAGE_ROLE_VALUES);
@@ -33966,7 +33966,7 @@ import { createServer } from "node:http";
33966
33966
  import fs2 from "node:fs/promises";
33967
33967
  import path31 from "node:path";
33968
33968
  import { createHash as createHash2, randomUUID as randomUUID7 } from "node:crypto";
33969
- import { mkdir as mkdir12, stat as stat7 } from "node:fs/promises";
33969
+ import { mkdir as mkdir12, readdir as readdir6, stat as stat7 } from "node:fs/promises";
33970
33970
  import path39 from "node:path";
33971
33971
  import micromatch4 from "micromatch";
33972
33972
  import { readFileSync } from "node:fs";
@@ -37053,11 +37053,13 @@ function parseWorkspaceHookConfig(raw, evalFileDir) {
37053
37053
  function parseWorkspaceHooksConfig(raw, evalFileDir) {
37054
37054
  if (!isJsonObject(raw)) return void 0;
37055
37055
  const obj = raw;
37056
+ const enabled = typeof obj.enabled === "boolean" ? obj.enabled : void 0;
37056
37057
  const beforeAll = parseWorkspaceHookConfig(obj.before_all, evalFileDir);
37057
37058
  const beforeEach = parseWorkspaceHookConfig(obj.before_each, evalFileDir);
37058
37059
  const afterEach = parseWorkspaceHookConfig(obj.after_each, evalFileDir);
37059
37060
  const afterAll = parseWorkspaceHookConfig(obj.after_all, evalFileDir);
37060
37061
  const hooks = {
37062
+ ...enabled !== void 0 && { enabled },
37061
37063
  ...beforeAll !== void 0 && { before_all: beforeAll },
37062
37064
  ...beforeEach !== void 0 && { before_each: beforeEach },
37063
37065
  ...afterEach !== void 0 && { after_each: afterEach },
@@ -37130,13 +37132,15 @@ function mergeWorkspaceConfigs(suiteLevel, caseLevel) {
37130
37132
  ...caseHook ?? {}
37131
37133
  };
37132
37134
  };
37135
+ const mergedEnabled = caseLevel.hooks?.enabled ?? suiteLevel.hooks?.enabled;
37133
37136
  const mergedHooks = {
37137
+ ...mergedEnabled !== void 0 && { enabled: mergedEnabled },
37134
37138
  before_all: mergeHook(suiteLevel.hooks?.before_all, caseLevel.hooks?.before_all),
37135
37139
  before_each: mergeHook(suiteLevel.hooks?.before_each, caseLevel.hooks?.before_each),
37136
37140
  after_each: mergeHook(suiteLevel.hooks?.after_each, caseLevel.hooks?.after_each),
37137
37141
  after_all: mergeHook(suiteLevel.hooks?.after_all, caseLevel.hooks?.after_all)
37138
37142
  };
37139
- const hasHooks = Object.values(mergedHooks).some((hook) => hook !== void 0);
37143
+ const hasHooks = mergedEnabled !== void 0 || Object.values(mergedHooks).some((hook) => hook !== void 0 && typeof hook === "object");
37140
37144
  return {
37141
37145
  template: caseLevel.template ?? suiteLevel.template,
37142
37146
  isolation: caseLevel.isolation ?? suiteLevel.isolation,
@@ -40013,14 +40017,18 @@ var PiAgentSdkProvider = class {
40013
40017
  }
40014
40018
  });
40015
40019
  try {
40016
- const timeoutMs = this.config.timeoutMs ?? 12e4;
40017
- const timeoutPromise = new Promise((_, reject) => {
40018
- setTimeout(
40019
- () => reject(new Error(`Pi agent SDK timed out after ${timeoutMs}ms`)),
40020
- timeoutMs
40021
- );
40022
- });
40023
- await Promise.race([agent.prompt(request.question), timeoutPromise]);
40020
+ if (this.config.timeoutMs) {
40021
+ const timeoutMs = this.config.timeoutMs;
40022
+ const timeoutPromise = new Promise((_, reject) => {
40023
+ setTimeout(
40024
+ () => reject(new Error(`Pi agent SDK timed out after ${timeoutMs}ms`)),
40025
+ timeoutMs
40026
+ );
40027
+ });
40028
+ await Promise.race([agent.prompt(request.question), timeoutPromise]);
40029
+ } else {
40030
+ await agent.prompt(request.question);
40031
+ }
40024
40032
  await agent.waitForIdle();
40025
40033
  const agentMessages = agent.state.messages;
40026
40034
  for (const msg of agentMessages) {
@@ -41096,7 +41104,7 @@ async function waitForBatchResponses(responseFilesFinal, pollInterval = 1e3, sil
41096
41104
  var logged = false;
41097
41105
  function getAgentvHome() {
41098
41106
  const envHome = process.env.AGENTV_HOME;
41099
- if (envHome) {
41107
+ if (envHome && envHome !== "undefined") {
41100
41108
  if (!logged) {
41101
41109
  logged = true;
41102
41110
  console.warn(`Using AGENTV_HOME: ${envHome}`);
@@ -47057,6 +47065,9 @@ function toScriptConfig(hook, hookName, context) {
47057
47065
  function hasHookCommand(hook) {
47058
47066
  return !!(hook?.command && hook.command.length > 0 || hook?.script && hook.script.length > 0);
47059
47067
  }
47068
+ function hooksEnabled(workspace) {
47069
+ return workspace?.hooks?.enabled !== false;
47070
+ }
47060
47071
  function getWorkspaceTemplate(target) {
47061
47072
  const config2 = target.config;
47062
47073
  if ("workspaceTemplate" in config2 && typeof config2.workspaceTemplate === "string") {
@@ -47275,9 +47286,28 @@ async function runEvaluation(options) {
47275
47286
  const availablePoolSlots = [];
47276
47287
  const poolSlotBaselines = /* @__PURE__ */ new Map();
47277
47288
  const poolMaxSlots = Math.min(configPoolMaxSlots ?? 10, 50);
47289
+ let staticMaterialised = false;
47278
47290
  if (useStaticWorkspace && configuredStaticPath) {
47291
+ const isYamlConfiguredPath = !cliWorkspacePath && !!yamlWorkspacePath;
47292
+ const dirExists = await stat7(configuredStaticPath).then(
47293
+ (s) => s.isDirectory(),
47294
+ () => false
47295
+ );
47296
+ const isEmpty = dirExists ? (await readdir6(configuredStaticPath)).length === 0 : false;
47297
+ if (isYamlConfiguredPath && (!dirExists || isEmpty)) {
47298
+ if (!dirExists) {
47299
+ await mkdir12(configuredStaticPath, { recursive: true });
47300
+ }
47301
+ if (workspaceTemplate) {
47302
+ await copyDirectoryRecursive(workspaceTemplate, configuredStaticPath);
47303
+ setupLog(`copied template into static workspace: ${configuredStaticPath}`);
47304
+ }
47305
+ staticMaterialised = true;
47306
+ setupLog(`materialised static workspace at: ${configuredStaticPath}`);
47307
+ } else {
47308
+ setupLog(`reusing existing static workspace: ${configuredStaticPath}`);
47309
+ }
47279
47310
  sharedWorkspacePath = configuredStaticPath;
47280
- setupLog(`using static workspace: ${configuredStaticPath}`);
47281
47311
  } else if (usePool && suiteWorkspace?.repos) {
47282
47312
  const slotsNeeded = workers;
47283
47313
  setupLog(`acquiring ${slotsNeeded} workspace pool slot(s) (pool capacity: ${poolMaxSlots})`);
@@ -47323,7 +47353,8 @@ async function runEvaluation(options) {
47323
47353
  } catch {
47324
47354
  }
47325
47355
  }
47326
- const repoManager = suiteWorkspace?.repos?.length && !usePool && !useStaticWorkspace ? new RepoManager(verbose) : void 0;
47356
+ const needsRepoMaterialisation = !!suiteWorkspace?.repos?.length && !usePool && (!useStaticWorkspace || staticMaterialised);
47357
+ const repoManager = needsRepoMaterialisation ? new RepoManager(verbose) : void 0;
47327
47358
  if (repoManager && sharedWorkspacePath && suiteWorkspace?.repos && !isPerTestIsolation) {
47328
47359
  setupLog(
47329
47360
  `materializing ${suiteWorkspace.repos.length} shared repo(s) into ${sharedWorkspacePath}`
@@ -47340,8 +47371,9 @@ async function runEvaluation(options) {
47340
47371
  throw new Error(`Failed to materialize repos: ${message}`);
47341
47372
  }
47342
47373
  }
47374
+ const suiteHooksEnabled = hooksEnabled(suiteWorkspace);
47343
47375
  const suiteBeforeAllHook = suiteWorkspace?.hooks?.before_all;
47344
- if (sharedWorkspacePath && hasHookCommand(suiteBeforeAllHook)) {
47376
+ if (sharedWorkspacePath && suiteHooksEnabled && hasHookCommand(suiteBeforeAllHook)) {
47345
47377
  const beforeAllHook = suiteBeforeAllHook;
47346
47378
  const beforeAllCommand = (beforeAllHook.command ?? beforeAllHook.script ?? []).join(" ");
47347
47379
  setupLog(
@@ -47368,7 +47400,7 @@ async function runEvaluation(options) {
47368
47400
  throw new Error(`before_all script failed: ${message}`);
47369
47401
  }
47370
47402
  }
47371
- if (availablePoolSlots.length > 0 && hasHookCommand(suiteBeforeAllHook)) {
47403
+ if (availablePoolSlots.length > 0 && suiteHooksEnabled && hasHookCommand(suiteBeforeAllHook)) {
47372
47404
  const beforeAllHook = suiteBeforeAllHook;
47373
47405
  for (const slot of availablePoolSlots) {
47374
47406
  setupLog(`running before_all on pool slot ${slot.index}`);
@@ -47610,7 +47642,7 @@ async function runEvaluation(options) {
47610
47642
  }
47611
47643
  const afterAllWorkspaces = poolSlots.length > 1 ? poolSlots.map((s) => s.path) : sharedWorkspacePath ? [sharedWorkspacePath] : [];
47612
47644
  const suiteAfterAllHook = suiteWorkspace?.hooks?.after_all;
47613
- if (afterAllWorkspaces.length > 0 && hasHookCommand(suiteAfterAllHook)) {
47645
+ if (afterAllWorkspaces.length > 0 && suiteHooksEnabled && hasHookCommand(suiteAfterAllHook)) {
47614
47646
  const afterAllHook = suiteAfterAllHook;
47615
47647
  for (const wsPath of afterAllWorkspaces) {
47616
47648
  const scriptContext = {
@@ -47858,6 +47890,7 @@ async function runEvalCase(options) {
47858
47890
  let afterEachOutput;
47859
47891
  const isSharedWorkspace = !!sharedWorkspacePath;
47860
47892
  let caseWorkspaceFile;
47893
+ const caseHooksEnabled = hooksEnabled(evalCase.workspace);
47861
47894
  if (!workspacePath) {
47862
47895
  const rawCaseTemplate = evalCase.workspace?.template ?? getWorkspaceTemplate(target);
47863
47896
  const resolvedCaseTemplate = await resolveWorkspaceTemplate(rawCaseTemplate);
@@ -47919,7 +47952,7 @@ async function runEvalCase(options) {
47919
47952
  }
47920
47953
  }
47921
47954
  const caseBeforeAllHook = evalCase.workspace?.hooks?.before_all;
47922
- if (workspacePath && hasHookCommand(caseBeforeAllHook)) {
47955
+ if (workspacePath && caseHooksEnabled && hasHookCommand(caseBeforeAllHook)) {
47923
47956
  const beforeAllHook = caseBeforeAllHook;
47924
47957
  const beforeAllCommand = (beforeAllHook.command ?? beforeAllHook.script ?? []).join(" ");
47925
47958
  if (setupDebug) {
@@ -47963,7 +47996,7 @@ async function runEvalCase(options) {
47963
47996
  }
47964
47997
  }
47965
47998
  const caseBeforeEachHook = evalCase.workspace?.hooks?.before_each;
47966
- if (workspacePath && hasHookCommand(caseBeforeEachHook)) {
47999
+ if (workspacePath && caseHooksEnabled && hasHookCommand(caseBeforeEachHook)) {
47967
48000
  const beforeEachHook = caseBeforeEachHook;
47968
48001
  const scriptContext = {
47969
48002
  workspacePath,
@@ -48092,7 +48125,7 @@ async function runEvalCase(options) {
48092
48125
  }
48093
48126
  }
48094
48127
  const providerError = extractProviderError(providerResponse);
48095
- if (repoManager && workspacePath && evalCase.workspace?.hooks?.after_each?.reset && evalCase.workspace.hooks.after_each.reset !== "none" && evalCase.workspace.repos) {
48128
+ if (caseHooksEnabled && repoManager && workspacePath && evalCase.workspace?.hooks?.after_each?.reset && evalCase.workspace.hooks.after_each.reset !== "none" && evalCase.workspace.repos) {
48096
48129
  try {
48097
48130
  await repoManager.reset(
48098
48131
  evalCase.workspace.repos,
@@ -48103,7 +48136,7 @@ async function runEvalCase(options) {
48103
48136
  }
48104
48137
  }
48105
48138
  const caseAfterEachHook = evalCase.workspace?.hooks?.after_each;
48106
- if (workspacePath && hasHookCommand(caseAfterEachHook)) {
48139
+ if (workspacePath && caseHooksEnabled && hasHookCommand(caseAfterEachHook)) {
48107
48140
  const afterEachHook = caseAfterEachHook;
48108
48141
  const scriptContext = {
48109
48142
  workspacePath,
@@ -48878,7 +48911,7 @@ async function evaluate(config2) {
48878
48911
  repoRoot,
48879
48912
  target: resolvedTarget,
48880
48913
  maxRetries: config2.maxRetries ?? 2,
48881
- agentTimeoutMs: config2.agentTimeoutMs ?? 12e4,
48914
+ agentTimeoutMs: config2.agentTimeoutMs,
48882
48915
  verbose: config2.verbose,
48883
48916
  maxConcurrency: config2.workers ?? 3,
48884
48917
  filter: config2.filter,
@@ -48978,7 +49011,7 @@ var AgentVConfigSchema = external_exports.object({
48978
49011
  workers: external_exports.number().int().min(1).max(50).optional(),
48979
49012
  /** Maximum retries on failure (default: 2) */
48980
49013
  maxRetries: external_exports.number().int().min(0).optional(),
48981
- /** Agent timeout in milliseconds (default: 120000) */
49014
+ /** Agent timeout in milliseconds. No timeout if not set. */
48982
49015
  agentTimeoutMs: external_exports.number().int().min(0).optional(),
48983
49016
  /** Enable verbose logging */
48984
49017
  verbose: external_exports.boolean().optional(),
@@ -49732,4 +49765,4 @@ export {
49732
49765
  OtelStreamingObserver,
49733
49766
  createAgentKernel
49734
49767
  };
49735
- //# sourceMappingURL=chunk-NWQTM4ZK.js.map
49768
+ //# sourceMappingURL=chunk-BM77B57R.js.map