@agentv/core 2.18.1 → 2.18.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-I4VQY3XJ.js → chunk-V42NUK73.js} +1 -1
- package/dist/chunk-V42NUK73.js.map +1 -0
- package/dist/evaluation/validation/index.cjs.map +1 -1
- package/dist/evaluation/validation/index.js +1 -1
- package/dist/index.cjs +53 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +55 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-I4VQY3XJ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -4778,11 +4778,13 @@ function parseWorkspaceHookConfig(raw, evalFileDir) {
|
|
|
4778
4778
|
function parseWorkspaceHooksConfig(raw, evalFileDir) {
|
|
4779
4779
|
if (!isJsonObject(raw)) return void 0;
|
|
4780
4780
|
const obj = raw;
|
|
4781
|
+
const enabled = typeof obj.enabled === "boolean" ? obj.enabled : void 0;
|
|
4781
4782
|
const beforeAll = parseWorkspaceHookConfig(obj.before_all, evalFileDir);
|
|
4782
4783
|
const beforeEach = parseWorkspaceHookConfig(obj.before_each, evalFileDir);
|
|
4783
4784
|
const afterEach = parseWorkspaceHookConfig(obj.after_each, evalFileDir);
|
|
4784
4785
|
const afterAll = parseWorkspaceHookConfig(obj.after_all, evalFileDir);
|
|
4785
4786
|
const hooks = {
|
|
4787
|
+
...enabled !== void 0 && { enabled },
|
|
4786
4788
|
...beforeAll !== void 0 && { before_all: beforeAll },
|
|
4787
4789
|
...beforeEach !== void 0 && { before_each: beforeEach },
|
|
4788
4790
|
...afterEach !== void 0 && { after_each: afterEach },
|
|
@@ -4855,13 +4857,15 @@ function mergeWorkspaceConfigs(suiteLevel, caseLevel) {
|
|
|
4855
4857
|
...caseHook ?? {}
|
|
4856
4858
|
};
|
|
4857
4859
|
};
|
|
4860
|
+
const mergedEnabled = caseLevel.hooks?.enabled ?? suiteLevel.hooks?.enabled;
|
|
4858
4861
|
const mergedHooks = {
|
|
4862
|
+
...mergedEnabled !== void 0 && { enabled: mergedEnabled },
|
|
4859
4863
|
before_all: mergeHook(suiteLevel.hooks?.before_all, caseLevel.hooks?.before_all),
|
|
4860
4864
|
before_each: mergeHook(suiteLevel.hooks?.before_each, caseLevel.hooks?.before_each),
|
|
4861
4865
|
after_each: mergeHook(suiteLevel.hooks?.after_each, caseLevel.hooks?.after_each),
|
|
4862
4866
|
after_all: mergeHook(suiteLevel.hooks?.after_all, caseLevel.hooks?.after_all)
|
|
4863
4867
|
};
|
|
4864
|
-
const hasHooks = Object.values(mergedHooks).some((hook) => hook !== void 0);
|
|
4868
|
+
const hasHooks = mergedEnabled !== void 0 || Object.values(mergedHooks).some((hook) => hook !== void 0 && typeof hook === "object");
|
|
4865
4869
|
return {
|
|
4866
4870
|
template: caseLevel.template ?? suiteLevel.template,
|
|
4867
4871
|
isolation: caseLevel.isolation ?? suiteLevel.isolation,
|
|
@@ -7923,14 +7927,18 @@ var PiAgentSdkProvider = class {
|
|
|
7923
7927
|
}
|
|
7924
7928
|
});
|
|
7925
7929
|
try {
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
(
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7930
|
+
if (this.config.timeoutMs) {
|
|
7931
|
+
const timeoutMs = this.config.timeoutMs;
|
|
7932
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
7933
|
+
setTimeout(
|
|
7934
|
+
() => reject(new Error(`Pi agent SDK timed out after ${timeoutMs}ms`)),
|
|
7935
|
+
timeoutMs
|
|
7936
|
+
);
|
|
7937
|
+
});
|
|
7938
|
+
await Promise.race([agent.prompt(request.question), timeoutPromise]);
|
|
7939
|
+
} else {
|
|
7940
|
+
await agent.prompt(request.question);
|
|
7941
|
+
}
|
|
7934
7942
|
await agent.waitForIdle();
|
|
7935
7943
|
const agentMessages = agent.state.messages;
|
|
7936
7944
|
for (const msg of agentMessages) {
|
|
@@ -16300,6 +16308,9 @@ function toScriptConfig(hook, hookName, context2) {
|
|
|
16300
16308
|
function hasHookCommand(hook) {
|
|
16301
16309
|
return !!(hook?.command && hook.command.length > 0 || hook?.script && hook.script.length > 0);
|
|
16302
16310
|
}
|
|
16311
|
+
function hooksEnabled(workspace) {
|
|
16312
|
+
return workspace?.hooks?.enabled !== false;
|
|
16313
|
+
}
|
|
16303
16314
|
function getWorkspaceTemplate(target) {
|
|
16304
16315
|
const config = target.config;
|
|
16305
16316
|
if ("workspaceTemplate" in config && typeof config.workspaceTemplate === "string") {
|
|
@@ -16518,9 +16529,28 @@ async function runEvaluation(options) {
|
|
|
16518
16529
|
const availablePoolSlots = [];
|
|
16519
16530
|
const poolSlotBaselines = /* @__PURE__ */ new Map();
|
|
16520
16531
|
const poolMaxSlots = Math.min(configPoolMaxSlots ?? 10, 50);
|
|
16532
|
+
let staticMaterialised = false;
|
|
16521
16533
|
if (useStaticWorkspace && configuredStaticPath) {
|
|
16534
|
+
const isYamlConfiguredPath = !cliWorkspacePath && !!yamlWorkspacePath;
|
|
16535
|
+
const dirExists = await (0, import_promises29.stat)(configuredStaticPath).then(
|
|
16536
|
+
(s) => s.isDirectory(),
|
|
16537
|
+
() => false
|
|
16538
|
+
);
|
|
16539
|
+
const isEmpty = dirExists ? (await (0, import_promises29.readdir)(configuredStaticPath)).length === 0 : false;
|
|
16540
|
+
if (isYamlConfiguredPath && (!dirExists || isEmpty)) {
|
|
16541
|
+
if (!dirExists) {
|
|
16542
|
+
await (0, import_promises29.mkdir)(configuredStaticPath, { recursive: true });
|
|
16543
|
+
}
|
|
16544
|
+
if (workspaceTemplate) {
|
|
16545
|
+
await copyDirectoryRecursive(workspaceTemplate, configuredStaticPath);
|
|
16546
|
+
setupLog(`copied template into static workspace: ${configuredStaticPath}`);
|
|
16547
|
+
}
|
|
16548
|
+
staticMaterialised = true;
|
|
16549
|
+
setupLog(`materialised static workspace at: ${configuredStaticPath}`);
|
|
16550
|
+
} else {
|
|
16551
|
+
setupLog(`reusing existing static workspace: ${configuredStaticPath}`);
|
|
16552
|
+
}
|
|
16522
16553
|
sharedWorkspacePath = configuredStaticPath;
|
|
16523
|
-
setupLog(`using static workspace: ${configuredStaticPath}`);
|
|
16524
16554
|
} else if (usePool && suiteWorkspace?.repos) {
|
|
16525
16555
|
const slotsNeeded = workers;
|
|
16526
16556
|
setupLog(`acquiring ${slotsNeeded} workspace pool slot(s) (pool capacity: ${poolMaxSlots})`);
|
|
@@ -16566,7 +16596,8 @@ async function runEvaluation(options) {
|
|
|
16566
16596
|
} catch {
|
|
16567
16597
|
}
|
|
16568
16598
|
}
|
|
16569
|
-
const
|
|
16599
|
+
const needsRepoMaterialisation = !!suiteWorkspace?.repos?.length && !usePool && (!useStaticWorkspace || staticMaterialised);
|
|
16600
|
+
const repoManager = needsRepoMaterialisation ? new RepoManager(verbose) : void 0;
|
|
16570
16601
|
if (repoManager && sharedWorkspacePath && suiteWorkspace?.repos && !isPerTestIsolation) {
|
|
16571
16602
|
setupLog(
|
|
16572
16603
|
`materializing ${suiteWorkspace.repos.length} shared repo(s) into ${sharedWorkspacePath}`
|
|
@@ -16583,8 +16614,9 @@ async function runEvaluation(options) {
|
|
|
16583
16614
|
throw new Error(`Failed to materialize repos: ${message}`);
|
|
16584
16615
|
}
|
|
16585
16616
|
}
|
|
16617
|
+
const suiteHooksEnabled = hooksEnabled(suiteWorkspace);
|
|
16586
16618
|
const suiteBeforeAllHook = suiteWorkspace?.hooks?.before_all;
|
|
16587
|
-
if (sharedWorkspacePath && hasHookCommand(suiteBeforeAllHook)) {
|
|
16619
|
+
if (sharedWorkspacePath && suiteHooksEnabled && hasHookCommand(suiteBeforeAllHook)) {
|
|
16588
16620
|
const beforeAllHook = suiteBeforeAllHook;
|
|
16589
16621
|
const beforeAllCommand = (beforeAllHook.command ?? beforeAllHook.script ?? []).join(" ");
|
|
16590
16622
|
setupLog(
|
|
@@ -16611,7 +16643,7 @@ async function runEvaluation(options) {
|
|
|
16611
16643
|
throw new Error(`before_all script failed: ${message}`);
|
|
16612
16644
|
}
|
|
16613
16645
|
}
|
|
16614
|
-
if (availablePoolSlots.length > 0 && hasHookCommand(suiteBeforeAllHook)) {
|
|
16646
|
+
if (availablePoolSlots.length > 0 && suiteHooksEnabled && hasHookCommand(suiteBeforeAllHook)) {
|
|
16615
16647
|
const beforeAllHook = suiteBeforeAllHook;
|
|
16616
16648
|
for (const slot of availablePoolSlots) {
|
|
16617
16649
|
setupLog(`running before_all on pool slot ${slot.index}`);
|
|
@@ -16853,7 +16885,7 @@ async function runEvaluation(options) {
|
|
|
16853
16885
|
}
|
|
16854
16886
|
const afterAllWorkspaces = poolSlots.length > 1 ? poolSlots.map((s) => s.path) : sharedWorkspacePath ? [sharedWorkspacePath] : [];
|
|
16855
16887
|
const suiteAfterAllHook = suiteWorkspace?.hooks?.after_all;
|
|
16856
|
-
if (afterAllWorkspaces.length > 0 && hasHookCommand(suiteAfterAllHook)) {
|
|
16888
|
+
if (afterAllWorkspaces.length > 0 && suiteHooksEnabled && hasHookCommand(suiteAfterAllHook)) {
|
|
16857
16889
|
const afterAllHook = suiteAfterAllHook;
|
|
16858
16890
|
for (const wsPath of afterAllWorkspaces) {
|
|
16859
16891
|
const scriptContext = {
|
|
@@ -17101,6 +17133,7 @@ async function runEvalCase(options) {
|
|
|
17101
17133
|
let afterEachOutput;
|
|
17102
17134
|
const isSharedWorkspace = !!sharedWorkspacePath;
|
|
17103
17135
|
let caseWorkspaceFile;
|
|
17136
|
+
const caseHooksEnabled = hooksEnabled(evalCase.workspace);
|
|
17104
17137
|
if (!workspacePath) {
|
|
17105
17138
|
const rawCaseTemplate = evalCase.workspace?.template ?? getWorkspaceTemplate(target);
|
|
17106
17139
|
const resolvedCaseTemplate = await resolveWorkspaceTemplate(rawCaseTemplate);
|
|
@@ -17162,7 +17195,7 @@ async function runEvalCase(options) {
|
|
|
17162
17195
|
}
|
|
17163
17196
|
}
|
|
17164
17197
|
const caseBeforeAllHook = evalCase.workspace?.hooks?.before_all;
|
|
17165
|
-
if (workspacePath && hasHookCommand(caseBeforeAllHook)) {
|
|
17198
|
+
if (workspacePath && caseHooksEnabled && hasHookCommand(caseBeforeAllHook)) {
|
|
17166
17199
|
const beforeAllHook = caseBeforeAllHook;
|
|
17167
17200
|
const beforeAllCommand = (beforeAllHook.command ?? beforeAllHook.script ?? []).join(" ");
|
|
17168
17201
|
if (setupDebug) {
|
|
@@ -17206,7 +17239,7 @@ async function runEvalCase(options) {
|
|
|
17206
17239
|
}
|
|
17207
17240
|
}
|
|
17208
17241
|
const caseBeforeEachHook = evalCase.workspace?.hooks?.before_each;
|
|
17209
|
-
if (workspacePath && hasHookCommand(caseBeforeEachHook)) {
|
|
17242
|
+
if (workspacePath && caseHooksEnabled && hasHookCommand(caseBeforeEachHook)) {
|
|
17210
17243
|
const beforeEachHook = caseBeforeEachHook;
|
|
17211
17244
|
const scriptContext = {
|
|
17212
17245
|
workspacePath,
|
|
@@ -17335,7 +17368,7 @@ async function runEvalCase(options) {
|
|
|
17335
17368
|
}
|
|
17336
17369
|
}
|
|
17337
17370
|
const providerError = extractProviderError(providerResponse);
|
|
17338
|
-
if (repoManager && workspacePath && evalCase.workspace?.hooks?.after_each?.reset && evalCase.workspace.hooks.after_each.reset !== "none" && evalCase.workspace.repos) {
|
|
17371
|
+
if (caseHooksEnabled && repoManager && workspacePath && evalCase.workspace?.hooks?.after_each?.reset && evalCase.workspace.hooks.after_each.reset !== "none" && evalCase.workspace.repos) {
|
|
17339
17372
|
try {
|
|
17340
17373
|
await repoManager.reset(
|
|
17341
17374
|
evalCase.workspace.repos,
|
|
@@ -17346,7 +17379,7 @@ async function runEvalCase(options) {
|
|
|
17346
17379
|
}
|
|
17347
17380
|
}
|
|
17348
17381
|
const caseAfterEachHook = evalCase.workspace?.hooks?.after_each;
|
|
17349
|
-
if (workspacePath && hasHookCommand(caseAfterEachHook)) {
|
|
17382
|
+
if (workspacePath && caseHooksEnabled && hasHookCommand(caseAfterEachHook)) {
|
|
17350
17383
|
const afterEachHook = caseAfterEachHook;
|
|
17351
17384
|
const scriptContext = {
|
|
17352
17385
|
workspacePath,
|
|
@@ -18125,7 +18158,7 @@ async function evaluate(config) {
|
|
|
18125
18158
|
repoRoot,
|
|
18126
18159
|
target: resolvedTarget,
|
|
18127
18160
|
maxRetries: config.maxRetries ?? 2,
|
|
18128
|
-
agentTimeoutMs: config.agentTimeoutMs
|
|
18161
|
+
agentTimeoutMs: config.agentTimeoutMs,
|
|
18129
18162
|
verbose: config.verbose,
|
|
18130
18163
|
maxConcurrency: config.workers ?? 3,
|
|
18131
18164
|
filter: config.filter,
|
|
@@ -18228,7 +18261,7 @@ var AgentVConfigSchema = import_zod6.z.object({
|
|
|
18228
18261
|
workers: import_zod6.z.number().int().min(1).max(50).optional(),
|
|
18229
18262
|
/** Maximum retries on failure (default: 2) */
|
|
18230
18263
|
maxRetries: import_zod6.z.number().int().min(0).optional(),
|
|
18231
|
-
/** Agent timeout in milliseconds
|
|
18264
|
+
/** Agent timeout in milliseconds. No timeout if not set. */
|
|
18232
18265
|
agentTimeoutMs: import_zod6.z.number().int().min(0).optional(),
|
|
18233
18266
|
/** Enable verbose logging */
|
|
18234
18267
|
verbose: import_zod6.z.boolean().optional(),
|