@agentv/core 4.21.0-next.1 → 4.22.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-WCW3V6QJ.js → chunk-B3BLJRYI.js} +26 -4
- package/dist/chunk-B3BLJRYI.js.map +1 -0
- package/dist/index.cjs +96 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +107 -1
- package/dist/index.d.ts +107 -1
- package/dist/index.js +72 -1
- package/dist/index.js.map +1 -1
- package/dist/{ts-eval-loader-HPIPE72C.js → ts-eval-loader-PA4YFM5D.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-WCW3V6QJ.js.map +0 -1
- /package/dist/{ts-eval-loader-HPIPE72C.js.map → ts-eval-loader-PA4YFM5D.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -788,11 +788,13 @@ async function loadConfig(evalFilePath, repoRoot) {
|
|
|
788
788
|
configPath
|
|
789
789
|
);
|
|
790
790
|
const results = parseResultsConfig(parsed.results, configPath);
|
|
791
|
+
const hooks = parseHooksConfig(parsed.hooks, configPath);
|
|
791
792
|
return {
|
|
792
793
|
required_version: requiredVersion,
|
|
793
794
|
eval_patterns: evalPatterns,
|
|
794
795
|
execution: executionDefaults,
|
|
795
|
-
results
|
|
796
|
+
results,
|
|
797
|
+
...hooks && { hooks }
|
|
796
798
|
};
|
|
797
799
|
} catch (error) {
|
|
798
800
|
logWarning(
|
|
@@ -1139,6 +1141,25 @@ function parseResultsExportConfig(raw, configPath) {
|
|
|
1139
1141
|
...branchPrefix && { branch_prefix: branchPrefix }
|
|
1140
1142
|
};
|
|
1141
1143
|
}
|
|
1144
|
+
function parseHooksConfig(raw, configPath) {
|
|
1145
|
+
if (raw === void 0 || raw === null) {
|
|
1146
|
+
return void 0;
|
|
1147
|
+
}
|
|
1148
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
1149
|
+
logWarning(`Invalid hooks in ${configPath}, expected object`);
|
|
1150
|
+
return void 0;
|
|
1151
|
+
}
|
|
1152
|
+
const obj = raw;
|
|
1153
|
+
const beforeSession = obj.before_session;
|
|
1154
|
+
if (beforeSession !== void 0) {
|
|
1155
|
+
if (typeof beforeSession !== "string" || beforeSession.trim().length === 0) {
|
|
1156
|
+
logWarning(`Invalid hooks.before_session in ${configPath}, expected non-empty string`);
|
|
1157
|
+
return void 0;
|
|
1158
|
+
}
|
|
1159
|
+
return { before_session: beforeSession.trim() };
|
|
1160
|
+
}
|
|
1161
|
+
return void 0;
|
|
1162
|
+
}
|
|
1142
1163
|
function logWarning(message) {
|
|
1143
1164
|
console.warn(`${ANSI_YELLOW2}Warning: ${message}${ANSI_RESET3}`);
|
|
1144
1165
|
}
|
|
@@ -24440,6 +24461,7 @@ __export(index_exports, {
|
|
|
24440
24461
|
parseClaudeSession: () => parseClaudeSession,
|
|
24441
24462
|
parseCodexSession: () => parseCodexSession,
|
|
24442
24463
|
parseCopilotEvents: () => parseCopilotEvents,
|
|
24464
|
+
parseEnvOutput: () => parseEnvOutput,
|
|
24443
24465
|
parseJsonFromText: () => parseJsonFromText,
|
|
24444
24466
|
parseJsonSafe: () => parseJsonSafe,
|
|
24445
24467
|
prepareResultsRepoBranch: () => prepareResultsRepoBranch,
|
|
@@ -24459,6 +24481,7 @@ __export(index_exports, {
|
|
|
24459
24481
|
resolveTargetDefinition: () => resolveTargetDefinition,
|
|
24460
24482
|
resolveWorkspaceTemplate: () => resolveWorkspaceTemplate,
|
|
24461
24483
|
rubricEvaluationSchema: () => rubricEvaluationSchema,
|
|
24484
|
+
runBeforeSessionHook: () => runBeforeSessionHook,
|
|
24462
24485
|
runContainsAllAssertion: () => runContainsAllAssertion,
|
|
24463
24486
|
runContainsAnyAssertion: () => runContainsAnyAssertion,
|
|
24464
24487
|
runContainsAssertion: () => runContainsAssertion,
|
|
@@ -24474,6 +24497,7 @@ __export(index_exports, {
|
|
|
24474
24497
|
runStartsWithAssertion: () => runStartsWithAssertion,
|
|
24475
24498
|
saveBenchmarkRegistry: () => saveBenchmarkRegistry,
|
|
24476
24499
|
scanRepoDeps: () => scanRepoDeps,
|
|
24500
|
+
scoreRangeEvaluationSchema: () => scoreRangeEvaluationSchema,
|
|
24477
24501
|
scoreToVerdict: () => scoreToVerdict,
|
|
24478
24502
|
shouldEnableCache: () => shouldEnableCache,
|
|
24479
24503
|
shouldSkipCacheForTemperature: () => shouldSkipCacheForTemperature,
|
|
@@ -24811,6 +24835,17 @@ var AgentVConfigSchema = import_zod5.z.object({
|
|
|
24811
24835
|
maxCostUsd: import_zod5.z.number().min(0).optional(),
|
|
24812
24836
|
/** Maximum duration per run in milliseconds */
|
|
24813
24837
|
maxDurationMs: import_zod5.z.number().int().min(0).optional()
|
|
24838
|
+
}).optional(),
|
|
24839
|
+
/** Lifecycle hooks */
|
|
24840
|
+
hooks: import_zod5.z.object({
|
|
24841
|
+
/**
|
|
24842
|
+
* Shell command to run once at agentv startup, before any command executes.
|
|
24843
|
+
* stdout is parsed for env var exports (`KEY=value` or `export KEY="value"`)
|
|
24844
|
+
* and injected into process.env. Keys already set in the environment are
|
|
24845
|
+
* not overwritten — existing env always takes priority.
|
|
24846
|
+
* stderr is forwarded to the user. Non-zero exit aborts with an error.
|
|
24847
|
+
*/
|
|
24848
|
+
beforeSession: import_zod5.z.string().optional()
|
|
24814
24849
|
}).optional()
|
|
24815
24850
|
});
|
|
24816
24851
|
function defineConfig(config) {
|
|
@@ -26110,6 +26145,63 @@ var RunBudgetTracker = class {
|
|
|
26110
26145
|
}
|
|
26111
26146
|
};
|
|
26112
26147
|
|
|
26148
|
+
// src/evaluation/hooks.ts
|
|
26149
|
+
init_cjs_shims();
|
|
26150
|
+
var import_node_child_process13 = require("child_process");
|
|
26151
|
+
var ANSI_YELLOW9 = "\x1B[33m";
|
|
26152
|
+
var ANSI_RESET10 = "\x1B[0m";
|
|
26153
|
+
function parseEnvOutput(stdout) {
|
|
26154
|
+
const result = {};
|
|
26155
|
+
for (const line of stdout.split("\n")) {
|
|
26156
|
+
const trimmed = line.trim();
|
|
26157
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
26158
|
+
const match = trimmed.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
|
|
26159
|
+
if (!match) continue;
|
|
26160
|
+
const key = match[1];
|
|
26161
|
+
let value = match[2];
|
|
26162
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
26163
|
+
value = value.slice(1, -1);
|
|
26164
|
+
}
|
|
26165
|
+
if (key) {
|
|
26166
|
+
result[key] = value;
|
|
26167
|
+
}
|
|
26168
|
+
}
|
|
26169
|
+
return result;
|
|
26170
|
+
}
|
|
26171
|
+
function runBeforeSessionHook(command) {
|
|
26172
|
+
const isWindows = process.platform === "win32";
|
|
26173
|
+
const shell = isWindows ? "cmd" : "sh";
|
|
26174
|
+
const shellFlag = isWindows ? "/c" : "-c";
|
|
26175
|
+
console.log(`${ANSI_YELLOW9}Running before_session hook: ${command}${ANSI_RESET10}`);
|
|
26176
|
+
const result = (0, import_node_child_process13.spawnSync)(shell, [shellFlag, command], {
|
|
26177
|
+
encoding: "utf8",
|
|
26178
|
+
// Do not inherit stdio — capture stdout for parsing, forward stderr manually
|
|
26179
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
26180
|
+
});
|
|
26181
|
+
if (result.stderr) {
|
|
26182
|
+
process.stderr.write(result.stderr);
|
|
26183
|
+
}
|
|
26184
|
+
if (result.error) {
|
|
26185
|
+
throw new Error(`before_session hook failed to start: ${result.error.message}`);
|
|
26186
|
+
}
|
|
26187
|
+
if (result.status !== 0) {
|
|
26188
|
+
throw new Error(
|
|
26189
|
+
`before_session hook exited with code ${result.status ?? "unknown"}: ${command}`
|
|
26190
|
+
);
|
|
26191
|
+
}
|
|
26192
|
+
const vars = parseEnvOutput(result.stdout ?? "");
|
|
26193
|
+
let injected = 0;
|
|
26194
|
+
for (const [key, value] of Object.entries(vars)) {
|
|
26195
|
+
if (process.env[key] === void 0) {
|
|
26196
|
+
process.env[key] = value;
|
|
26197
|
+
injected++;
|
|
26198
|
+
}
|
|
26199
|
+
}
|
|
26200
|
+
if (injected > 0) {
|
|
26201
|
+
console.log(`before_session hook injected ${injected} environment variable(s).`);
|
|
26202
|
+
}
|
|
26203
|
+
}
|
|
26204
|
+
|
|
26113
26205
|
// src/import/index.ts
|
|
26114
26206
|
init_cjs_shims();
|
|
26115
26207
|
|
|
@@ -26896,6 +26988,7 @@ function createAgentKernel() {
|
|
|
26896
26988
|
parseClaudeSession,
|
|
26897
26989
|
parseCodexSession,
|
|
26898
26990
|
parseCopilotEvents,
|
|
26991
|
+
parseEnvOutput,
|
|
26899
26992
|
parseJsonFromText,
|
|
26900
26993
|
parseJsonSafe,
|
|
26901
26994
|
prepareResultsRepoBranch,
|
|
@@ -26915,6 +27008,7 @@ function createAgentKernel() {
|
|
|
26915
27008
|
resolveTargetDefinition,
|
|
26916
27009
|
resolveWorkspaceTemplate,
|
|
26917
27010
|
rubricEvaluationSchema,
|
|
27011
|
+
runBeforeSessionHook,
|
|
26918
27012
|
runContainsAllAssertion,
|
|
26919
27013
|
runContainsAnyAssertion,
|
|
26920
27014
|
runContainsAssertion,
|
|
@@ -26930,6 +27024,7 @@ function createAgentKernel() {
|
|
|
26930
27024
|
runStartsWithAssertion,
|
|
26931
27025
|
saveBenchmarkRegistry,
|
|
26932
27026
|
scanRepoDeps,
|
|
27027
|
+
scoreRangeEvaluationSchema,
|
|
26933
27028
|
scoreToVerdict,
|
|
26934
27029
|
shouldEnableCache,
|
|
26935
27030
|
shouldSkipCacheForTemperature,
|